Skip to content
Buy 10+ on select items — save 10% auto-applied
Free US shipping on orders $35+
Order by 3pm ET — ships same-day from the US
Skip to main content

Arduino Nano DHT22: Log Temp and Humidity to Serial | ShillehTek

May 14, 2026 17 views

Arduino Nano DHT22: Log Temp and Humidity to Serial | ShillehTek
Project

Build an Arduino Nano DHT22 temperature and humidity logger that prints stable readings to Serial every 2 seconds using the Adafruit library from ShillehTek.

10 min Beginner3 parts

Project Overview

Arduino Nano + DHT22 climate readings: In this tutorial, you will wire a DHT22 temperature and humidity sensor to an Arduino Nano and print readings to the Serial Monitor every 2 seconds.

The DHT22 is a one-wire digital sensor that reports temperature (-40 C to +80 C) and relative humidity (0 to 100%) over a single GPIO pin. It is commonly used for grow tents, weather stations, fridge loggers, and HVAC monitoring.

  • Time: ~10 minutes
  • Skill level: Beginner
  • What you will build: An Arduino logging temperature + humidity to the Serial Monitor every 2 seconds.
DHT22 temperature and humidity sensor module on a white background
The DHT22, one wire in and climate data out.

Parts List

From ShillehTek

External

  • USB cable - to power and program the Arduino Nano
  • Arduino IDE - to install the library and upload the sketch

Note: A 10 kOhm pull-up between DATA and VCC is required if your module is just a bare DHT22. ShillehTek’s DHT22 with cables already includes the pull-up on the breakout.

Step-by-Step Guide

Step 1 - Identify the Pins

Goal: Know what each lead does.

What to do: Confirm the DHT22 pins before wiring: VCC, DATA, NC, and GND. Leave the NC pin unconnected.

DHT22 pinout diagram labeling VCC, DATA, NC, and GND
Three usable pins: VCC, DATA, GND. The fourth (NC) stays unconnected.

Expected result: You can identify VCC, DATA, and GND confidently before connecting to the Arduino.

Step 2 - Wire It Up

Goal: Connect the DHT22 to the Arduino Nano correctly.

What to do: Wire the sensor to the Arduino as shown. Use D2 for the data pin to match the sketch.

Arduino wired to a DHT22 sensor with VCC to 5V, DATA to D2, and GND to GND
VCC to 5 V, DATA to D2, GND to GND.
  • VCC to 5 V (3.3 V also works on ESP32 / Pi Pico)
  • DATA to D2
  • GND to GND

Expected result: The DHT22 is powered and its DATA line is connected to Arduino digital pin 2.

Step 3 - Install the Library

Goal: Add the Arduino library needed to talk to the DHT22.

What to do: In the Arduino IDE, open Tools → Manage Libraries and install DHT sensor library by Adafruit. Accept the prompt to install dependencies (Adafruit Unified Sensor).

Expected result: The DHT sensor library and its dependencies are installed successfully.

Step 4 - Upload the Sketch

Goal: Program the Arduino Nano to print humidity and temperature.

What to do: Paste the sketch below, select your board and port, then upload.

Arduino IDE showing a DHT22 sketch that reads humidity and temperature
Two lines per loop, that is the whole interface.

Code:

#include <DHT.h>

#define DHTPIN 2
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  dht.begin();
}

void loop() {
  delay(2000);
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  if (isnan(h) || isnan(t)) {
    Serial.println(F("DHT read failed"));
    return;
  }
  Serial.print(F("Humidity: "));
  Serial.print(h, 1);
  Serial.print(F("%  Temp: "));
  Serial.print(t, 1);
  Serial.println(F(" C"));
}

Expected result: The upload completes, and the Arduino begins sampling the DHT22 about once every 2 seconds.

Step 5 - Watch the Output

Goal: Verify the sensor readings in the Serial Monitor.

What to do: Open the Serial Monitor at 9600 baud and watch the printed humidity and temperature values. The DHT22 needs about 2 seconds between samples.

Arduino Serial Monitor showing DHT22 humidity and temperature readings updating every 2 seconds
Stable readings within a couple of seconds; the DHT22 needs about 2 seconds between samples.
Plot of DHT22 humidity and temperature trends over time from Arduino readings
Plot it over time and you have a small climate logger.

Expected result: You see lines like “Humidity: XX.X% Temp: YY.Y C” updating every 2 seconds.

Step 6 - Where to Take It Next

Goal: Extend the project after you confirm basic readings.

What to do: Pick one of these next steps for your build.

  • Push readings to a Google Sheet via an ESP32 + IFTTT
  • Drive an LCD1602 to display T/RH live
  • Trigger a relay-controlled fan or heater above/below thresholds
  • Stream to MQTT for Home Assistant integration

Expected result: You have a clear direction for turning simple serial output into a real monitoring or automation project.

Conclusion

You just wired a DHT22 temperature and humidity sensor to an Arduino Nano and logged readings to the Serial Monitor. With one data pin and the Adafruit library, you can quickly turn it into a basic climate monitor.

Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project or building something for your product, check out our IoT consulting services.

Credits: The DHT22 wiring photos and Serial Monitor screenshots are credited to Instructables, which served as a reference for this version.