DHT11 & DHT22 Sensors Temperature and Humidity Tutorial using Arduino and LCD

preview_player
Показать описание
Arduino Code
see comment...
Рекомендации по теме
Комментарии
Автор

#include <LiquidCrystal.h>
#include <DHT.h> //
#define DHTPIN 2 // DHT Data Pin
LiquidCrystal lcd(8, 3, 4, 5, 6, 7);
//define LCD pins (RS, E, D4, D5, D6, D7)

#define DHTTYPE DHT11 // or DHT 22

DHT dht(DHTPIN, DHTTYPE);


void setup() {
Serial.begin(9600);
Serial.println("DHT11 Sensor!");
lcd.begin(16, 2);
dht.begin();
}

void loop() {
// Wait a few seconds between measurements.
delay(1000);

float h = dht.readHumidity();
// Read temperature as Celsius
float t = dht.readTemperature();
// Read temperature as Fahrenheit
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("Failed to read from DHT sensor!");
return;
}

// Compute heat index
// Must send in temp in Fahrenheit!
float hi = dht.computeHeatIndex(f, h);
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");
Serial.print(f);
Serial.print(" *F\t");
Serial.print("Heat index: ");
Serial.print(hi);
Serial.println(" *F");

lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(t);
lcd.print(" C");
lcd.setCursor(0, 1);
lcd.print("Humi: ");
lcd.print(h);
lcd.print(" %");
}

pushpamtronic
Автор

Make a tutorial to see the reading of ultrasonic sensor on mobile screen or TFT screen

ShivamKumar-egis
Автор

Can you comment the code for getting data on serial monitor. I don't want to use LCD screen.

MohitSingh-pbbi
Автор

Make a tutorial to see the reading on phone

rohitpatel
Автор

Hi, can you please comment the code because I can’t find it on the website

ahmadchoujaa