import time
import random # Simulating sensor data
# Function to simulate reading from DHT sensor
def read_sensor():
temperature = random.uniform(20.0, 30.0) # Simulated temperature
humidity = random.uniform(30.0, 70.0) # Simulated humidity
return temperature, humidity
def main():
while True:
temperature, humidity = read_sensor()
print(f"Temperature: {temperature:.2f} °C, Humidity: {humidity:.2f} %")
time.sleep(2) # Read every 2 seconds
if __name__ == "__main__":
main()