Working

Dependencies:   DHT mbed

Committer:
umairaftab
Date:
Tue Mar 18 23:49:51 2014 +0000
Revision:
0:8464dce1d116
Working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
umairaftab 0:8464dce1d116 1 #include "mbed.h"
umairaftab 0:8464dce1d116 2 #include "DHT.h"
umairaftab 0:8464dce1d116 3
umairaftab 0:8464dce1d116 4 DigitalOut myled(LED1);
umairaftab 0:8464dce1d116 5
umairaftab 0:8464dce1d116 6 DHT sensor(PTC7,SEN11301P); // Use the SEN11301P sensor
umairaftab 0:8464dce1d116 7
umairaftab 0:8464dce1d116 8 int main() {
umairaftab 0:8464dce1d116 9 int err;
umairaftab 0:8464dce1d116 10 printf("\r\nDHT Test program");
umairaftab 0:8464dce1d116 11 printf("\r\n******************\r\n");
umairaftab 0:8464dce1d116 12 wait(1); // wait 1 second for device stable status
umairaftab 0:8464dce1d116 13 while (1) {
umairaftab 0:8464dce1d116 14 myled = 1;
umairaftab 0:8464dce1d116 15 err = sensor.readData();
umairaftab 0:8464dce1d116 16 if (err == 0) {
umairaftab 0:8464dce1d116 17 printf("Temperature is %4.2f C \r\n",sensor.ReadTemperature(CELCIUS));
umairaftab 0:8464dce1d116 18 printf("Temperature is %4.2f F \r\n",sensor.ReadTemperature(FARENHEIT));
umairaftab 0:8464dce1d116 19 printf("Temperature is %4.2f K \r\n",sensor.ReadTemperature(KELVIN));
umairaftab 0:8464dce1d116 20 printf("Humidity is %4.2f \r\n",sensor.ReadHumidity());
umairaftab 0:8464dce1d116 21 printf("Dew point is %4.2f \r\n",sensor.CalcdewPoint(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity()));
umairaftab 0:8464dce1d116 22 printf("Dew point (fast) is %4.2f \r\n",sensor.CalcdewPointFast(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity()));
umairaftab 0:8464dce1d116 23 } else
umairaftab 0:8464dce1d116 24 printf("\r\nErr %i \n",err);
umairaftab 0:8464dce1d116 25 myled = 0;
umairaftab 0:8464dce1d116 26 wait(15);
umairaftab 0:8464dce1d116 27 }
umairaftab 0:8464dce1d116 28 }