ESP32 C3 Super Mini - DHT22

Learn how to use the ESP32 C3 Super Mini with a DHT22 sensor to measure temperature and humidity. This beginner-friendly tutorial covers both DHT22 sensor and module versions with complete wiring diagrams and code examples.

In this tutorial, you'll learn:

ESP32 C3 Super Mini - DHT22

Hardware Preparation

1×ESP32 C3 Super Mini
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×DHT22 Temperature Humidity Sensor Module
1×10 kΩ Resistor
1×Breadboard
1×Jumper Wires
1×Optionally, DC Power Jack

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of DHT22 Temperature and Humidity Sensor

The DHT22 is a digital temperature and humidity sensor that provides reliable environmental readings for your ESP32 C3 Super Mini projects.

Key specifications:

  • Operating voltage: 3V to 5V (compatible with ESP32 C3 Super Mini)
  • Humidity measurement range: 0% to 100%
  • Humidity accuracy: ±2% to 5%
  • Temperature measurement range: -40°C to 80°C
  • Temperature accuracy: ±0.5°C
  • Reading rate: 0.5Hz (one reading every 2 seconds)

Why DHT22 is great for beginners:

  • Simple digital interface - easy to connect and program
  • Pre-built Arduino libraries available for quick setup
  • Accurate readings suitable for most home projects
  • Available as both raw sensor and convenient module format
DHT22
Operating Voltage3 to 5V
The humidity range 0% to 100%
The humidity accuracy ± 2% to 5%
The temperature range -40°C to 80°C
The temperature accuracy ± 0.5°C
The reading rate 0.5Hz (one time per 2 seconds)

DHT22 Pinout

The DHT22 comes in two forms: a raw sensor with 4 pins and a convenient module with 3 pins.

DHT22 sensor module Pinout

DHT22 raw sensor pins (4 pins):

  • GND pin: Connect to GND (0V)
  • VCC pin: Connect to VCC (3.3V or 5V)
  • DATA pin: Communication pin between sensor and ESP32 C3 Super Mini
  • NC pin: Not connected (leave unconnected)

DHT22 module pins (3 pins):

  • VCC (or +): Connect to 3.3V or 5V
  • GND (or -): Connect to GND
  • DATA (or OUT): Communication pin to ESP32 C3 Super Mini

Note: The DHT22 module includes a built-in pull-up resistor, making wiring simpler for beginners.

Wiring Diagram between DHT22 and ESP32 C3 Super Mini

Here's how to connect the DHT22 sensor to your ESP32 C3 Super Mini board.

  • Note: When using the raw DHT22 sensor, a 10kΩ pull-up resistor is required between DATA and VCC pins for reliable communication.

ESP32 C3 Super Mini - DHT22 Sensor Wiring

The wiring diagram between ESP32 C3 Super Mini DHT22 Temperature and humidity Sensor

This image is created using Fritzing. Click to enlarge image

DHT22 Sensor Pin ESP32 C3 Super Mini Pin
VCC 3.3V or 5V
GND GND
DATA D4 (or any digital pin)
10kΩ Resistor Between DATA and VCC

ESP32 C3 Super Mini - DHT22 Module Wiring

The DHT22 module simplifies wiring by including the pull-up resistor internally - no external resistor needed!

The wiring diagram between ESP32 C3 Super Mini DHT22 Temperature and humidity Module

This image is created using Fritzing. Click to enlarge image

DHT22 Module Pin ESP32 C3 Super Mini Pin
VCC (or +) 3.3V or 5V
GND (or -) GND
DATA (or OUT) D4 (or any digital pin)

ESP32 C3 Super Mini Code - DHT22

Here's the code to read temperature and humidity from the DHT22 sensor using your ESP32 C3 Super Mini.

This code does the following:

  • Initializes the DHT22 sensor on the specified pin
  • Reads humidity and temperature values every 2 seconds
  • Converts temperature to both Celsius and Fahrenheit
  • Displays formatted readings on the Serial Monitor
  • Includes error checking for failed sensor readings
