Maximum deep sleep

Updated on 3 September 2021
dev board WeMos D1 mini
chip ESP8266
features sleep wakeup
This tutorial is more than 1 year old. If the steps below do not work, then please check the latest versions and the documentations of the individual tools used.

Buy the components

Code

Download code max-deep-sleep.ino
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(115200);
  Serial.println("");
  Serial.println("[INFO] Wake up!");
}

void loop() {
  blinkLED();

  Serial.println("[INFO] Going to sleep for ESP.deepSleepMax()...");
  ESP.deepSleep(ESP.deepSleepMax());
}

void blinkLED() {
  Serial.println("LED ON");
  digitalWrite(LED_BUILTIN, LOW);
  delay(2000);

  Serial.println("LED OFF");
  digitalWrite(LED_BUILTIN, HIGH);
  delay(2000);

  Serial.println("LED ON");
  digitalWrite(LED_BUILTIN, LOW);
  delay(2000);

  Serial.println("LED OFF");
  digitalWrite(LED_BUILTIN, HIGH);
  delay(2000);
}

Makefile

.PHONY: lint compile upload clean

lint:
	cpplint --extensions=ino --filter=-legal/copyright *.ino

compile:
	arduino-cli compile --fqbn esp8266com:esp8266:d1_mini ./

upload:
	arduino-cli upload -p /dev/cu.wchusbserial1410 --fqbn esp8266com:esp8266:d1_mini ./

clean:
	rm -f .*.bin
	rm -f .*.elf

flash: lint compile upload clean

Serial console

Serial output from the firmware.

Maximum deep sleep serial console

Description

How long can ESP8266 sleep? This firmware code will test it out.

If only ESP8266 is used, short pin D0 to pin RST to enable wakeup. Then connect the USB power to a WeMos module, open the serial monitor and wait for the console to show wakeup.

It wakes up about 3 hours, 45 minutes later.

References