import dht
import json
from machine import Pin, I2C
import ssd1306
from mp_i2c_lcd1602 import LCD1602
from utime import sleep
print("Hello, ESP32!")
d = dht.DHT22(Pin(14))
led = Pin(18, Pin.OUT)
i2c = I2C(1, sda=Pin(21), scl=Pin(22))
oled_width = 128
oled_height = 64
d.measure()
a_temp = d.temperature()
a_hum = d.humidity()
mon_dict = {"temp": a_temp, "hum": a_hum}
json_str = json.dumps(mon_dict)
print(json_str)
#oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
LCD = LCD1602(i2c)
led.on()
while True:
LCD.puts(f'''Temperature : {a_temp}''', 0, 0)
LCD.puts(f'''Humidite : {a_hum}''',0, 1)
sleep(2)
LCD.puts(' -HEURE- ', 0, 0)
#LCD.puts(' ' + time + ' ',0 , 1)
LCD.puts(' ' + '23:42:12' + ' ',0 , 1)
sleep(2)
#oled.text(f'''Temperature : {a_temp}\n Humidité : {a_hum}''',10,10)
#oled.show()