Plant Monitoring Project

Dependencies:   mbed SHT21_ncleee WakeUp SSD1306 DHT Adafruit_TCS34725 DS1820

Revision:
7:deb5dbe9e23d
Parent:
6:cd98294b2e5e
Child:
8:cbce19ac54b3
--- a/main.cpp	Tue Oct 08 15:49:46 2019 +0000
+++ b/main.cpp	Tue Oct 08 18:22:15 2019 +0000
@@ -35,6 +35,7 @@
 void    fct_RGB(unsigned char *pr, unsigned char *pg, unsigned char *pb, unsigned short *lux);
 void    sendDataSigfox(float tempSol, unsigned char *humSol, float tempAir, unsigned char *humAir, unsigned short *lux, unsigned char *R, unsigned char *G, unsigned char *B);
 void    oledData(void);
+void    readData(void);
 
 
     float temperature_sol;
@@ -46,32 +47,28 @@
     
     
 int main() {
-    oled.speed (SSD1306::Medium);  // set working frequency
-    oled.init();                   // initialize SSD1306
-    oled.cls();                    // clear frame buffer
+    // Initialisation de l'écran
+    oled.speed (SSD1306::Medium);
+    oled.init();
+    oled.cls();
     oled.set_contrast(200);
+    
+    // Initialisation WakeUp
+    //WakeUp::calibrate();
+    //WakeUp::set(10);                // Durée entre deux envois à modifier 
+    //WakeUp::attach(&readData);
         
     while(1) {
       
-      temperature_sol = temp_sol();
-      //pc.printf("T sol = %.2f\n\r", temperature_sol);
-      
-      humidity_sol = fct_humidity_sol();
-      //pc.printf("H sol = %d\n\r", humidity_sol);
+      // Mesures des grandeurs physiques
+      readData();
+        
+      // Affichage des données sur l'écran
+      oledData();
       
-      temperature_air = sht.readTemp();
-      //pc.printf("temperature_air = %.2f\n\r", temperature_air);
-      
-      humidity_air = sht.readHumidity();
-      //pc.printf("humidity_air = %d\n\r", humidity_air);
-      
-      fct_RGB(&pr, &pg, &pb, &lum);
-      //pc.printf("red=%d green=%d blue=%d\n\r", pr, pg, pb);
-        
-      oledData();
+      // Envoi des données sur le cloud
       sendDataSigfox(temperature_sol, &humidity_sol, temperature_air, &humidity_air, &lum, &pr, &pg, &pb);
     
-      //pc.printf("\n\r");
       wait(10);
     }
 }
@@ -141,4 +138,12 @@
     oled.redraw();
 }
 
+void readData(void){
+    temperature_sol = temp_sol();
+    humidity_sol = fct_humidity_sol();
+    temperature_air = sht.readTemp();
+    humidity_air = sht.readHumidity();
+    fct_RGB(&pr, &pg, &pb, &lum);
+}
 
+