Slave for temp k64f

Dependencies:   mbed HCSR04 DHT

Files at this revision

API Documentation at this revision

Comitter:
varza
Date:
Wed Dec 12 22:03:38 2018 +0000
Commit message:
temp/humid k64f slave;

Changed in this revision

DHT.lib Show annotated file Show diff for this revision Revisions of this file
HCSR04.lib Show annotated file Show diff for this revision Revisions of this file
Slave_Main_Temp.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 399c90b6c19a DHT.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DHT.lib	Wed Dec 12 22:03:38 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Wimpie/code/DHT/#9b5b3200688f
diff -r 000000000000 -r 399c90b6c19a HCSR04.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HCSR04.lib	Wed Dec 12 22:03:38 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/rabad1/code/HCSR04/#5461d44a187c
diff -r 000000000000 -r 399c90b6c19a Slave_Main_Temp.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Slave_Main_Temp.cpp	Wed Dec 12 22:03:38 2018 +0000
@@ -0,0 +1,78 @@
+#include "mbed.h"
+#include "DHT.h"
+
+DHT sensor(D4, DHT11);
+Timeout response;
+
+DigitalOut green(LED_GREEN);
+DigitalOut red(LED_RED);
+DigitalIn  sw2(SW2);
+Serial pc(USBTX, USBRX );
+
+Serial blue(PTC15, PTC14); //tx, rx
+
+int main()
+{
+    int error = 0;
+    float h = 0.0f, k = 0.0f, dpf = 0.0f;
+    int c; 
+    int f;
+    int dp;
+    char send = 'Z';
+    char hold = 'b';
+    char correct = 'C';
+    int rangeFeet;
+     
+    
+    pc.baud(9600);
+    blue.baud(9600);
+    
+    printf("Slave connecting to the master\n");
+    
+    
+      //------------------------Sensor Start-------------------------------------
+    
+    
+    while (send!='R') {
+        wait(0.5f);
+        error = sensor.readData();
+        if (0 == error) 
+        {
+            c   = sensor.ReadTemperature(CELCIUS);
+            f   = sensor.ReadTemperature(FARENHEIT);
+            k   = sensor.ReadTemperature(KELVIN);
+            h   = sensor.ReadHumidity();
+            dp  = sensor.CalcdewPoint(c, h);
+            dpf = sensor.CalcdewPointFast(c, h);
+            
+            printf("\n Temperature in Kelvin: %4.2f, Celcius: %i, Farenheit %i\n\r", k, c, f);
+            printf("\n Humidity is %4.2f, Dewpoint: %i, Dewpoint fast: %4.2f\n\r", h, dp, dpf);
+        } 
+        else 
+        {
+        //    printf("Error: %d\n\r", error);
+        }
+       
+       
+       //-----------------------Sensor End--------------------------------------
+       //-----------------------Transmit Begin----------------------------------
+       
+        if(blue.readable())
+        {
+            char word = f + '0'; 
+            blue.putc(word); 
+            
+            wait(0.5f);
+            
+            word = dp + '0';
+            blue.putc(word);
+        }
+        
+        //----------------------Transmit End------------------------------------
+        
+        wait(0.5f); // wait a small period of time        
+        green = !green; // toggle a led
+        
+    }
+}
+
diff -r 000000000000 -r 399c90b6c19a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Dec 12 22:03:38 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file