Home » ESP32 and DHT11 example in Micropython

ESP32 and DHT11 example in Micropython

by shedboy71

In this example we look at a DHT11 example in Micropython for an ESP32. 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

 

Image Summary
MH-ET LIVE ESP32 MINI KIT WiFi+Bluetooth Internet of Things development board based ESP8266 Fully functional D1 MINI Upgraded
This is the original DHT11 shield – still available from many sellers. The later version uses a DHT12 which is an I2C device
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 MH-ET LIVE ESP32 MINI KIT to the dual base and then put the DHT shield along side this.

Name Link
Wemos Base Tripler Base V1.0.0 Shield for WeMos D1 Mini
Wemos DHT11 1PCS DHT Shield for WeMos D1 mini DHT11 Single-bus digital temperature and humidity sensor module sensor
MH-ET LIVE ESP32 MINI KIT MH-ET LIVE ESP32 MINI KIT WiFi+Bluetooth Internet of Things development board based ESP8266 Fully functional D1 MINI Upgraded

Code

[codesyntax lang=”python”]

from machine import Pin
import dht
import time

while True:
	sensor = dht.DHT11(Pin(16))
	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(‘dhtESP32.py').read(),globals())
Temperature = 25.00
Humidity = 18.00
Temperature = 27.00
Humidity = 17.00
Temperature = 27.00
Humidity = 17.00
Temperature = 27.00
Humidity = 17.00
Temperature = 27.00
Humidity = 17.00
Temperature = 27.00
Humidity = 17.00

 

Links

https://akizukidenshi.com/download/ds/aosong/DHT11.pdf

You may also like

Leave a Comment

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.