Example of my library for the DHT11 temperature and humidity sendor
Dependencies: DHT11 TextLCD mbed
Revision 0:da7b1c04a659, committed 2014-09-11
- Comitter:
- s_inoue_mbed
- Date:
- Thu Sep 11 13:50:10 2014 +0000
- Commit message:
- Example of my library for the DHT11 temperature and humidity sendor
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DHT11.lib Thu Sep 11 13:50:10 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/s_inoue_mbed/code/DHT11/#056d1e9b428c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Thu Sep 11 13:50:10 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 11 13:50:10 2014 +0000 @@ -0,0 +1,41 @@ +/* + * A program for the use of the DHT11, a temperature and humidity sensor + * Shigenori Inoue, September 10, 2014 + */ + +#include "mbed.h" +#include "TextLCD.h" +#include "DHT11.h" + +// LEDs for debugging +BusOut leds(LED4, LED3, LED2, LED1); + +// LCD module +TextLCD lcd(p25, p24, p12, p13, p14, p23); + +// Humidity sensor +DHT11 d(p18); + +// The main function +int main() +{ + int state; + + lcd.cls(); + lcd.locate(0, 0); + lcd.printf("DHT11 Humidity"); + + while(true) { + state = d.readData(); + + if (state != DHT11::OK) { + lcd.locate(0, 1); + lcd.printf("Error: %d", state); + } else { + lcd.locate(0, 1); + lcd.printf("T: %dC, H: %d%%", d.readTemperature(), d.readHumidity()); + } + leds = leds + 1; + wait(2.0); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Sep 11 13:50:10 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013 \ No newline at end of file