diff --git a/TODO.md b/TODO.md index 5e17012..204b22e 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,6 @@ # WifiControlSensor * MQTT Watch GPIO value using interuption * Configure BMP180 altitude in EEPROM thanks to web interface -* Enable LIGHT_SLEEP_T wifi sleep type * Make mqtt optionnal * Make web interface optionnal diff --git a/WifiControlSensor/WifiControlSensor.ino b/WifiControlSensor/WifiControlSensor.ino index ae149eb..f8f9a91 100644 --- a/WifiControlSensor/WifiControlSensor.ino +++ b/WifiControlSensor/WifiControlSensor.ino @@ -35,14 +35,18 @@ #include #include #include + #include "config.h" #include "debug_sketch.h" #include "BMP180.h" - #include "Adafruit_MQTT.h" #include "Adafruit_MQTT_Client.h" +extern "C" { +#include +} + #define CONFIG_EEPROM_SIZE 256 char eeprom[CONFIG_EEPROM_SIZE]; @@ -218,6 +222,9 @@ void setup() { SKETCH_DEBUG_PRINTLN("BMP180 init success"); WebSetupServer(mode); } +#ifdef CONFIG_ENABLE_LIGHT_SLEEP + wifi_set_sleep_type(LIGHT_SLEEP_T); +#endif } uint nbCycle = 0; diff --git a/WifiControlSensor/config_device.h b/WifiControlSensor/config_device.h index d3bde77..1fd9978 100644 --- a/WifiControlSensor/config_device.h +++ b/WifiControlSensor/config_device.h @@ -12,6 +12,9 @@ #define CONFIG_BMP180_SDA 12 #define CONFIG_BMP180_SCL 14 +// Enable light sleep to save some power (http://bbs.espressif.com/viewtopic.php?f=6&t=133&p=485&hilit=sleep+modem#p485) +//#define CONFIG_ENABLE_LIGHT_SLEEP + /* DEFAULT VALUE ALSO DEFINED IN CONFIG.H */ // Time to sleep between 2 webserver request (increase it reduce battery usage but increase latency)