====== ESP32 DHT11 ===== This is an example of the dht reading and displaying on screen. ===== Prequisits ==== Platform.ini lib_deps = adafruit/DHT sensor library@^1.4.6 ===== Example ==== #include #include #include /* DHT11 */ #define DHTPIN 15 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); #define LCD_RS 48 #define LCD_ENABLE 47 #define LCD_D4 34 #define LCD_D5 33 #define LCD_D6 26 #define LCD_D7 21 static Adafruit_LiquidCrystal lcd(LCD_RS, LCD_ENABLE, LCD_D4, LCD_D5, LCD_D6, LCD_D7); void setup() { Serial.begin(152000); if (!lcd.begin(16, 2)) { Serial.println("Could not init LCD"); while(1); } Serial.println("LCD ready."); // Print a message to the LCD. lcd.print("IOT-OPEN"); /* dht11 setup */ dht.begin(); } void loop() { //dht11 code float h = dht.readHumidity(); float t = dht.readTemperature(); lcd.setCursor(0, 0); // First line lcd.print("H: "); lcd.print(h); lcd.print("%"); lcd.setCursor(0, 1); // Second line lcd.print("T: "); lcd.print(t); lcd.print("C"); delay(1000); }