Arduino: LCD + hezetasun/tenperatura sensorie

LCD: YwRobot LCM1602

LCD YwRobot LCM1602

DHT22 hezetasun/tenperatura sensorie:
DHT22

Hamen dana montata:
Arduino LCD + sensoreak

Oin kodigue:

Nire kasuen DHT22 da, DHT21 edo DHT11 badakozun, // kendu zeurieri eta imiñi bestieri:

...
//#define DHTTYPE DHT11   // DHT 11
#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301
...

Oin bai kodigue :D

#include  // 
#include  // 
#include  // 

LiquidCrystal_I2C lcd(0x27, 516,2);
 
#define DHTPIN 2

#define DHTTYPE DHT22
 
DHT dht(DHTPIN, DHTTYPE);
 
void setup()
{
  lcd.init(); 
  lcd.backlight();
  dht.begin();
  Serial.begin(9600);
}
 
void loop()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();
 
  if (isnan(t) || isnan(h))
  {
    lcd.clear();
    lcd.setCursor (0,0);
    lcd.print("Failed to read from DHT");
  }
  else
  {
    lcd.clear();
    lcd.setCursor (0,0);
    lcd.print("Hez:");
    lcd.print(h);
    Serial.print("Hezetasune:");
    Serial.print(h);
    Serial.println("");
    lcd.setCursor (0,1);
    lcd.print("Tenp:");
    lcd.print(t);
    Serial.print("Tenperaturie:");
    Serial.print(t);    
    Serial.println("");    
    delay(5000);
  }
}

Hamen dakozuie libreridxek eta upin danak bateko ia @GaurDaBihar honegaz pozik lotzien badan:

https://github.com/ZiTAL/arduino

LCD_I2C_DHT ariketie da, baie libraries karpetie derrigorrezkue da martxan imintzeko

Leave a Reply

Your email address will not be published. Required fields are marked *