Home Code ESP8266 and DHT Pro shield Micropython example

ESP8266 and DHT Pro shield Micropython example

by shedboy71

In this example we look at a DHT PRO example in Micropython for an ESP8266.

The DHT pro is actually an AM2302 sensor from the same company that makes the DHT11 sensor

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 we used in the example

 

Image Summary
The Wemos mini – ESP8266 based board, it comes with various headers. This is the beauty of it you can create stackable projects with the board and pin compatible shields
This is not an official Wemos shield – its called the DHT Shield but its based on the AM2302
This is simply a base, you plug the Wemos Mini into one side and you can plug a shield or shields into the other side

 

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.

Name Link
Wemos Mini D1 mini – Mini NodeMcu 4M bytes Lua WIFI Internet of Things development board based ESP8266 by WeMos
Wemos Base Tripler Base V1.0.0 Shield for WeMos D1 Mini
DHT PRO shield DHT Pro Shield for WeMos D1 mini DHT22 Single-bus digital temperature and humidity sensor module sensor

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

You may also like

Leave a Comment