ESP32 Weather Station using DHT11 with LCD (MicroPython)
Weather Station using ESP32 board and DHT11 Temperature and Humidity Sensor with MicroPython. Show status on LCD Display.



MicroPython Code – ESP32 Weather Station using DHT11 with LCD Display
from machine import Pin, SoftI2C
from i2c_lcd import I2cLcd
import time
import dht
# LCD
i2c = SoftI2C(scl=Pin(22), sda=Pin(21),freq=100000)
lcd = I2cLcd(i2c, 0x27,2,16)
time.sleep(1)
lcd.clear()
# DHT11
d = dht.DHT11(Pin(23))
t = 0
h = 0
# START
text = 'Starting...'
lcd.putstr(text)
while True:
try:
d.measure()
time.sleep(2)
t = d.temperature()
h = d.humidity()
temp = 'Temp: {:.0f} C'.format(t)
humid = 'Humidity: {:.0f} %'.format(h)
print('DHT11:', t, h)
lcd.clear()
lcd.putstr(temp)
lcd.move_to(0,1)
lcd.putstr(humid)
time.sleep(5)
except:
pass