Chat freely about anything...

User avatar
By OzGrant
#88071 G'Day,
Have attached a basic Light-Sleep sketch that blinks the Led OK but then stops randomly.
Often blinks 10 times other times 50. (Hardware is a WeMos mini)
Anyone got any clues.

#include <ESP8266WiFi.h>
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, LOW);
wifi_set_sleep_type(NONE_SLEEP_T); // Disable light sleep
delay(2000);
digitalWrite(LED_BUILTIN, HIGH);
wifi_set_sleep_type(LIGHT_SLEEP_T); // Enable light sleep
delay(2000);
}
User avatar
By dj_thossi
#90000
OzGrant wrote:G'Day,
Have attached a basic Light-Sleep sketch that blinks the Led OK but then stops randomly.
Often blinks 10 times other times 50. (Hardware is a WeMos mini)
Anyone got any clues.

I'm not sure why your board is stops working over time.

OzGrant wrote:#include <ESP8266WiFi.h>
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, LOW);
wifi_set_sleep_type(NONE_SLEEP_T); // Disable light sleep
delay(2000);
digitalWrite(LED_BUILTIN, HIGH);
wifi_set_sleep_type(LIGHT_SLEEP_T); // Enable light sleep
delay(2000);
}

I was just running your code on an ESP-01F and the multimeter stays stable at about 68 mA, indifferent if LED is on or off.
User avatar
By dj_thossi
#90002 I'm looking for a way to save as much energy as possible with an ESP-01F without soldering for deep sleep. I managed to do the WiFi.forceSleepBegin. This wrings consumption down to 16 mA. Now I read about light sleep which is suppose to bring the consumption down to about 2 mA. I even managed to get the following code running as expected, except the multimeter shows still 15 mA in during light sleep. Does anyone has an idea on how to get light sleep mode properly working on ESP-01F? Keep in mind. I'm not good in soldering and PIN 2 will be later used for reading from DHT-22 sensor.

Code: Select all#include <ESP8266WiFi.h>

extern "C" {
#include "gpio.h"
}
extern "C" {
#include "user_interface.h"
}

const char* ssid = "XXX";
const char* password = "XXX";
WiFiClient client;

void setup() {
  Serial.begin(74880);
  Serial.println("Initializing");
  gpio_init();
//  pinMode(0, INPUT); // this pin is connected to the PIR sensor.
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  delay(1000);
}

void loop() {
  Serial.println("Ready to go into light sleep...");
  delay(1000);
  Serial.println("3...");
  delay(1000);
  Serial.println("2...");
  delay(1000);
  Serial.println("1...");
  sleepNow();
}

void sleepNow() {
  Serial.println("going to light sleep...");
//  wifi_station_disconnect();
  wifi_set_opmode(NULL_MODE);
  wifi_fpm_set_sleep_type(LIGHT_SLEEP_T); //light sleep mode
//  gpio_pin_wakeup_enable(GPIO_ID_PIN(0), GPIO_PIN_INTR_HILEVEL);
  wifi_fpm_open();
  delay(100);
 
  wifi_fpm_set_wakeup_cb(wakeupFromMotion); //wakeup callback
  int sleepInMillisekonds = 5000;
  wifi_fpm_do_sleep(sleepInMillisekonds * 1000);
  delay(sleepInMillisekonds + 1); //It must be at least one ms more than wifi_fpm_do_sleep
}

void wakeupFromMotion(void) {
  wifi_fpm_close;
  wifi_set_opmode(STATION_MODE);
//  wifi_station_connect();
  Serial.println("Woke up from sleep");
}



The output looks like this
Code: Select allload 0x4010f000, len 3584, room 16
tail 0
chksum 0xb0
csum 0xb0
v2843a5ac
~ld
initializing
Ready to go into light sleep...
3...
2...
1...
going to light sleep...
Woke up from sleep
Ready to go into light sleep...
3...
2...
1...
going to light sleep...


Again: Does anyone has an idea or a working example on how to get light sleep mode properly working on ESP-01F?