### wk-lcd-dht-001.py
from machine import Pin, SoftI2C
from i2c_lcd import I2cLcd
i2c = SoftI2C(sda = Pin(21), scl = Pin(22))
lcd = I2cLcd(i2c, 0x27, 2, 16)
lcd.backlight_on()
lcd.clear()
import dht
import time
sensor = dht.DHT22(Pin(4))
while True:
time.sleep(2)
sensor.measure()
temp = sensor.temperature()
humi = sensor.humidity()
lcd.move_to(0,0)
lcd.putstr("Temp: ")
lcd.move_to(7,0)
lcd.putstr(str(temp))
lcd.move_to(13,0)
lcd.putstr("C")
# lcd.putstr(chr(223)+"C")
lcd.move_to(0,1)
lcd.putstr("Humi:")
lcd.move_to(7,1)
lcd.putstr(str(humi))
lcd.move_to(13,1)
lcd.putstr("%")
###==========================================
### wk-lcd-dht-002.py
# from machine import Pin, SoftI2C
# from i2c_lcd import I2cLcd
# i2c = SoftI2C(sda = Pin(21), scl = Pin(22))
# lcd = I2cLcd(i2c, 0x27, 2, 16)
# lcd.backlight_on()
# lcd.clear()
# import dht
# import time
# sensor = dht.DHT22(Pin(4))
# while True:
# time.sleep(2)
# sensor.measure()
# temp = sensor.temperature()
# humi = sensor.humidity()
# # txtTemp = 'Temp: {:6.2f} C '.format(temp)
# txtTemp = 'Temp: {:6.2f} {}C '.format(temp,chr(223))
# lcd.move_to(0,0)
# lcd.putstr(txtTemp)
# txtHumi = 'Humi: {:5.1f} % '.format(humi)
# lcd.move_to(0,1)
# lcd.putstr(txtHumi)
# # txt = 'Temp: {:6.2f} C, Humi: {:5.1f} %'.format(temp,humi)
# txt = 'Temp: {:6.2f} \u00B0C, Humi: {:5.1f} %'.format(temp,humi)
# print(txt)