Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HP206C mbed WakeUp QMC5883L DHT22 DS1820
Revision 8:c4801ce16934, committed 2018-11-12
- Comitter:
- raminou
- Date:
- Mon Nov 12 10:24:45 2018 +0000
- Parent:
- 7:036d9a2accff
- Child:
- 9:2f31939caaf2
- Commit message:
- sigfox sleep tested OK
Changed in this revision
--- a/DHT22.lib Tue Nov 06 13:22:55 2018 +0000 +++ b/DHT22.lib Mon Nov 12 10:24:45 2018 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/teams/IOT1234/code/DHT22/#f05f26b87bd4 +https://os.mbed.com/teams/IOT1234/code/DHT22/#bc68e7ad5200
--- a/QMC5883L.lib Tue Nov 06 13:22:55 2018 +0000 +++ b/QMC5883L.lib Mon Nov 12 10:24:45 2018 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/raminou/code/QMC5883L/#2620ae5391a6 +https://os.mbed.com/users/raminou/code/QMC5883L/#4136b94b5cb9
--- 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
