Zain Zafar
/
DHT_TestProgram
DHT testprogram
Fork of DHT_TestProgram by
Diff: main.cpp
- Revision:
- 1:731de3b11b74
- Parent:
- 0:9ef709bfeb08
diff -r 9ef709bfeb08 -r 731de3b11b74 main.cpp --- a/main.cpp Tue Jul 10 13:11:23 2012 +0000 +++ b/main.cpp Tue Dec 29 10:55:05 2015 +0000 @@ -2,26 +2,40 @@ #include "DHT.h" DigitalOut myled(LED1); +DigitalInOut data_pin(A0); // Activate digital in +DigitalInOut data_pin(A1); // Activate digital in +Serial pc(SERIAL_TX, SERIAL_RX); // Initialize UART connection +Serial blutooth(PA_9, PA_10);//Tx, Rx +Timer tmr; //initialize timer +uint64_t adat; // 64 bit variable for temporary data +int i; -DHT sensor(p23,SEN11301P); // Use the SEN11301P sensor +// Use a terminal program (eg. TeraTerm). +//Timer tmr; //initialize timer + + +DHT sensor(A0,SEN11301P); // Use the SEN11301P sensor int main() { int err; - printf("\r\nDHT Test program"); - printf("\r\n******************\r\n"); + pc.printf("\r\nDHT Test program"); + pc.printf("\r\n******************\r\n"); wait(1); // wait 1 second for device stable status while (1) { myled = 1; + wait(2); err = sensor.readData(); if (err == 0) { - printf("Temperature is %4.2f C \r\n",sensor.ReadTemperature(CELCIUS)); - printf("Temperature is %4.2f F \r\n",sensor.ReadTemperature(FARENHEIT)); - printf("Temperature is %4.2f K \r\n",sensor.ReadTemperature(KELVIN)); - printf("Humidity is %4.2f \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",sensor.CalcdewPointFast(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity())); + + 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("Temperature is %4.2f K \r\n",sensor.ReadTemperature(KELVIN)); + pc.printf("Humidity is %4.2f \r\n",sensor.ReadHumidity()); + pc.printf("Dew point is %4.2f \r\n",sensor.CalcdewPoint(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity())); + pc.printf("Dew point (fast) is %4.2f \r\n",sensor.CalcdewPointFast(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity())); + pc.printf("\n\n\n"); } else - printf("\r\nErr %i \n",err); + pc.printf("\r\nErr %i \n",err); myled = 0; wait(5); }