DHT11 Temperature + Humidity Logger

A single-wire sensor and an Arduino sketch print room temperature and humidity to the serial monitor every two seconds.

Difficulty: Breadboard. Estimated build time: about 30 minutes. Estimated parts cost: about US$3.50. 4-line bill of materials. Compare supplier offers when available. A combined temperature and humidity logger built around the DHT11, a tiny 4-pin sensor with an integrated capacitive humidity element and an NTC thermistor.

Wire the 1-wire sensor

DHT11 has 4 pins — left to right with the grille facing you: VCC, DATA, NC, GND. (Some 3-pin breakouts omit the NC pin.) Connect VCC to 5 V on the Uno, GND to GND. The DATA pin goes to any Arduino digital pin (we'll use D2). Add a 10 kΩ pull-up resistor between DATA and VCC — it holds the line idle-high between transactions and is required for reliable communication.

Install the Adafruit DHT library

In the Arduino IDE Library Manager, install 'DHT sensor library' by Adafruit. It depends on 'Adafruit Unified Sensor' which the IDE will offer to install too. The library hides the bit-banging timing for you — you just call dht.readTemperature() and dht.readHumidity() and get back floats.

Print readings to Serial

In setup(), Serial.begin(9600) and dht.begin(). In loop(), read humidity and temperature, print them as 'Temp: 23.0 °C Humidity: 45.0 %' to Serial, and delay(2000). Open the Serial Monitor at 9600 baud — you should see a fresh reading every two seconds. Breathe on the sensor and watch the humidity climb to 80–90 %.