# from machine import Pin, ADC, I2C
# import dht
# import ssd1306
# import time
# import network
# from umqtt.simple import MQTTClient
# # ======================
# # CONFIGURAÇÃO DE PINOS
# # ======================
# DHT_PIN = 15 # DHT22 (NÃO usar 22!)
# LDR_PIN = 34 # LDR
# GAS_PIN = 35 # MQ-2
# BTN_PIN = 13 # Botão
# I2C_SCL = 22 # OLED
# I2C_SDA = 21 # OLED
# # ======================
# # SENSORES
# # ======================
# dht_sensor = dht.DHT22(Pin(DHT_PIN))
# ldr = ADC(Pin(LDR_PIN))
# ldr.atten(ADC.ATTN_11DB)
# gas = ADC(Pin(GAS_PIN))
# gas.atten(ADC.ATTN_11DB)
# # ======================
# # OLED
# # ======================
# i2c = I2C(0, scl=Pin(I2C_SCL), sda=Pin(I2C_SDA))
# oled = ssd1306.SSD1306_I2C(128, 64, i2c)
# # ======================
# # BOTÃO E TELAS
# # ======================
# tela = 0
# botao = Pin(BTN_PIN, Pin.IN, Pin.PULL_UP)
# estado_anterior = 1
# # ======================
# # CONFORTO TÉRMICO
# # ======================
# def indice_conforto(temp, umid):
# return temp + 0.3 * umid
# def texto_conforto(ic):
# if ic < 28:
# return "Agradavel"
# elif ic < 34:
# return "Quente"
# else:
# return "Muito quente"
# # ======================
# # WIFI
# # ======================
# wifi = network.WLAN(network.STA_IF)
# wifi.active(True)
# wifi.connect("Wokwi-GUEST", "")
# while not wifi.isconnected():
# time.sleep(1)
# # ======================
# # MQTT - HIVE MQ
# # ======================
# MQTT_CLIENT_ID = "esp32-leticia"
# MQTT_BROKER = "29919427f0ca4636ac8c892ae7ac29ab.s1.eu.hivemq.cloud"
# MQTT_USER = "esp32"
# MQTT_PASSWORD = "Esp32@8031"
# mqtt = MQTTClient(
# MQTT_CLIENT_ID,
# MQTT_BROKER,
# port=8883,
# user=MQTT_USER,
# password=MQTT_PASSWORD,
# ssl=True
# )
# mqtt.connect()
# # ======================
# # LOOP PRINCIPAL
# # ======================
# while True:
# # Leitura dos sensores
# dht_sensor.measure()
# temp = dht_sensor.temperature()
# hum = dht_sensor.humidity()
# luz = int(ldr.read() / 4095 * 100)
# gas_val = gas.read()
# ic = indice_conforto(temp, hum)
# conforto_txt = texto_conforto(ic)
# # ===== ENVIO MQTT =====
# # mqtt.publish("estacao/temperatura", str(temp))
# # mqtt.publish("estacao/umidade", str(hum))
# # mqtt.publish("estacao/luz", str(luz))
# # mqtt.publish("estacao/gas", str(gas_val))
# # mqtt.publish("estacao/conforto", conforto_txt)
# # ===== OLED =====
# oled.fill(0)
# if tela == 0:
# oled.text("TELA 1 - CLIMA", 0, 0)
# oled.text(f"Temp: {temp:.1f}C", 0, 15)
# oled.text(f"Umid: {hum:.1f}%", 0, 30)
# if temp > 35:
# oled.text("ALERTA: CALOR", 0, 50)
# elif tela == 1:
# oled.text("TELA 2 - LUZ", 0, 0)
# oled.text(f"Luz: {luz}%", 0, 20)
# elif tela == 2:
# oled.text("TELA 3 - AR", 0, 0)
# oled.text(f"Gas: {gas_val}", 0, 20)
# if gas_val > 2000:
# oled.text("AR RUIM", 0, 40)
# elif tela == 3:
# oled.text("TELA 4 - CONFORTO", 0, 0)
# oled.text(f"Indice: {ic:.1f}", 0, 20)
# oled.text(conforto_txt, 0, 40)
# if ic > 34:
# oled.text("ALERTA CALOR", 0, 55)
# oled.show()
# # ===== BOTÃO =====
# estado_atual = botao.value()
# if estado_atual == 0 and estado_anterior == 1:
# tela += 1
# if tela > 3:
# tela = 0
# time.sleep(0.3) # debounce
# estado_anterior = estado_atual
# time.sleep(2)
import time
print("INICIOU")
i = 0
while True:
print("RODANDO", i)
i += 1
time.sleep(1)