Mathieu Moneyron / Mbed 2 deprecated projetS1

Dependencies:   HP206C mbed HMC5883L DHT DS1820

Revision:
53:a0752606d02c
Parent:
52:d49b6f468b97
Child:
54:61d003e0754d
Child:
55:887edb961698
diff -r 849a66d85f6b -r a0752606d02c main.cpp
--- a/main.cpp	Mon Oct 08 10:02:31 2018 +0000
+++ b/main.cpp	Mon Oct 08 10:19:07 2018 +0000
@@ -3,17 +3,21 @@
 #include "communication.h"
 #include "T_H_air.h"
 #include "altitude.h"
+#include "HMC5883L.h"
 
 
 Serial wisol(SERIAL_PORT);
 Serial pc(USBTX, USBRX);
 DHT sensor(PIN_NAME, DHTtype);
-I2C hp206c(D12, A6);
+I2C hp206c(HP20X_I2C_PORT);
+HMC5883L hmc5883(HMC5883_I2C_PORT);
 
 int main() {
     while(1) {
-        float airH, airT;
+        float airH, tmpH, tmpT, airT;
         char *message;
+        int16_t magXYZ[3];
+        unsigned long alt;
         /*
         read T&H air
         read T sol
@@ -24,14 +28,28 @@
         m = genMessage(T_air, H_air, T_sol, H_sol, Pressure, Mag)
         sendMessage(m)
         */
-        airH = airHumidity(sensor);
-        airT = airTemperature(sensor);
+        //airH = airHumidity(sensor);
+        //airT = airTemperature(sensor);
         //message = genMessage(airT, airH);
         //wisol.printf("AT$SF=%s\r\n", message);
-        unsigned long alt = readAltitude(&hp206c);
-        pc.printf("H air : %f\n", airH);
-        pc.printf("T air : %f\n", airT);
-        pc.printf("altitude : %lu\n", alt);
-        wait(1);
+        alt = readAltitude(&hp206c);
+        hmc5883.getXYZ(magXYZ);
+        pc.printf("\n=====| Data |=====\n");
+        tmpH = airHumidity(sensor);
+        if( tmpH!=0){
+            airH = tmpH;
+        }
+        
+        wait(2);
+
+        tmpT = airTemperature(sensor);
+        if( tmpT!=0 ){
+            airT=tmpT;
+        }
+        pc.printf("H air : %.2f \%\n", airH);
+        pc.printf("T air : %.2f °C\n", airT);
+        pc.printf("altitude : %lu m\n", alt);
+        pc.printf("Mag : X:%d ; Y:%d ; Z:%d\n", magXYZ[0], magXYZ[1], magXYZ[2]);
+        wait(5);
     }
 }