St-connect
Dependencies: HP206C mbed WakeUp QMC5883L DHT22 DS1820
- ST Conect Project Look how we did it : [Hackster](https://www.hackster.io/monginjulien/st-connect-dike-monitoring-534a32)
Diff: main.cpp
- Revision:
- 8:c4801ce16934
- Parent:
- 7:036d9a2accff
- Child:
- 9:2f31939caaf2
--- a/main.cpp Tue Nov 06 13:22:55 2018 +0000 +++ b/main.cpp Mon Nov 12 10:24:45 2018 +0000 @@ -4,17 +4,18 @@ #include "HP20x_dev.h" #include "DS1820.h" #include "QMC5883L.h" + #define ENABLE_BAROMETER 1 #define ENABLE_MAGNETOMETER 1 #define ENABLE_GROUND_TEMPERATURE 1 #define ENABLE_GROUND_HUMIDITY 1 #define ENABLE_DHT22 1 + #define MESSAGE_SIZE 32 #define TRAME_SIZE 25 - #define DEBUG -// #define SEND_SIGFOX 1 +#define SEND_SIGFOX 1 #ifdef DEBUG Serial pc(USBTX, USBRX); @@ -41,6 +42,7 @@ #endif Serial sigfox(D1, D0); +DigitalInOut reset_sigfox(D9); char message[MESSAGE_SIZE] = "AT$SF="; @@ -126,16 +128,26 @@ int main() { - sigfox.printf("\r\n"); - #ifdef ENABLE_MAGNETOMETER - capt_magnetometer.init(); - #endif - #ifdef DEBUG pc.printf("\r\n\r\n\r\nInit...\r\n"); #endif + sigfox.printf("\r\n"); + + #ifdef ENABLE_MAGNETOMETER + capt_magnetometer.init(); + wait_ms(1500); + #endif + while(1) { + // Wake Up sigfox + reset_sigfox.output(); + reset_sigfox = 0; + wait(5); + + // Set high impendance the sigfox reset pin + reset_sigfox.input(); + #ifdef ENABLE_GROUND_TEMPERATURE // Temperature Sol capt_ground_temperature.convertTemperature(true, DS1820::all_devices); @@ -159,14 +171,18 @@ #ifdef ENABLE_BAROMETER // Pression if(capt_barometer.isAvailable()) + { pressure = capt_barometer.ReadPressure(); + } #endif #ifdef ENABLE_MAGNETOMETER // Magnetometre + // capt_magnetometer.soft_reset(); magnetic_field[0] = capt_magnetometer.getMagXvalue(); magnetic_field[1] = capt_magnetometer.getMagYvalue(); magnetic_field[2] = capt_magnetometer.getMagZvalue(); + // capt_magnetometer.standby(); #endif // Affichage pour debug @@ -188,15 +204,22 @@ #endif #ifdef SEND_SIGFOX + #ifdef DEBUG + pc.printf("ENVOIE\r\n", message); + #endif sigfox.printf("%s", message); + wait(10); + #endif + sigfox.printf("AT$P=1\r\n"); + #ifdef DEBUG + pc.printf("Sleep"); #endif // DEEPSLEEP - /* - WakeUp::set_ms(10000); + WakeUp::set_ms(30000); WakeUp::attach(&mycallback); deepsleep(); - */ - wait(1000); + //wait(30); + //wait(10); } } \ No newline at end of file