import time
import board
import adafruit_dht
import adafruit_character_lcd.character_lcd_i2c as character_lcd

# Set up the DHT22 sensor
dht22 = adafruit_dht.DHT22(board.D4)

# Set up the I2C bus using the GP0 and GP1 pins
i2c = board.I2C(board.GP0, board.GP1)

# Set up the LCD display
lcd_columns = 16
lcd_rows = 2
lcd = character_lcd.Character_LCD_I2C(i2c, lcd_columns, lcd_rows)

while True:
    # Read the temperature and humidity
    temperature = dht22.temperature
    humidity = dht22.humidity

    # Format the readings as strings
    temp_str = f"Temperature: {temperature:.1f} C"
    humidity_str = f"Humidity: {humidity:.1f}%"

    # Clear the display and write the readings to it
    lcd.clear()
    lcd.message = temp_str + "\n" + humidity_str

    # Wait a while before taking the next reading
    time.sleep(5)
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT