ruche

Dependencies:   ATParser DHT22 SerialGPS Sigfox mbed

Fork of Nucleo_SerialGPS_to_PC by hime hime

Files at this revision

API Documentation at this revision

Comitter:
dahmani_belkacem
Date:
Wed Jan 17 14:34:05 2018 +0000
Parent:
0:e0a6c18ea0fb
Child:
2:f760e8507750
Commit message:
publier

Changed in this revision

ATParser.lib Show annotated file Show diff for this revision Revisions of this file
DHT22.lib Show annotated file Show diff for this revision Revisions of this file
Sigfox.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ATParser.lib	Wed Jan 17 14:34:05 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/dahmani_belkacem/code/ATParser/#07049b3aad7a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DHT22.lib	Wed Jan 17 14:34:05 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Julepalme/code/DHT22/#7fd3ff04ae95
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sigfox.lib	Wed Jan 17 14:34:05 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/dahmani_belkacem/code/Sigfox/#43a4b8ba4635
--- a/main.cpp	Mon Jan 05 15:34:58 2015 +0000
+++ b/main.cpp	Wed Jan 17 14:34:05 2018 +0000
@@ -1,12 +1,25 @@
 #include "mbed.h"
 #include "SerialGPS.h"
+#include "DHT22.h"
+#include "Sigfox.h"
+#include "BufferedSerial.h"
+//#include "ATParser.h"
 
  
 Serial pc(USBTX, USBRX); // tx, rx
-SerialGPS gps(PA_9,PA_10);  // tx, rx
+SerialGPS gps(PC_10,PC_11);  // tx, rx
+DHT22 dht22(D4);//pin pour la lecture du dht22 grove
+DHT22 dht22Bis(D5);//pin pour la lecture du dht22 
+AnalogIn IRSensor(A1);//Pin de lecture du capteur IR
+
+BufferedSerial serial = BufferedSerial(PC_10,PC_11);
+//ATParser at = ATParser(serial, "\r\n");
+Sigfox sig(*);
+
+//Sigfox(at(&at));
 
 
-
+//programme du gps
 
 /**
  * A callback function for logging data.
@@ -22,12 +35,15 @@
  */
 void cbfunc_gga(SerialGPS::gps_gga_t *p) {
 
-        pc.printf("%02d:%02d:%02d(P%d,S%d)\r\n", p->hour, p->min, p->sec, p->position_fix, p->satellites_used);
+     pc.printf("%02d:%02d:%02d(P%d,S%d)\r\n", p->hour, p->min, p->sec, p->position_fix, p->satellites_used);
+
+       // pc.printf("latitude  %c=%10.4f\r\n", p->ns, p->latitude);
 
-        pc.printf("%c=%10.4f\r\n", p->ns, p->latitude);
-
-        pc.printf("%c=%10.4f\r\n", p->ew, p->longitude);
-    
+       // pc.printf("longitude %c=%10.4f\r\n", p->ew, p->longitude);
+        double a = p->latitude;
+        double b = p->longitude;
+        pc.printf("latitude %10.4f\r\n", a);
+        pc.printf("longitude %10.4f\r\n", b);
 }
 
 /**
@@ -37,7 +53,7 @@
  */
 void cbfunc_gsa(SerialGPS::gps_gsa_t *p) {
 
-        pc.printf("SEL:%c FIX:%d\r\n", p->selmode, p->fix);
+  pc.printf("SEL:%c FIX:%d\r\n", p->selmode, p->fix);
   
 }
 
@@ -48,7 +64,7 @@
  */
 void cbfunc_gsv(SerialGPS::gps_gsv_t *p) {
  
-        pc.printf("Satellites:%2d\r\n", p->satcnt);
+      pc.printf("Satellites:%2d\r\n", p->satcnt);
 
 }
 
@@ -59,7 +75,7 @@
  */
 void cbfunc_rmc(SerialGPS::gps_rmc_t *p) {
 
-        pc.printf("%02d:%02d:%02d(%c)\r\n", p->hour, p->min, p->sec, p->status);
+     pc.printf("%02d:%02d:%02d(%c)\r\n", p->hour, p->min, p->sec, p->status);
 
 }
 
@@ -67,30 +83,93 @@
  * Entry point.
  */
 
+//fin du prgramme de lecture GPS
 
+//Fonction lecture des donneé sigfox
 
  
 int main() {
+    //programme main du gps
+        //programme main de lecture DHT22
+    
+    int hum;
+    int temp;
+    int hum1;
+    int temp1;
     
     pc.baud(9600);
-    
+ 
     
     pc.printf("TEST\r\n");
     wait(0.5);
+    pc.printf("TEST1\r\n");
     
     SerialGPS::gps_callback_t cb;
     cb.cbfunc_log = cbfunc_log;
-    cb.cbfunc_gga = cbfunc_gga;
+    pc.printf("TEST2\r\n");
+    
     cb.cbfunc_gsa = cbfunc_gsa;
     cb.cbfunc_gsv = cbfunc_gsv;
     cb.cbfunc_rmc = cbfunc_rmc;
     gps.attach(&cb);
-    
+    pc.printf("TEST3\r\n");
+
     while(1) {
         
-
-    gps.processing();
+     wait(1);
+     gps.processing();
+     pc.printf("TEST4\r\n");
+     //lecture du DHT22 grove
+             
+       dht22.sample() ;
+        hum=dht22.getHumidity()/10.0;
+        temp=dht22.getTemperature()/10.0;
+        printf("temperature: %d, humidity: %d\n\r",temp,hum);
+        
+        //lecture du DHT22 simple
+        
+        dht22Bis.sample() ;
+        hum1=dht22Bis.getHumidity()/10.0;
+        temp1=dht22Bis.getTemperature()/10.0;
+        printf("temperature1: %3d, humidity1: %3d\n\r",temp1,hum1);
+      
+        //mesure de la distance 
+        
+        //wait(2);
+       //3.1V at 4cm to 0.3V at 30cm. 
+       float a = IRSensor;// 1=4cm 0=30cm
+       pc.printf("IR sensor reads %2.2f\n ", a);
+       a=1-a;// now 0=4cm and 1=30cm 
+       float b= 40+a * 260; //(a26+4);
+       pc.printf("\rDistance is %2.2f mm \n ", b); // print and convert to distance by taking x=0->1 and 26x+4
+      float x = 200 - b;
+      float f = 2.913*x;
+      int m= 1000*(f/(9.8));
+      pc.printf("\la masse de la ruche est egale a %2.2f g \n ",m); 
+     
+      sig->send(""+m);
+      
+      
+      wait(1);
+    
 
     }
+       //programme main de lecture DHT22
+    
+
+    
+
+    
+/*    while (1) {
+        
+       
+    }
+  */  
+    //Fin du programme de lecture DHT22
+    
+ 
 }
 
+
+
+
--- a/mbed.bld	Mon Jan 05 15:34:58 2015 +0000
+++ b/mbed.bld	Wed Jan 17 14:34:05 2018 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/7130f322cb7e
\ No newline at end of file