In this example we look at a DHT PRO example in Micropython for an ESP8266. Once again we use uPyCraft and again we use Wemos shields.
The DHT pro is actually an AM2302 sensor from the same company as the DHT11
A reminder of the AM2302 from the datasheet
AM2302 capacitive humidity sensing digital temperature and humidity module is one that contains the compound has been calibrated digital signal output of the temperature and humidity sensors. 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 capacitive sensor wet components and a high-precision temperature measurement devices, and connected with a high-performance 8-bit microcontroller.
The product has excellent quality, fast response, strong anti-jamming capability, and high cost. Each sensor is extremely accurate humidity calibration chamber calibration. The form of procedures, the calibration coefficients stored in the microcontroller, the sensor within the processing of the heartbeat to call these calibration coefficients. Standard single-bus interface, system integration quick and easy. Small size, low power consumption, signal transmission distance up to 20 meters, making it the best choice of all kinds of applications and even the most demanding applications
Requirements
Lets take a look a the shields and boards that are required for this example
Parts List
I connect the Wemos Mini to the dual base and then put the DHT shield along side this, you can connect the Wemos DHT shield directly to the Wemos Mini if you want.
Code
[codesyntax lang=”python”]
from machine import Pin import dht import time while True: sensor = dht.DHT22(Pin(2)) sensor.measure() print('Temperature = %.2f' % sensor.temperature()) print('Humidity = %.2f' % sensor.humidity()) time.sleep(3)
[/codesyntax]
Output
You should see something like the following in uPyCraft
Ready to download this file,please wait!
..
download ok
exec(open(‘dht22.py’).read(),globals())
Temperature = 26.10
Humidity = 32.60
Temperature = 26.20
Humidity = 32.50
Temperature = 26.10
Humidity = 32.50
Temperature = 26.20
Humidity = 32.60
Links
https://akizukidenshi.com/download/ds/aosong/AM2302.pdf