St-connect

Dependencies:   HP206C mbed WakeUp QMC5883L DHT22 DS1820

  1. ST Conect Project Look how we did it : [Hackster](https://www.hackster.io/monginjulien/st-connect-dike-monitoring-534a32)
Revision:
0:1c266599e07b
Child:
1:6b6f96cbd12c
diff -r 000000000000 -r 1c266599e07b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 02 14:11:24 2018 +0000
@@ -0,0 +1,82 @@
+#include "mbed.h"
+#include "WakeUp.h"
+#include "DHT22.h"
+#include "HP20x_dev.h"
+#define DEBUG 1
+
+#ifdef DEBUG
+    Serial pc(USBTX, USBRX);
+#endif
+
+// HP20x_dev capt_barometer(D4, D5);
+// I2C capt_magnetometer(D4, D5);
+// AnalogIn capt_ground_humidity(A0);      // SEN0
+DHT22 capt_thermo_air_humidity(D3);     // DHT22
+Serial sigfox(D1, D0);
+
+char message[50] = {};
+
+long pressure = 1000;
+float air_temperature = 20;
+float air_humidity = 50;
+int ground_temperature = 20;
+int ground_humidity = 50;
+
+void mycallback()
+{
+}
+
+int main()
+{
+    sigfox.printf("\r\n");
+    #ifdef DEBUG
+        pc.printf("\r\n\r\n\r\nInit...\r\n");
+    #endif
+    
+    while(1) {
+        /*
+        // Temperature Sol
+        
+        // Humidite Sol
+        ground_humidity = capt_ground_humidity.read();
+        */
+        
+        // Temperature et Humidite Air
+        if(capt_thermo_air_humidity.sample())
+        {
+            air_temperature = capt_thermo_air_humidity.getTemperature() / 10.0;
+            air_humidity = capt_thermo_air_humidity.getHumidity() / 10.0;
+        }
+        
+        // Pression
+        /*
+        if(barometer.isAvailible())
+            pressure = capt_barometer.ReadPressure()
+        
+        // Magnetometre
+        */
+        
+        // Affichage pour debug
+        #ifdef DEBUG
+            // pc.printf("Pressure: %d\r\n", pressure);
+            // pc.printf("Ground Temperature: %.1f\r|\t Ground Humidity: %f\r\n", ground_temperature, ground_humidity);
+            pc.printf("Air Temperature: %.1f\t|\tAir Humidity: %.1f\r\n", air_temperature, air_humidity);
+        #endif
+        
+        // Envoie sigfox
+        sprintf(message, "AT$SF=%04x%02x\r\n", (int)(air_temperature*10), (int)(air_humidity*10));
+        #ifdef DEBUG
+            pc.printf("%s", message);
+        #endif
+        
+        //sigfox.printf("%s", message);
+        
+        // DEEPSLEEP
+        /*
+        WakeUp::set_ms(10000);
+        WakeUp::attach(&mycallback);
+        deepsleep();
+        */
+        wait(120);
+    }
+}