basic temp probe

Dependencies:   DHT mbed

Fork of DHT-11 by Umair Aftab

Committer:
umairaftab
Date:
Mon Mar 03 19:57:32 2014 +0000
Revision:
0:6e5d3c6e8715
Child:
1:2fc8fc8a4b8d
working ;

Who changed what in which revision?

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