https://github.com/asathiskumar98-byte/esp8266-dht22-temperature-humidity-sensor-micropython
This project shows how to interface a **DHT22 (AM2302)** sensor with an **ESP8266** using **MicroPython**. It reads **temperature** and **humidity** values every 2 seconds and displays them on the **Thonny IDE console**.
https://github.com/asathiskumar98-byte/esp8266-dht22-temperature-humidity-sensor-micropython
dht22-sensor embedded-systems esp8266 esp8266-projects humidity-monitoring micropython micropython-esp8266 temperature-monitoring thonny-ide
Last synced: about 2 months ago
JSON representation
This project shows how to interface a **DHT22 (AM2302)** sensor with an **ESP8266** using **MicroPython**. It reads **temperature** and **humidity** values every 2 seconds and displays them on the **Thonny IDE console**.
- Host: GitHub
- URL: https://github.com/asathiskumar98-byte/esp8266-dht22-temperature-humidity-sensor-micropython
- Owner: asathiskumar98-byte
- Created: 2025-10-29T03:37:43.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-10-29T03:40:32.000Z (7 months ago)
- Last Synced: 2025-10-29T05:39:18.348Z (7 months ago)
- Topics: dht22-sensor, embedded-systems, esp8266, esp8266-projects, humidity-monitoring, micropython, micropython-esp8266, temperature-monitoring, thonny-ide
- Language: Python
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🌡️ ESP8266 DHT22 Temperature & Humidity Sensor — MicroPython
## 🧠 Overview
This project shows how to interface a **DHT22 (AM2302)** sensor with an **ESP8266** using **MicroPython**.
It reads **temperature** and **humidity** values every 2 seconds and displays them on the **Thonny IDE console**.
---
## ⚙️ Hardware Setup
| Component | ESP8266 Pin | Description |
|------------|-------------|--------------|
| DHT22 (Data) | GPIO4 (D2) | Sensor data output |
| VCC | 3.3V | Power supply |
| GND | GND | Common ground |
🪛 **Connections:**
- DHT22 **VCC → 3.3V**
- DHT22 **GND → GND**
- DHT22 **Data → GPIO4 (D2)**
- Add a **10kΩ pull-up resistor** between **VCC** and **Data** for stable readings.
---
## 🧩 Code
```python
# GPIO04 = D2 = Data of DHT22
import machine
import dht
import utime
dh = dht.DHT22(machine.Pin(4))
while True:
dh.measure()
utime.sleep_ms(2000)
tem = dh.temperature()
hum = dh.humidity()
print('Humidity:', hum, 'TEMPERATURE:', tem)