from machine import Pin, I2C
from time import sleep
from dht import DHT22
from pico_i2c_lcd import I2cLcd
def celsius_fahrenheit(celcius):
return max((celcius* 9/5) + 32, 0)
sensor = DHT22(Pin(7))
i2c = I2C(0, scl=Pin(5), sda=Pin(4), freq=100000)
i2c_ADDR = i2c.scan()[0]
lcd =I2cLcd(i2c, i2c_ADDR, 2, 16)
while True:
sensor.measure()
temp_cel = sensor.temperature()
temp_fah = celsius_fahrenheit(temp_cel)
print("Body temp: {:.1f} F recorded".format(temp_fah))
lcd.clear()
lcd.putstr('Temp :{:.1f} F recorded'.format(temp_fah))
if temp_fah > 98.6:
lcd.move_to(0,1)
lcd.putstr('Fever')
print("Fever")
else:
lcd.move_to(0,1)
lcd.putstr('No fever')
print("No fever")
sleep(2)