This guide shows how to connect a DHT11 temperature and humidity sensor to an Arduino and read both values with the Adafruit DHT library. The DHT11 is a digital sensor; its pinout and electrical requirements depend on whether you have a bare sensor or a breakout module, so check the documentation supplied with your exact unit.
In this guide
Introduction
DHT11 sends temperature and relative-humidity readings over a digital data line. It is commonly used for learning and simple microcontroller projects. Do not treat an Arduino demonstration as calibration or validation for a production measurement system.
Wiring the DHT11
Identify VCC, GND and DATA from the sensor or module markings and its datasheet; physical pin order is not universal across every breakout. Connect DATA to the digital input selected in the sketch, connect grounds together, and use only a supply voltage supported by both the sensor and the Arduino board. A bare sensor may need an external pull-up on the data line; some modules already include one. Verify this from the module documentation before adding components.
Install the Arduino library and read values
In the Arduino IDE Library Manager, install “DHT sensor library by Adafruit” and its “Adafruit Unified Sensor” dependency. Set the data pin and sensor type to match your hardware. This example reads temperature in Celsius and relative humidity, checks for failed readings, and prints the results to Serial Monitor:
#include <DHT.h>
#define DHTPIN 2 // DATA pin connected to digital pin 2
#define DHTTYPE DHT11 // Select the sensor installed
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
float humidity = dht.readHumidity();
float temperatureC = dht.readTemperature();
if (isnan(humidity) || isnan(temperatureC)) {
Serial.println(F("DHT read failed; check wiring and sensor type."));
delay(2000);
return;
}
Serial.print(F("Humidity: "));
Serial.print(humidity);
Serial.print(F("% Temperature: "));
Serial.print(temperatureC);
Serial.println(F(" °C"));
delay(2000);
}
The code follows Adafruit’s DHT library pattern. Use its Arduino setup guide and library documentation for current installation details and examples. The selected sensor type must match the installed model or readings may be invalid.
Testing and troubleshooting
- Confirm DATA is connected to the pin named in
DHTPIN, and the sensor type matchesDHTTYPE. - Check VCC, common ground, connector orientation and any pull-up requirement for the exact module.
- Open the correct serial port and baud rate, and allow the sensor’s recommended sampling interval between reads.
- If reads fail, test the library’s example sketch and inspect the wiring before changing code.
DHT11 Arduino projects are useful for prototyping and learning. For industrial or OEM temperature-and-humidity applications, review the required measurement range, accuracy, response, enclosure, environmental exposure and calibration evidence against the exact product documentation. See our temperature and humidity sensor range and contact the team with OEM requirements when a project needs a specified sensor assembly.
References: Adafruit DHTxx Arduino guide; Adafruit DHTtester example.


