Implement light sleep

This commit is contained in:
Mathieu Maret 2016-04-01 01:06:13 +02:00
parent a204d6fddf
commit 2778443ccc
3 changed files with 11 additions and 2 deletions

View File

@ -1,7 +1,6 @@
# WifiControlSensor # WifiControlSensor
* MQTT Watch GPIO value using interuption * MQTT Watch GPIO value using interuption
* Configure BMP180 altitude in EEPROM thanks to web interface * Configure BMP180 altitude in EEPROM thanks to web interface
* Enable LIGHT_SLEEP_T wifi sleep type
* Make mqtt optionnal * Make mqtt optionnal
* Make web interface optionnal * Make web interface optionnal

View File

@ -35,14 +35,18 @@
#include <EEPROM.h> #include <EEPROM.h>
#include <ArduinoOTA.h> #include <ArduinoOTA.h>
#include <errno.h> #include <errno.h>
#include "config.h" #include "config.h"
#include "debug_sketch.h" #include "debug_sketch.h"
#include "BMP180.h" #include "BMP180.h"
#include "Adafruit_MQTT.h" #include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h" #include "Adafruit_MQTT_Client.h"
extern "C" {
#include <user_interface.h>
}
#define CONFIG_EEPROM_SIZE 256 #define CONFIG_EEPROM_SIZE 256
char eeprom[CONFIG_EEPROM_SIZE]; char eeprom[CONFIG_EEPROM_SIZE];
@ -218,6 +222,9 @@ void setup() {
SKETCH_DEBUG_PRINTLN("BMP180 init success"); SKETCH_DEBUG_PRINTLN("BMP180 init success");
WebSetupServer(mode); WebSetupServer(mode);
} }
#ifdef CONFIG_ENABLE_LIGHT_SLEEP
wifi_set_sleep_type(LIGHT_SLEEP_T);
#endif
} }
uint nbCycle = 0; uint nbCycle = 0;

View File

@ -12,6 +12,9 @@
#define CONFIG_BMP180_SDA 12 #define CONFIG_BMP180_SDA 12
#define CONFIG_BMP180_SCL 14 #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 */ /* DEFAULT VALUE ALSO DEFINED IN CONFIG.H */
// Time to sleep between 2 webserver request (increase it reduce battery usage but increase latency) // Time to sleep between 2 webserver request (increase it reduce battery usage but increase latency)