Grove temperature humidity sensors

Table of Contents

    Introduction

    This page covers the low cost DHT temperature & humidity sensors. These sensors are very basic and slow, but are great for some basic data logging. The DHT sensors are made of two parts, a capacitive humidity sensor and a thermistor. There is also a very basic chip inside that does some analog to digital conversion and spits out a digital signal with the temperature and humidity. The digital signal is fairly easy to read using any microcontroller.

    Product Specifications

    There are different versions of the DHT sensor, they look a bit similar and have the same pinout, but have different characteristics.

    DHT11

    • Power Supply: 3 to 5V DC, 2.5mA max current use during conversion (while requesting data)
    • Operating range: Good for 20-80% humidity readings with 5% accuracy
    • Good for 0-50°C temperature readings ±2°C accuracy
    • No more than 1 Hz sampling rate (once every second)
    • Body size: 15.5mm x 12mm x 5.5mm

    DHT22

    • 3 to 5V power and I/O 2.5mA max current use during conversion (while requesting data)
    • Good for 0-100% humidity readings with 2-5% accuracy
    • Good for -40 to 125°C temperature readings ±0.5°C accuracy
    • No more than 0.5 Hz sampling rate (once every 2 seconds)
    • Body size: 15.1mm x 25mm x 7.7mm

    The DHT22 is a little more accurate. All sensors have a low sampling rate.

    Different names

    They come in different packages, breakoutboards:

    Wiring / Connectivity

    Connection of the SEN11301P or SEN51035P:

    /media/uploads/Wimpie/_scaled_wiring.jpg

    • black - GND (Ground)
    • red - VCC (3 to 5V power)
    • white - NC (not connected)
    • yellow - SIG (Signal or data)

    Connection of the DHT11 or DHT22:

    Don't forget to place a 5K or 4k7 resistor between VCC and the data pin, to act as a medium-strength pull up on the data line.

    /media/uploads/Wimpie/dht11_pinout.jpg

    • pin 1 - VCC (3 to 5V power)
    • pin 2 - Data
    • pin 3 - NC (not connected)
    • pin 4 - GND

    Library

    Import libraryDHT

    Test Code

    #include "mbed.h"
    #include "DHT.h"
    
    DigitalOut myled(LED1);
    
    DHT sensor(p23,SEN11301P); // Use the SEN11301P sensor
    
    int main() {
        int err;
        printf("\r\nDHT Test program");
        printf("\r\n******************\r\n");
        wait(1); // wait 1 second for device stable status
        while (1) {
            myled = 1;
            err = sensor.readData();
            if (err == 0) {
                printf("Temperature is %4.2f C \r\n",sensor.ReadTemperature(CELCIUS));
                printf("Temperature is %4.2f F \r\n",sensor.ReadTemperature(FARENHEIT));
                printf("Temperature is %4.2f K \r\n",sensor.ReadTemperature(KELVIN));
                printf("Humidity is %4.2f \r\n",sensor.ReadHumidity());
                printf("Dew point is %4.2f  \r\n",sensor.CalcdewPoint(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity()));
                printf("Dew point (fast) is %4.2f  \r\n",sensor.CalcdewPointFast(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity()));
            } else
                printf("\r\nErr %i \n",err);
            myled = 0;
            wait(5);
        }
    }
    

    Output

    /media/uploads/Wimpie/output_dht.jpg


    All wikipages