About Lesson
To wire a 3-pin DHT22 sensor to an ESP32, the process is similar to wiring it to other microcontrollers like Arduino. Here’s a step-by-step guide to help you:
Pin Layout of the DHT22 (3-pin):
- Pin 1: VCC – Power supply (3.3V or 5V)
- Pin 2: DATA – Data signal (to ESP32 GPIO pin)
- Pin 3: GND – Ground (connected to the common ground)
Components Needed:
- DHT22 (3-pin) sensor
- ESP32 microcontroller
- Jumper wires
- 4.7kΩ to 10kΩ pull-up resistor (optional, but usually built into the 3-pin DHT22)
Wiring the DHT22 to ESP32:
-
Pin 1 (VCC) → Power:
- Connect Pin 1 of the DHT22 to the 3.3V pin of the ESP32 (ESP32 operates at 3.3V logic).
-
Pin 2 (DATA) → ESP32 GPIO Pin:
- Connect Pin 2 (DATA) of the DHT22 to any available GPIO pin on the ESP32 (e.g., GPIO 4).
- You may optionally add a 4.7kΩ to 10kΩ pull-up resistor between Pin 1 (VCC) and Pin 2 (DATA) for stable communication (though the 3-pin version often has this built-in).
-
Pin 3 (GND) → Ground:
- Connect Pin 3 of the DHT22 to one of the GND pins of the ESP32.
Example ESP32 Wiring:
- DHT22 Pin 1 (VCC) → ESP32 3.3V
- DHT22 Pin 2 (DATA) → ESP32 GPIO 4
- DHT22 Pin 3 (GND) → ESP32 GND
Notes:
- Make sure the ESP32 is powered properly (via USB or another reliable source).
- Ensure that the DHT22 is receiving a stable 3.3V from the ESP32.
- You can change the GPIO pin in the code to match your wiring.
By following these steps, the ESP32 will read the temperature and humidity data from the DHT22 sensor and display it in the Serial Monitor.