DHT11 Sensor Interfacing With ARM MBED - MBED
DHT11 Sensor Interfacing With ARM MBED - 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
Example
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"
int main()
int error = 0;
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);
} else {