NodeMCU Projects: Difference between revisions
→DHT11 Temp Sensor
Line 116:
from dht import DHT11
from esp8266_i2c_lcd import I2cLcd
d = DHT11(Pin(14)) # Pin D5
Line 123 ⟶ 125:
while True:
try:
d.measure()
lcd.putstr("Temperature: " + str(d.temperature()) + "C")▼
▲ lcd.putstr("Temperature: " + str(d.temperature()) + "C")
▲ time.sleep(10)
lcd.putstr("Humidity: " + str(d.humidity()) + "%")
lcd.clear()▼
time.sleep(10)
▲ lcd.clear()
except OSError:
print("Sensor read error!!")
lcd.putstr("Sensor read error!!")
time.sleep(5)
lcd.clear()
</syntaxhighlight>
|