import Adafruit_DHT
import time
import Adafruit_CharLCD as LCD
# Raspberry Pi pin setup
lcd_rs = 25
lcd_en = 24
lcd_d4 = 23
lcd_d5 = 17
lcd_d6 = 18
lcd_d7 = 22
lcd_backlight = 2
# Define LCD column and row size for 16x2 LCD.
lcd_rows = 2
DHT_SENSOR = Adafruit_DHT.DHT11
DHT_PIN = 4
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backlight)
lcd.message(Redronic')
# Wait 5 seconds
time.sleep(5.0)
lcd.clear()
while True:
humidity, temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)
if humidity is not None and temperature is not None:
print("Temp={0:0.1f}*C Humidity={1:0.1f} %".format(temperature, humidity))
lcd.message(“Temp={0:0.1f}*C Humidity={1:0.1f} %".format(temperature, humidity))
else:
print("Failed to retrieve data from humidity sensor")