import time
import machine
from dht import DHT22
#We performed the simulation with DHT22 because LM35 sensor is not available on Wokwi.
dht = DHT22(22)
rgb_r = machine.Pin(21, machine.Pin.OUT)
rgb_g = machine.Pin(20, machine.Pin.OUT)
rgb_b = machine.Pin(19, machine.Pin.OUT)
while True:
rgb_r.high()
rgb_g.high()
rgb_b.high()
dht.measure()
tempC = dht.temperature()
#Common Anode RGB is used
if(tempC > 25):
rgb_r.low()
rgb_g.high()
rgb_b.high()
if(tempC > 0 and tempC <= 25):
rgb_r.high()
rgb_g.low()
rgb_b.high()
if(tempC <= 0):
rgb_r.high()
rgb_g.high()
rgb_b.low()
print("Temperature: ",tempC, "°C", sep=" ")
time.sleep(2)