A simple example temperature/humidy sensor with LCD display using: DHT11 & Robot LCD 1602

Dependencies:   DHT TextLCD mbed

Fork of DHT11-HelloWorld by WIZnet

Committer:
kaizen
Date:
Tue Jun 23 00:18:57 2015 +0000
Revision:
0:3b6dd029d50c
Child:
1:f31d081b628c
Example for DHT11 on WIZwiki-W7500

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kaizen 0:3b6dd029d50c 1 #include "mbed.h"
kaizen 0:3b6dd029d50c 2 #include "DHT.h"
kaizen 0:3b6dd029d50c 3
kaizen 0:3b6dd029d50c 4 DHT sensor(D4, DHT11);
kaizen 0:3b6dd029d50c 5
kaizen 0:3b6dd029d50c 6 int main()
kaizen 0:3b6dd029d50c 7 {
kaizen 0:3b6dd029d50c 8 int error = 0;
kaizen 0:3b6dd029d50c 9 float h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f;
kaizen 0:3b6dd029d50c 10
kaizen 0:3b6dd029d50c 11 while(1) {
kaizen 0:3b6dd029d50c 12 wait(2.0f);
kaizen 0:3b6dd029d50c 13 error = sensor.readData();
kaizen 0:3b6dd029d50c 14 if (0 == error) {
kaizen 0:3b6dd029d50c 15 c = sensor.ReadTemperature(CELCIUS);
kaizen 0:3b6dd029d50c 16 f = sensor.ReadTemperature(FARENHEIT);
kaizen 0:3b6dd029d50c 17 k = sensor.ReadTemperature(KELVIN);
kaizen 0:3b6dd029d50c 18 h = sensor.ReadHumidity();
kaizen 0:3b6dd029d50c 19 dp = sensor.CalcdewPoint(c, h);
kaizen 0:3b6dd029d50c 20 dpf = sensor.CalcdewPointFast(c, h);
kaizen 0:3b6dd029d50c 21 printf("Temperature in Kelvin: %4.2f, Celcius: %4.2f, Farenheit %4.2f\n", k, c, f);
kaizen 0:3b6dd029d50c 22 printf("Humidity is %4.2f, Dewpoint: %4.2f, Dewpoint fast: %4.2f\n", h, dp, dpf);
kaizen 0:3b6dd029d50c 23 } else {
kaizen 0:3b6dd029d50c 24 printf("Error: %d\n", error);
kaizen 0:3b6dd029d50c 25 }
kaizen 0:3b6dd029d50c 26 }
kaizen 0:3b6dd029d50c 27 }