This microcontroller board can be used for low power usage thanks to the ESP32's multiple sleep modes.
There are three basic operating states to Espressif chips: normal, light sleep and deep sleep.
Normal power usage is as you expect: you can use the chip and run code as you like - connecting to WiFi, reading sensors, etc.
Light sleep is sort of a 'hibernation' - power usage is minimal and WiFi is disconnected, but the internal clock and memory is kept. That means you can wake up where you left off, in the middle of the code as desired. You'll still need to re-initialize any external hardware that got disconnected, and WiFi, but it's often faster than waking from a deep sleep
Deep sleep is the lowest power but the tradeoff is that all memory and state is lost - the only thing that's running is the real time clock that can wake the chip up. When woken up, the chip starts as if it was physically reset - from the beginning of the code. This can be beneficial if you want to have a fresh start each time
A rough guideline is:
- Normal power: 100mA+ can be as much power as need and spike during WiFi connection
- Light sleep: 2mA assuming all external hardware is de-powered
- Deep sleep: 100uA assuming all external hardware is de-powered
The Adafruit ESP32 Feather V2 has a NEOPIXEL_I2C_POWER
pin that controls power to I2C and the NeoPixel LED. This pin is automatically pulled HIGH in both CircuitPython and Arduino. Disabling this pin by setting it to an output and LOW allows you to drop the power draw, even when you have I2C sensors or breakouts connected.
Here's a generic sketch we use for all our boards that has a macro-defined section for enabling and disabling all external powered elements. For example, if there's a power pin for NeoPixels, I2C port, TFT, etc...we turn that off before going into light or deep sleep! This will minimize power usage
// SPDX-FileCopyrightText: 2022 Limor Fried for Adafruit Industries // // SPDX-License-Identifier: MIT #include <Adafruit_NeoPixel.h> // While we wait for Feather ESP32 V2 to get added to the Espressif BSP, // we have to select PICO D4 and UNCOMMENT this line! //#define ADAFRUIT_FEATHER_ESP32_V2 // then these pins will be defined for us #if defined(ADAFRUIT_FEATHER_ESP32_V2) or defined(ARDUINO_ADAFRUIT_ITSYBITSY_ESP32) #define PIN_NEOPIXEL 0 #define NEOPIXEL_I2C_POWER 2 #endif #if defined(PIN_NEOPIXEL) Adafruit_NeoPixel pixel(1, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800); #endif void setup() { Serial.begin(115200); // Turn on any internal power switches for TFT, NeoPixels, I2C, etc! enableInternalPower(); } void loop() { LEDon(); delay(1000); disableInternalPower(); LEDoff(); esp_sleep_enable_timer_wakeup(1000000); // 1 sec esp_light_sleep_start(); // we'll wake from light sleep here // wake up 1 second later and then go into deep sleep esp_sleep_enable_timer_wakeup(1000000); // 1 sec esp_deep_sleep_start(); // we never reach here } void LEDon() { #if defined(PIN_NEOPIXEL) pixel.begin(); // INITIALIZE NeoPixel pixel.setBrightness(20); // not so bright pixel.setPixelColor(0, 0xFFFFFF); pixel.show(); #endif } void LEDoff() { #if defined(PIN_NEOPIXEL) pixel.setPixelColor(0, 0x0); pixel.show(); #endif } void enableInternalPower() { #if defined(NEOPIXEL_POWER) pinMode(NEOPIXEL_POWER, OUTPUT); digitalWrite(NEOPIXEL_POWER, HIGH); #endif #if defined(NEOPIXEL_I2C_POWER) pinMode(NEOPIXEL_I2C_POWER, OUTPUT); digitalWrite(NEOPIXEL_I2C_POWER, HIGH); #endif #if defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2) // turn on the I2C power by setting pin to opposite of 'rest state' pinMode(PIN_I2C_POWER, INPUT); delay(1); bool polarity = digitalRead(PIN_I2C_POWER); pinMode(PIN_I2C_POWER, OUTPUT); digitalWrite(PIN_I2C_POWER, !polarity); pinMode(NEOPIXEL_POWER, OUTPUT); digitalWrite(NEOPIXEL_POWER, HIGH); #endif } void disableInternalPower() { #if defined(NEOPIXEL_POWER) pinMode(NEOPIXEL_POWER, OUTPUT); digitalWrite(NEOPIXEL_POWER, LOW); #endif #if defined(NEOPIXEL_I2C_POWER) pinMode(NEOPIXEL_I2C_POWER, OUTPUT); digitalWrite(NEOPIXEL_I2C_POWER, LOW); #endif #if defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2) // turn on the I2C power by setting pin to rest state (off) pinMode(PIN_I2C_POWER, INPUT); pinMode(NEOPIXEL_POWER, OUTPUT); digitalWrite(NEOPIXEL_POWER, LOW); #endif }
The best way to really test power draw is with a specialty power meter such as the Nordic PPK 2
When running the above code and monitoring with a PPK, you'll get a graph like this:
The big pulse is normal mode, you can see the ESP32 booting up, loading code, and then pausing 1 second. Then there's a big drop for one sec to light sleep, and finally one more 1 second pause at deep sleep.
Power Draw for ESP32 Feather V2
The following graphs show the power draw for the ESP32 Feather V2 in normal power mode, light sleep mode, and deep sleep mode.
The power draw, running normally (without WiFi), is 40mA.
The power draw in light sleep mode is 1.1mA.
The power draw in deep sleep mode is 70uA.
Text editor powered by tinymce.