0% found this document useful (0 votes)
404 views

DHT11 Sensor Interfacing With ARM MBED - MBED

The document describes interfacing a DHT11 temperature and humidity sensor with an ARM MBED microcontroller. The DHT11 sensor measures relative humidity from 20-90% and temperature from 0-50°C over a single data line using different pulse times. An example program uses the DHT library to read temperature and humidity values from the DHT11 sensor and print them to the serial window every 2 seconds.

Uploaded by

Krishanu Modak
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
404 views

DHT11 Sensor Interfacing With ARM MBED - MBED

The document describes interfacing a DHT11 temperature and humidity sensor with an ARM MBED microcontroller. The DHT11 sensor measures relative humidity from 20-90% and temperature from 0-50°C over a single data line using different pulse times. An example program uses the DHT library to read temperature and humidity values from the DHT11 sensor and print them to the serial window every 2 seconds.

Uploaded by

Krishanu Modak
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

DHT11 Sensor Interfacing with ARM MBED

DHT11 Sensor

DHT11 sensor measures and provides humidity and temperature values serially over a single wire.
It can measure relative humidity in percentage (20 to 90% RH) and temperature in degree Celsius in the range of 0 to 50°C.
It has 4 pins; one of which is used for data communication in serial form.
Pulses of different TON and TOFF are decoded as logic 1 or logic 0 or start pulse or end of frame.

For more information about DHT11 sensor and how to use it, refer the topic DHT11 sensor in the sensors and modules topic.

Interfacing Diagram

Interfacing DHT11 Sensor with ARM MBED

 
Example

Reading temperature and humidity from DHT11 sensor.

Here, we will be using DHT11 library by seed studio from mbed. To use this library, we have to import or download DHT11 library
developed by SEEED Studio.

Program

#include "mbed.h"

#include "DHT.h"

DHT sensor(p5, DHT11);

int main()

int error = 0;

float h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f;

while(1) {

wait(2.0f);

error = sensor.readData();

if (0 == error) {

c = sensor.ReadTemperature(CELCIUS);

f = sensor.ReadTemperature(FARENHEIT);

k = sensor.ReadTemperature(KELVIN);

h = sensor.ReadHumidity();

dp = sensor.CalcdewPoint(c, h);

dpf = sensor.CalcdewPointFast(c, h);

printf("Temperature in Kelvin: %4.2f, Celcius: %4.2f, Farenheit %4.2f\n", k, c, f);

printf("Humidity is %4.2f, Dewpoint: %4.2f, Dewpoint fast: %4.2f\n", h, dp, dpf);

} else {

printf("Error: %d\n", error);

Output of DHT11 in serial window


 

You might also like