In this example we look at a DHT11 example in Micropython for an ESP8266. Once again we use uPyCraft and again we use Wemos shields. In this example we will use the original DHT version 1.0.0 shield which was based on the DHT11 . Later shields use the DHT12.
A reminder of the DHT11
The DHT11 digital temperature and humidity sensor is a composite Sensor contains a calibrated digital signal output of the temperature and humidity. Application of a dedicated digital modules collection technology and the temperature and humidity sensing technology, to ensure that the product has high reliability and excellent long-term stability. The sensor includes a resistive sense of wet components and an NTC temperature measurement devices, and connected with a high-performance 8-bit microcontroller.
Requirements
Lets take a look a the shields and boards that are required for this example
Parts List
Here are the parts I used
Name | Links | |
Wemos Mini | ||
DHT11 | ||
Connecting cables |
Code
from machine import Pin import dht import time while True: sensor = dht.DHT11(Pin(2)) sensor.measure() print('Temperature = %.2f' % sensor.temperature()) print('Humidity = %.2f' % sensor.humidity()) time.sleep(3)
Output
You should see something like the following in uPyCraft
Ready to download this file,please wait!
..
download ok
exec(open(‘dht.py’).read(),globals())
Temperature = 29.00
Humidity = 16.00
Temperature = 28.00
Humidity = 17.00
Temperature = 28.00
Humidity = 17.00
Temperature = 28.00
Humidity = 17.00
Links
https://akizukidenshi.com/download/ds/aosong/DHT11.pdf