Skip to content

This project demonstrates how to use an ESP32 microcontroller with MicroPython to read temperature and humidity data from a DHT11 or DHT22 sensor.

Notifications You must be signed in to change notification settings

weijuinlee/esp32micropythondht11

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP32,Micropython with DHT11 Temperature Sensor

Here’s a list of parts you need to build the circuit:

  1. DHT11 or DHT22 temperature and humidity sensor
  2. 10k Ohm resistor
  3. Breadboard
  4. Jumper wires

Code:

from machine import Pin
from time import sleep
import dht 
sensor = dht.DHT22(Pin(14))
#sensor = dht.DHT11(Pin(14))
while True:
  try:
    sleep(2)
    sensor.measure()
    temp = sensor.temperature()-590
    hum = sensor.humidity() - 1600
    print('Temperature: %f C' %temp)
    print('Humidity: %3.1f %%' %hum)
  except OSError as e:
    print('Failed to read sensor.')

Circuit: Images

Console:

About

This project demonstrates how to use an ESP32 microcontroller with MicroPython to read temperature and humidity data from a DHT11 or DHT22 sensor.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages