DHT11 and LCD, humidity, temperature, dew point
Dependencies: Freetronics_16x2_LCD mbed
Revision 0:5e787e0e8ab6, committed 2015-02-24
- Comitter:
- fblanc
- Date:
- Tue Feb 24 12:41:17 2015 +0000
- Commit message:
- test ST nucleo L152RE OK
Changed in this revision
diff -r 000000000000 -r 5e787e0e8ab6 DHT.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DHT.lib Tue Feb 24 12:41:17 2015 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/sam_grove/code/DHT/#df22ddf10d75
diff -r 000000000000 -r 5e787e0e8ab6 Freetronics_16x2_LCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Freetronics_16x2_LCD.lib Tue Feb 24 12:41:17 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/components/code/Freetronics_16x2_LCD/#0e04b6c4abb8
diff -r 000000000000 -r 5e787e0e8ab6 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Feb 24 12:41:17 2015 +0000 @@ -0,0 +1,69 @@ +#include "mbed.h" +#include "freetronicsLCDShield.h" +#include "DHT.h" + +freetronicsLCDShield lcd(D8, D9, D4, D5, D6, D7, D3, A0); +DHT sensor(A5, DHT11); +DigitalOut myled(LED1); +Ticker flipper; +bool up=true; +void readBP() +{ + float bp=lcd.readButton(); + if (bp<0.25) + up=true; + else if (bp<0.5) + up=false; +} +int main() +{ + flipper.attach(&readBP, 0.1); + int error = 0; + float h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f; + // turn on the back light (it's off by default) + lcd.setBackLight(true); + lcd.cls(); + // print the first line and wait 3 sec + lcd.printf("mbed DHT11"); + wait(3); + + // print the counter prefix; the number will be printed in the while loop + + + + + while (1) { + + 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); + if(up==true) { + lcd.setCursorPosition(0, 0); + lcd.printf("Temperature %4.2f ",c); + lcd.setCursorPosition(1, 0); + lcd.printf("Humidity %4.2f ", h); + } + if(up==false) { + + lcd.setCursorPosition(0, 0); + lcd.printf("Humidity %4.2f ", h); + lcd.setCursorPosition(1, 0); + lcd.printf("Dew point %4.2f ",dp); + } + } else { + + lcd.setCursorPosition(0, 0); + lcd.printf("mbed DHT11 "); + lcd.setCursorPosition(1, 0); + lcd.printf("Error: %d ", error); + } + + + wait(0.5f); + } +}
diff -r 000000000000 -r 5e787e0e8ab6 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Feb 24 12:41:17 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac \ No newline at end of file