/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-dht22 */ #include <DHT.h> #define DHT22_PIN D4 // The ESP32 C3 SuperMini pin D4 connected to DHT22 sensor DHT dht22(DHT22_PIN, DHT22); void setup() { Serial.begin(9600); dht22.begin(); // initialize the DHT22 sensor } void loop() { // read humidity float humi = dht22.readHumidity(); // read temperature in Celsius float temperature_C = dht22.readTemperature(); // read temperature in Fahrenheit float temperature_F = dht22.readTemperature(true); // check whether the reading is successful or not if ( isnan(temperature_C) || isnan(temperature_F) || isnan(humi)) { Serial.println("Failed to read from DHT22 sensor!"); } else { Serial.print("Humidity: "); Serial.print(humi); Serial.print("%"); Serial.print(" | "); Serial.print("Temperature: "); Serial.print(temperature_C); Serial.print("°C ~ "); Serial.print(temperature_F); Serial.println("°F"); } // wait a 2 seconds between readings delay(2000); }

Detailed Instructions

  • New to ESP32 C3 Super Mini? Start with our ESP32 C3 Super Mini Getting Started guide first.
  • Prepare the wiring: Connect the DHT22 sensor or module to your ESP32 C3 Super Mini according to the wiring diagram above.
  • Connect to computer: Plug the ESP32 C3 Super Mini into your computer using a USB Type-C cable.
  • Open Arduino IDE: Launch the Arduino IDE on your computer.
  • Select your board: Choose ESP32 C3 Super Mini from the board selector and select the correct COM port.
  • Install DHT library: Click the Library Manager icon on the left sidebar of Arduino IDE.
  • Search for library: Type "DHT" in the search box and find the DHT sensor library by Adafruit.
  • Install the library: Click the Install button next to the Adafruit DHT library.
ESP32 C3 Super Mini DHT sensor library
  • Install dependencies: When prompted, click Install All to install all required dependencies (including Adafruit Unified Sensor library).
ESP32 C3 Super Mini Adafruit Unified sensor library
  • Upload the code: Copy the code above, paste it into Arduino IDE, and click the Upload button.
  • Test the sensor: Try changing the temperature around the DHT22 (place it near a hot cup or use a fan to cool it).
  • View readings: Open the Serial Monitor (set to 9600 baud) to see live temperature and humidity readings.
  • Pro Tip: Wait at least 2 seconds between readings - the DHT22 sensor updates at a maximum rate of 0.5Hz.

Serial Monitor Output

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32C3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32C3 Dev Module' on 'COM15')
New Line
9600 baud
Humidity: 48.20% | Temperature: 23.10°C ~ 73.58°F Humidity: 48.50% | Temperature: 23.20°C ~ 73.76°F Humidity: 48.30% | Temperature: 23.30°C ~ 73.94°F Humidity: 48.10% | Temperature: 23.50°C ~ 74.30°F Humidity: 47.90% | Temperature: 23.70°C ~ 74.66°F Humidity: 47.80% | Temperature: 24.00°C ~ 75.20°F Humidity: 47.60% | Temperature: 24.30°C ~ 75.74°F Humidity: 47.40% | Temperature: 24.80°C ~ 76.64°F
Ln 11, Col 1
ESP32C3 Dev Module on COM15
2

Applications and Project Ideas

Use your ESP32 C3 Super Mini with DHT22 sensor to build these practical projects:

  • Home weather station: Monitor indoor temperature and humidity with data logging
  • Smart greenhouse controller: Automatically adjust ventilation based on humidity levels
  • Comfort monitor: Alert when room conditions exceed comfortable ranges
  • Server room monitoring: Track temperature to prevent overheating in equipment rooms
  • DIY thermostat: Create a smart temperature control system for your home
  • Pet habitat monitor: Ensure optimal conditions for reptiles or other sensitive pets
  • Indoor air quality tracker: Combine with other sensors for comprehensive environmental monitoring

Video Tutorial

Watch the video below for a visual walkthrough of this project.

Challenge Yourself

Take your ESP32 C3 Super Mini and DHT22 skills to the next level with these challenges:

  • Easy: Add an LED that turns on when temperature exceeds 25°C
  • Easy: Display a "Too Humid" warning when humidity goes above 70%
  • Medium: Log temperature and humidity data to an SD card with timestamps
  • Medium: Send readings to a smartphone using Bluetooth or WiFi
  • Advanced: Create a web server that displays real-time temperature and humidity graphs
  • Advanced: Build a dual-zone monitoring system using two DHT22 sensors and compare readings

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!