S. Ken San
/
KL05Z_DHT11
Example using DHT11 with KL05Z. DHT library from teams/components/code/DHT
Revision 0:052ced68c756, committed 2014-08-13
- Comitter:
- kenno
- Date:
- Wed Aug 13 13:44:15 2014 +0000
- Child:
- 1:d2396e83a3b9
- Commit message:
- Initial commit.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DHT.lib Wed Aug 13 13:44:15 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Wimpie/code/DHT/#bc5415405cad
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Aug 13 13:44:15 2014 +0000 @@ -0,0 +1,30 @@ +#include "mbed.h" +#include "DHT.h" + +DigitalOut myled(LED_GREEN); +Serial pc(USBTX, USBRX); // default baud 9600 + +DHT sensor(PTA11, DHT11); + +int main() { + int err; + pc.printf("\nDHT11 Test Program\n"); + + wait(1); // wait 1 sec for device stable + while (true) { + myled = 1; + err = sensor.readData(); + if (err == 0) { + pc.printf("Temperature is %4.2f C \r\n", sensor.ReadTemperature(CELCIUS)); + pc.printf("Temperature is %4.2f F \r\n", sensor.ReadTemperature(FARENHEIT)); + pc.printf("Humidity is %4.f % \r\n", sensor.ReadHumidity()); + printf("Dew point is %4.2f \r\n",sensor.CalcdewPoint(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity())); + printf("Dew point (fast) is %4.2f \r\n\n",sensor.CalcdewPointFast(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity())); + } + else { + printf("\r\nErr %i \n", err); + } + myled = 0; + wait(15); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Aug 13 13:44:15 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6213f644d804 \ No newline at end of file