from machine import Pin,I2C,PWM,ADC
import network
from socket import *
import ssd1306
from dht import DHT22
import utime as microtime
import time
import machine
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
adc_pin = Pin(36)
adc= ADC(adc_pin)
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
PWM_PIN = 18
pwm_pin = Pin(18)
pwm= PWM(pwm_pin,freq=1, duty=513)
adc_pin = Pin(36)
adc= ADC(adc_pin)
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c,addr=0x3c)
oled.poweron()
oled.fill(0)
oled.text("Todo OK", 20 ,10, 1)
oled.show()
dht_pin= machine.Pin(16)
dht22 = DHT22(dht_pin)
microtime.sleep(2)
while True:
try:
dht22.measure()
temp = dht22.temperature()
hum = dht22.humidity()
oled.fill(0)
oled.text("temp: {:.2f} C".format(temp), 0, 0)
oled.text("hum: {:.2f} %".format(hum), 0, 20)
oled.show()
microtime.sleep(1)