This is code to test the ARCH GPRS with Grove TempHum sensor.
Dependencies: USBDevice idDHTLib mbed
Diff: main.cpp
- Revision:
- 0:7d6ba98d8088
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jan 28 18:47:50 2014 +0000 @@ -0,0 +1,44 @@ +#include "mbed.h" +#include "idDHTLib.h" +#include "USBSerial.h" + +DigitalOut myled(LED1); +//Virtual serial port over USB +USBSerial serial; + +void dhtWrapper(); +idDHTLib DHTLib(P1_24, dhtWrapper); + +void dhtWrapper() +{ + DHTLib.dht11Callback(); // change do dht11Callback if needed +} + +void readDht() +{ + if(!DHTLib.acquiring()) DHTLib.acquire(); +} + +int main() +{ + float humidity; + float temperature; + wait(10); + serial.printf("\r\nDHT Test program"); + serial.printf("\r\n******************\r\n"); + wait(1); // wait 1 second for device stable status + DHTLib.acquireAndWait(); + while (1) { + myled = 1; + readDht(); + humidity = DHTLib.getHumidity(); + temperature = DHTLib.getCelsius(); + serial.printf("Status is %i\r\n",DHTLib.getStatus()); + serial.printf("Temperature is %4.2f C \r\n",temperature); + serial.printf("Humidity is %4.2f \r\n",humidity); + + myled = 0; + wait(10); + } + +} \ No newline at end of file