Mathieu Moneyron / Mbed 2 deprecated projetS1

Dependencies:   HP206C mbed HMC5883L DHT DS1820

Revision:
72:f678052af558
Parent:
71:b31e3ee29dd0
Child:
73:bc3b0ee46dfc
--- a/main.cpp	Tue Oct 09 15:35:04 2018 +0000
+++ b/main.cpp	Tue Oct 09 15:58:00 2018 +0000
@@ -6,29 +6,48 @@
 #include "altitude.h"
 #include "HMC5883L.h"
 
-
+DS1820 probe(PA_5);
+AnalogIn humidSensor(PA_6);
 Serial wisol(SERIAL_PORT);
 Serial pc(USBTX, USBRX);
 DHT sensor(PIN_NAME, DHTtype);
 HP20x_dev barometre(HP20X_I2C_PORT);
 HMC5883L hmc5883(HMC5883_I2C_PORT);
 
-int main() {
+int main()
+{
+    float airH = 0,airT = 0, solT = 0, solH = 0;;
+    long P = 0;
+    float airValue(AIR_SOIL_HUMIDITY);
+    float waterValue(WATER_SOIL_HUMIDITY);
+
+
+    if(initSoilTemp(probe,PA_5)) {
+        pc.printf("unassigned Probe\r\n");
+    }
     barometre.reset();
     while(1) {
-        float airH = 0,airT = 0;
+        float temp = 0;
         int16_t magXYZ[3];
-        long P = 0;
-        
+
         //collect data
         hmc5883.getXYZ(magXYZ);
         get_T_H_air(&airT, &airH, sensor); // takes 2s to execute
-        P = pression(&barometre);
-        
+        P = pression(&barometre); // takes 5s to execute
+        temp = getSoilTemperature(probe);
+        if(temp == DS1820::invalid_conversion) {
+            pc.printf("Error with soil temperature probe : not connected\n\r");
+        }
+        else{
+            solT = temp;
+            }
+        solH = getSoilHumidity( humidSensor, airValue,waterValue, true);
         // Display
         pc.printf("\n=====| Data |=====\n");
+        pc.printf("T air : %.2f C\r\n", airT);
         pc.printf("H air : %.2f %%\r\n", airH);
-        pc.printf("T air : %.2f C\r\n", airT);
+        pc.printf("T sol : %.2f C\r\n", solT);
+        pc.printf("H sol : %.2f %%\r\n", solH);
         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);