projet capteur connecté ST/SE

Dependencies:   HP206C mbed HMC5883L DHT DS1820

Files at this revision

API Documentation at this revision

Comitter:
SBACCARI
Date:
Tue Oct 09 15:14:35 2018 +0000
Parent:
66:cbfcea17a3c5
Child:
69:9ad4bce37c63
Child:
70:1e2e21c377ed
Commit message:
v0.2

Changed in this revision

T_H_soil.h Show annotated file Show diff for this revision Revisions of this file
altitude.cpp Show annotated file Show diff for this revision Revisions of this file
altitude.h Show annotated file Show diff for this revision Revisions of this file
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/T_H_soil.h	Tue Oct 09 14:43:03 2018 +0000
+++ b/T_H_soil.h	Tue Oct 09 15:14:35 2018 +0000
@@ -4,8 +4,8 @@
 #include "mbed.h"
 #include "DS1820.h"
  
-#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   AIR_SOIL_HUMIDITY 0.78 // dry dirt at 0.75 with AnalogIn.read()
+//#define WATER_SOIL_HUMIDITY 0.38 // wet dirt at 0.54
 
 
 bool initSoilTemp(DS1820 probe, PinName pin);
--- a/altitude.cpp	Tue Oct 09 14:43:03 2018 +0000
+++ b/altitude.cpp	Tue Oct 09 15:14:35 2018 +0000
@@ -1,13 +1,13 @@
 #include "altitude.h"
 #include "config.h"
 
-long pression(HP20x_dev barometre)
+long pression(HP20x_dev* barometre)
 {
     long P = 0;
-    barometre.reset();
+    barometre->reset();
     //pc.printf("SB : available? => %d \r\n", barometre.isAvailable() ); // DEBUG : show sensor status
     wait(2);
-    P = barometre.ReadPressure();
+    P = barometre->ReadPressure();
     //pc.printf("P = %ul \r\n", P); // DEBUG : print pressure value
     wait(3);
 
--- a/altitude.h	Tue Oct 09 14:43:03 2018 +0000
+++ b/altitude.h	Tue Oct 09 15:14:35 2018 +0000
@@ -5,6 +5,6 @@
 #include "HP20x_dev.h"
 #include "config.h"
 
-long pression(HP20x_dev barometre);
+long pression(HP20x_dev* barometre);
 
 #endif
\ No newline at end of file
--- a/config.h	Tue Oct 09 14:43:03 2018 +0000
+++ b/config.h	Tue Oct 09 15:14:35 2018 +0000
@@ -9,9 +9,11 @@
 #define PIN_NAME                    D6
 #define DHTtype                     DHT22
 
-// H_sol
-#define LOW_H                       160
-#define HIGH_H                      520
+// T_H_soil
+#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
 
 // Altitude
 #define HP20X_I2C_DEV_ID            0xEC
--- a/main.cpp	Tue Oct 09 14:43:03 2018 +0000
+++ b/main.cpp	Tue Oct 09 15:14:35 2018 +0000
@@ -2,6 +2,7 @@
 #include "config.h"
 #include "communication.h"
 #include "T_H_air.h"
+#include "T_H_soil.h"
 #include "altitude.h"
 #include "HMC5883L.h"
 
@@ -11,13 +12,17 @@
 DHT sensor(PIN_NAME, DHTtype);
 HP20x_dev barometre(HP20X_I2C_PORT);
 HMC5883L hmc5883(HMC5883_I2C_PORT);
+DS1820 probe(SOIL_T_PIN);
+AnalogIn humidSensor(SOIL_H_PIN);
 
 int main() {
+    if(initSoilTemp(probe,PA_5))
+            pc.printf("unassigned Probe\r\n");
+    float airValue(AIR_SOIL_HUMIDITY);
+    float waterValue(WATER_SOIL_HUMIDITY);
     while(1) {
         float airH = 0,airT = 0;
-        char *message;
         int16_t magXYZ[3];
-        unsigned long alt;
         long P = 0;
         /*
         read T&H air
@@ -36,16 +41,22 @@
         */
         
         //collect data
-        //alt = readAltitude(&hp206c);
         hmc5883.getXYZ(magXYZ);
         get_T_H_air(&airT, &airH, sensor); // takes 2s to execute
-        P = pression(barometre);
+        P = pression(&barometre);
+        float soilH = getSoilHumidity( humidSensor, airValue,waterValue, true);
+        float soilT = getSoilTemperature(probe);
+        
+        if(soilT == DS1820::invalid_conversion)
+            pc.printf("Error with soil temperature probe : not connected\n\r");
         
         // Display
         pc.printf("\n=====| Data |=====\n");
-        pc.printf("H air : %.2f \%\n", airH);
-        pc.printf("T air : %.2f °C\n", airT);
-        pc.printf("altitude : %lu m\n", alt);
+        pc.printf("H air : %.2f %%\r\n", airH);
+        pc.printf("T air : %.2f oC\r\n", airT);
+        pc.printf("H soil : %.2f %%\r\n", soilH);
+        pc.printf("T soil : %.2f oC\r\n", soilT);
+        pc.printf("Pression : %lu m\n", P);
         pc.printf("Mag : X:%d ; Y:%d ; Z:%d\n", magXYZ[0], magXYZ[1], magXYZ[2]);
         wait(5);
     }