DHT11 Sensor in Micropython

--

DHT11 Module

Just a short bit of code to test a DHT11 temperature and humidity sensor module.

This version has just three pins VCC, GND and data, so easy to connect and use with the DHT library.

"""
Temperature and Humidity with DHT11
https://docs.micropython.org/en/latest/esp8266/tutorial/dht.html
"""
import dht
import machine
import time

d = dht.DHT11(machine.Pin(16))

while True:
d.measure()
print("Temperature :", d.temperature(), "C")
print("Humidity :", d.humidity(), "%")
time.sleep(5)

dht11.py.

Running the code

--

--