Skip to content Skip to sidebar Skip to footer

How to Use the DHT11 Sensor With Arduino Uno

DHT11 Sensor

Illustration: Pixabay

A. Pengertian Sensor DHT11

How to Use the DHT11 Sensor With Arduino Uno – DHT11 is a temperature and humidity sensor. This sensor has two sensors in it, namely a capacitive humidity sensor and a thermistor.

Although it is a cheap sensor and slow in data transmission, this sensor is suitable for beginners in making temperature and humidity detectors. This sensor has the following maximum specifications:

- Temperature measurement range 0 – 50
- Humidity measurement range 20 – 90% RH
- Temperature reading accuracy ±2℃
- Humidity reading accuracy ±5% RH
- Working voltage 3.3 – 5.5V

Here are the detailed specifications of the Arduino DHT11 sensor which I quoted from the datasheet:

B. Prinsip kerja DHT11

For sending and receiving data between the Arduino DHT11, this sensor uses a serial interface (single way two-way). This means that this sensor only uses one pin for sending and receiving data.

In the datasheet, this sensor takes 4ms at a time to communicate. Data packets issued or sent to Arduino are 40 bits.

The data format sent by DHT11 to Arduino is as follows: 8-bit integral RH data + 8-bit decimal RH data + 8-bit integral T data + 8-bit decimal T data + 8-bit condition data.

C. Rangkaian DHT11 Arduino

To be able to use the DHT11 sensor on Arduino, please follow the following circuit.

To make programming easier, there is a library for this sensor that we will use using Arduino.

There are two ways to get this library. First from library manager in arduino ide, second enter manually.

The library that I attached is taken from adafruit industries. Please download the following library and insert it into your Arduino IDE:

The following is an example program displaying temperature data.

#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11 // DHT 11
void setup() {
Serial.println(F("DHTxx test!"));
void loop() {
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
Serial.print(F("Humidity: "));
Serial.print(F("% Temperature: "));
Serial.print(F("°C "));
Serial.print(F("°F Heat index: "));
Serial.print(F("°C "));


1 comment for "How to Use the DHT11 Sensor With Arduino Uno"