import time
import dht
from machine import Pin
from machine import Pin, ADC
import time
mq2 = ADC(Pin(32))
buzzer = Pin(26, Pin.OUT)
threshold = 3628
dht_sensor = dht.DHT22(Pin(14))
led = Pin(33, Pin.OUT)
while True:
dht_sensor.measure()
temp = dht_sensor.temperature()
print("Temperature:", temp, "°C")
if temp >= 30:
led.on()
print("LED ON")
else:
led.off()
print("LED OFF")
gas_value = mq2.read()
print("Gas Sensor Value:", gas_value)
if gas_value > threshold:
print("Gas detected Activating buzzer...")
buzzer.on()
time.sleep(0.1)
buzzer.off()
else:
buzzer.off()
time.sleep(2)