concordia

Dependencies:   mbed

Committer:
urietony
Date:
Tue Mar 07 00:38:17 2017 +0000
Revision:
0:1d0724ab888b
lalala

Who changed what in which revision?

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