projet capteur connecté ST/SE

Dependencies:   HP206C mbed HMC5883L DHT DS1820

Files at this revision

API Documentation at this revision

Comitter:
Fayge
Date:
Wed Oct 10 10:30:56 2018 +0000
Parent:
72:f678052af558
Child:
75:9f6a6c7d4bea
Commit message:
V0.4 added genMessage to main

Changed in this revision

config.h 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
--- a/config.h	Tue Oct 09 15:58:00 2018 +0000
+++ b/config.h	Wed Oct 10 10:30:56 2018 +0000
@@ -13,7 +13,7 @@
 #define AIR_SOIL_HUMIDITY           0.78 // dry dirt at 0.75 with AnalogIn.read()
 #define WATER_SOIL_HUMIDITY         0.38 // wet dirt at 0.54
 #define SOIL_T_PIN                  A4
-#define SOIL_H_PIN                  A5 // max: 0.77 min:0.38
+#define SOIL_H_PIN                  A3 // max: 0.77 min:0.38
 
 // Altitude
 #define HP20X_I2C_DEV_ID            0xEC
--- a/main.cpp	Tue Oct 09 15:58:00 2018 +0000
+++ b/main.cpp	Wed Oct 10 10:30:56 2018 +0000
@@ -6,8 +6,8 @@
 #include "altitude.h"
 #include "HMC5883L.h"
 
-DS1820 probe(PA_5);
-AnalogIn humidSensor(PA_6);
+DS1820 probe(SOIL_T_PIN);
+AnalogIn humidSensor(SOIL_H_PIN);
 Serial wisol(SERIAL_PORT);
 Serial pc(USBTX, USBRX);
 DHT sensor(PIN_NAME, DHTtype);
@@ -20,16 +20,16 @@
     long P = 0;
     float airValue(AIR_SOIL_HUMIDITY);
     float waterValue(WATER_SOIL_HUMIDITY);
+    char* msg;
 
 
-    if(initSoilTemp(probe,PA_5)) {
+    if(initSoilTemp(probe,SOIL_T_PIN)) {
         pc.printf("unassigned Probe\r\n");
     }
     barometre.reset();
     while(1) {
         float temp = 0;
         int16_t magXYZ[3];
-
         //collect data
         hmc5883.getXYZ(magXYZ);
         get_T_H_air(&airT, &airH, sensor); // takes 2s to execute
@@ -41,15 +41,22 @@
         else{
             solT = temp;
             }
-        solH = getSoilHumidity( humidSensor, airValue,waterValue, true);
+        solH = getSoilHumidity( humidSensor, airValue,waterValue, false);
+        
+        msg = genMessage( solH,  airH,  solT, airT, P,magXYZ);
         // Display
-        pc.printf("\n=====| Data |=====\n");
-        pc.printf("T air : %.2f C\r\n", airT);
+        pc.printf("\n\r=====| Data |=====\n\r");
+        pc.printf("H sol : %.2f %%\r\n", solH);
         pc.printf("H air : %.2f %%\r\n", airH);
         pc.printf("T sol : %.2f C\r\n", solT);
-        pc.printf("H sol : %.2f %%\r\n", solH);
+        pc.printf("T air : %.2f C\r\n", airT);
+        pc.printf("Mag : X:%d ; Y:%d ; Z:%d\n\r", magXYZ[0], magXYZ[1], magXYZ[2]); 
         pc.printf("Pression : %ul Pa\r\n", P);
-        pc.printf("Mag : X:%d ; Y:%d ; Z:%d\n", magXYZ[0], magXYZ[1], magXYZ[2]);
-        wait(5);
+        pc.printf("\n\r");
+        for(int i=0; i<12 ; ++i)
+        {
+            pc.printf("%x ",msg[i]);
+        }
+        wait(2);
     }
 }