Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "DHT.h"
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- #define DHTPIN 2
- #define DHTTYPE DHT11
- DHT dht(DHTPIN, DHTTYPE);
- LiquidCrystal_I2C lcd(0x27, 16, 2);
- void setup() {
- Serial.begin(9600);
- Serial.println(F("Senzor de temperatura si umiditate cu display 1602 cu interfata i2c"));
- lcd.init();
- lcd.backlight();
- lcd.clear();
- lcd.setCursor(0,0);
- lcd.print("Daradici Levente");
- lcd.setCursor(2,1);
- lcd.print("DHT11 Senzor");
- delay(3000);
- lcd.clear();
- dht.begin();
- }
- void loop() {
- delay(3000);
- float h = dht.readHumidity();
- // Read temperature as Celsius (the default)
- float t = dht.readTemperature();
- // Read temperature as Fahrenheit (isFahrenheit = true)
- float f = dht.readTemperature(true);
- // Check if any reads failed and exit early (to try again).
- if (isnan(h) || isnan(t) || isnan(f)) {
- Serial.println(F("Failed to read from DHT sensor!"));
- return;
- }
- // Compute heat index in Fahrenheit (the default)
- float hif = dht.computeHeatIndex(f, h);
- // Compute heat index in Celsius (isFahreheit = false)
- float hic = dht.computeHeatIndex(t, h, false);
- lcd.clear();
- lcd.setCursor(0,0);
- lcd.print("Temp: ");
- lcd.setCursor(9,0);
- lcd.print(t);
- lcd.setCursor(14,0);
- lcd.print((char)223);
- lcd.setCursor(15,0);
- lcd.print("C");
- lcd.setCursor(0,1);
- lcd.print("Umid:");
- lcd.setCursor(9,1);
- lcd.print(h);
- lcd.setCursor(15,1);
- lcd.print("%");
- Serial.print(F("Umiditate: "));
- Serial.print(h);
- Serial.print(F("% Temperatura: "));
- Serial.print(t);
- Serial.println(F("°C "));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement