Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import I2C_LCD_driver
- from time import *
- import board
- import adafruit_dht
- dhtDevice = adafruit_dht.DHT11(board.D4)
- mylcd = I2C_LCD_driver.lcd()
- #mylcd.lcd_display_string("Hello World!", 1)
- while True:
- try:
- # Print the values to the serial port
- temperature = dhtDevice.temperature
- humidity = dhtDevice.humidity
- mylcd.lcd_display_string("Temp:"+str(temperature)+"C"+" Hum:" +str(humidity)+"%", 1)
- mylcd.lcd_display_string("Time", 2)
- print("Temp: {:.1f} C Humidity: {}% "
- .format(temperature, humidity))
- except RuntimeError as error: # Errors happen fairly often, DHT's are hard to read, just keep going
- print(error.args[0])
- sleep(2.0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement