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