portfolio

Wiring a DHT22 (3 Pin)

Course Content
Session 1: Introduction to ESP32
Objective: Get familiar with the ESP32 microcontroller and set up the development environment.
0/5
Session 2: Interfacing with Sensors and Displays
Learn how to connect a DHT22 sensor and an OLED display to the ESP32.
0/4
Session 4: Programming the OLED Display
Objective: Write code to display information on the OLED display.
0/4
Session 5: Integrating Sensor Data with OLED Display
Objective: Combine sensor readings with OLED display functionality.
0/1
Session 6: Setup WIFI Capability
0/1
Session 7: Adding a Webserver
0/1
Session 8: Wrap-up
0/1
ESP32 Basics
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):

  1. Pin 1: VCC – Power supply (3.3V or 5V)
  2. Pin 2: DATA – Data signal (to ESP32 GPIO pin)
  3. 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:

  1. Pin 1 (VCC) → Power:

    • Connect Pin 1 of the DHT22 to the 3.3V pin of the ESP32 (ESP32 operates at 3.3V logic).
  2. 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).
  3. 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.