Arduino Nano Humidity Sensor

The Humidity Sensor project demonstrates how to use an Arduino Nano with a DHT11 sensor to measure humidity and temperature. This project is valuable for applications requiring environmental monitoring, such as climate control systems, weather stations, and smart‑home projects.

Components Needed

  • Arduino Nano
  • DHT11 Humidity and Temperature Sensor
  • Jumper Wires

Circuit Setup

1. Connect DHT11 Sensor to Arduino Nano:

Connect the data pin of the DHT11 sensor to digital pin 2 on the Arduino Nano.

Ensure proper grounding by connecting the sensor's ground pin to the Arduino Nano's ground (GND).

Connect the sensor's VCC pin to the Arduino Nano's 5V pin for power.

How the Humidity Sensor Works

The DHT11 sensor outputs a digital signal that the Arduino reads using the DHT library. It returns both relative humidity (in %) and temperature (in °C), which can be printed on the Serial Monitor or used to control other devices like fans or humidifiers.

Program: Arduino Nano Humidity Sensor (DHT11 Example)
#include "DHT.h"

#define DHTPIN 2
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  dht.begin();
  Serial.println("=== HUMIDITY SENSOR READY ===");
  Serial.println("Humidity  Temperature");
}

void loop() {
  // Read humidity and temperature
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();

  // Check if readings are valid
  if (isnan(humidity) || isnan(temperature)) {
    Serial.println("Sensor error – retrying...");
  } else {
    Serial.print(humidity);
    Serial.print("%  ");
    Serial.print(temperature);
    Serial.println("°C");
  }

  delay(2000);  // DHT11 should not be read faster than ~2s
}

Instructions

1. Circuit Setup:

Wire the DHT11 sensor to the Arduino Nano as described in the circuit setup section.

2. Code Upload:

Connect the Arduino Nano to your computer via USB.

Open the Arduino IDE and paste the provided humidity sensor code.

Select the correct board (Arduino Nano) and port from the Tools menu.

Install the DHT library: Sketch → Include Library → Manage Libraries → search for "DHT sensor library" by Adafruit and install it.

Upload the code to the Arduino Nano.

3. Testing:

Once the code is uploaded, open the Serial Monitor (9600 baud).

Observe the humidity and temperature values displayed every 2 seconds.

Applications

Climate Control Systems: Use humidity sensors in HVAC systems for maintaining optimal indoor air quality and comfort.

Weather Stations: Incorporate humidity sensors into weather monitoring systems for collecting environmental data.

Plant Monitoring: Monitor humidity levels in greenhouses or agricultural settings to optimize plant growth conditions.

Troubleshooting and Sensitivity

  • Readings show 'Sensor error' every time? Check DHT11 wiring and power; ensure Vcc, GND, and data pin 2 are connected correctly.
  • Values are unstable or repeating? Keep away from direct heat sources, steam, or very dusty environments.
  • No readings at all? Make sure the DHT library is installed and the DHTPIN matches the data pin you used.

Best Practices and Notes

  • Do not power the DHT11 from the Arduino before the code starts; poor‑quality boards can cause brief power spikes that crash the sensor.
  • Expose the sensor to open air; do not seal it inside an airtight enclosure without ventilation for good humidity sampling.
  • Use a 4.7 kΩ pull‑up resistor between VCC and the data line if your module does not have it built‑in.
  • The DHT11 has limited accuracy; for higher precision, consider upgrading to a DHT22 or similar sensor.

Extensions and Ideas

You can extend this project by adding an LCD to display humidity and temperature, using a relay to turn a fan or humidifier on when conditions are outside a set range, or by sending data to a computer or cloud service for logging and graphing.