coen490 controller

Dependencies:   DHT mbed

Files at this revision

API Documentation at this revision

Comitter:
kayu
Date:
Tue Mar 07 18:35:22 2017 +0000
Commit message:
First commit; included Temperature and humidity code

Changed in this revision

DHT.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 845bbc545b56 DHT.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DHT.lib	Tue Mar 07 18:35:22 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Wimpie/code/DHT/#9b5b3200688f
diff -r 000000000000 -r 845bbc545b56 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 07 18:35:22 2017 +0000
@@ -0,0 +1,62 @@
+#include "mbed.h"
+#include "DHT/DHT.h"
+#include <string>
+
+using namespace std;
+
+DHT sensor(A2,DHT22); 
+Serial pc(SERIAL_TX,SERIAL_RX);
+Serial xbee(A0,A1);
+
+void getTemperatueHumidity(){
+    int err;
+    pc.printf("\r\nStarting to gather temperature and humidity......\n");
+    pc.printf("\r\n******************\r\n");
+    wait(1); // wait 1 second for device stable status
+    while (1) {
+ 
+        err = sensor.readData();
+        if (err == 0) {
+            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());
+     
+            xbee.printf("Temperature is %4.2f C \r\n",sensor.ReadTemperature(CELCIUS));
+            xbee.printf("Temperature is %4.2f F \r\n",sensor.ReadTemperature(FARENHEIT));
+            xbee.printf("Temperature is %4.2f K \r\n",sensor.ReadTemperature(KELVIN));
+            xbee.printf("Humidity is %4.2f \r\n",sensor.ReadHumidity());
+     
+            return;
+        } else {
+            pc.printf("\r\nErr %i \n",err);
+            xbee.printf("\r\nErr %i \n",err);
+        }
+        wait(5);
+    }
+}
+
+void printInit(){
+     xbee.printf("Awaiting User Command....\n");
+}
+
+int main() {
+   
+    char a;
+    printInit();
+    while(1){
+        a = xbee.getc();        
+        if(a == 'T'){
+            getTemperatueHumidity();
+            a = NULL; 
+            printInit();     
+        }
+        
+        if( a == 'G'){
+            //GPS function
+            a = NULL;
+            printInit();    
+        }      
+    }
+}
+
diff -r 000000000000 -r 845bbc545b56 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Mar 07 18:35:22 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e1686b8d5b90
\ No newline at end of file