STM32 power saving: sleep, deep sleep, shutdown, and power consumption – 5

Spread the love

STM32 power saving: sleep, deep sleep, shutdown and power consumption
STM32 power saving: sleep, deep sleep, shutdown and power consumption

We have already described Idle mode and the relative power consumption, in this article we continue to measure power consumption of other sleep modes to have a brief comparison.

Wiring for our tests

We are going to use ST-Link to program and power the STM32, but we are going to put in the middle of the 3v3 pin of ST-Link V2 and 3.3v of the STM32 a multimeter to measure the amperage to analyze the power consumption.

Here the STM32 and ST-Link V2 used in this test STM32F103C8T6 STM32F401 STM32F411 ST-Link v2 ST-Link v2 official

Here the FTDI USB to TTL CH340G - USB to TTL FT232RL


Here my multimeter Aneng SZ18

To get the Serial output we use an external FTDI with only GND and Tx from STM32 to Rx of FTDI connected.

STM32F1 and Serial to debug

STM32: programming via ST-Link, Serial debug via FTDI, and Amperage check on breadboard
STM32: programming via ST-Link, Serial debug via FTDI, and Amperage check on breadboard

STM32F1 and Serial2 to debug

STM32: programming via ST-Link, Serial2 debug via FTDI, and Amperage check on breadboard
STM32: programming via ST-Link, Serial2 debug via FTDI, and Amperage check on breadboard

STM32F4 and Serial to debug

STM32F4 black pill and ST-Link: Serial debug via FTDI with Amperage check
STM32F4 black pill and ST-Link: Serial debug via FTDI with Amperage check

STM32F4 and Serial2 to debug

STM32F4 black pill and ST-Link: Serial2 debug via FTDI with Amperage check
STM32F4 black pill and ST-Link: Serial2 debug via FTDI with Amperage check

Wake up with internal interrupt managed by RTC

Sleep

STM32F1 blue pill: power saving with frequencies management
STM32F1 blue pill: power saving with frequencies management

The Sleep status is the Low-Power Sleep mode equivalent in the ST framework. Respect the previous example, and the regulator is placed into low power mode.

STM32F1

The first device we use is an STM

/**
 *	STM32 Low Power Sleep wake up test from RTC
 *
 * 	This sketch demonstrates the usage of Internal Interrupts to wakeup a chip
 *	in Sleep mode.
 *
 *	In this sketch, the internal RTC will wake up the processor.
 *
 *	Renzo Mischianti <www.mischianti.org>
 * en: https://mischianti.org/category/tutorial/stm32-tutorial/
 * it: https://mischianti.org/it/category/guide/guida-alla-linea-di-microcontrollori-stm32/
 */

#include "STM32LowPower.h"

// If you use generic STM32F103C8
// you don't need this explicit declaration
// This is needed by bluepill specified version
//HardwareSerial Serial(USART2);   // PA3  (RX)  PA2  (TX)

void setup() {
	Serial.begin(115200);
	while (!Serial){ delay(100); }
	Serial.println("START!");

	// Configure low power
	LowPower.begin();
}

void loop() {
	Serial.print("Entering sleep in ");
	for (int i=5; i>0; i--) {Serial.print(i);Serial.print(" ");delay(500);}
	Serial.println();
	delay(100); // Needed to give the time to write on Serial
	LowPower.sleep(5000); // Entering in sleep

	delay(100); // Needed to restore the Serial
	Serial.print("Wake for 10 seconds! ");
	for (int i=10; i>0; i--) {Serial.print(i);Serial.print(" ");delay(1000);}
	Serial.println();
}

The Serial output is:

START!
Entering sleep in 5 4 3 2 1 
Wake for 10 seconds! 10 9 8 7 6 5 4 3 2 1 
Entering sleep in 5 4 3 2 1 
Wake for 10 seconds! 10 9 8 7 6 5 4 3 2 1 
Entering sleep in 5 4 3 2 1 

When entering Sleep, the power consumption from 17.50mAh goes down to 9.35mAh like the Sleep.

STM32F401

STM32F401CC black pill: configuration for low power test on Sloeber
STM32F401CC black pill: configuration for low power test on Sloeber

The same sketch in the STM32F401CC Black-Pill from 23.50mAh obtain the same result of Idle, 7.55mAh.

STM32F411

The same sketch in the STM32F411CE Black-Pill from 32.50mAh obtain the same result of Idle, 10.90mAh.

Deep Sleep

In DeepSleep (or Stop mode for ST Framework), some clocks are turned off, and only a minimal set of peripherals is in working mode.

STM32F1

Here is the code for my STM32F103C8 Blue pill

/**
 *	STM32 Low Power Deep Sleep wake up test from RTC
 *
 * 	This sketch demonstrates the usage of Internal Interrupts to wakeup a chip
 *	in DeepSleep mode.
 *
 *	In this sketch, the internal RTC will wake up the processor.
 *
 *	Renzo Mischianti <www.mischianti.org>
 * en: https://mischianti.org/category/tutorial/stm32-tutorial/
 * it: https://mischianti.org/it/category/guide/guida-alla-linea-di-microcontrollori-stm32/
 */

#include "STM32LowPower.h"

// If you use generic STM32F103C8
// you don't need this explicit declaration
// This is needed by bluepill specified version
//HardwareSerial Serial(USART2);   // PA3  (RX)  PA2  (TX)

void setup() {
	Serial.begin(115200);
	while (!Serial){ delay(100); }
	Serial.println("START!");

	// Configure low power
	LowPower.begin();
}

void loop() {
	Serial.print("Entering deep sleep in ");
	for (int i=5; i>0; i--) {Serial.print(i);Serial.print(" ");delay(500);}
	Serial.println();
	delay(100); // Needed to give the time to write on Serial
	LowPower.deepSleep(5000); // Entering in deep sleep

	delay(100); // Needed to restore the Serial
	Serial.print("Wake for 10 seconds! ");
	for (int i=10; i>0; i--) {Serial.print(i);Serial.print(" ");delay(1000);}
	Serial.println();
}

Here is the Serial output:

START!
Entering deep sleep in 5 4 3 2 1 
Wake for 10 seconds! 10 9 8 7 6 5 4 3 2 1 
Entering deep sleep in 5 4 3 2 1 
Wake for 10 seconds! 10 9 8 7 6 5 4 3 2 1 

Now the power consumption has a consistent change, and we get 1.914mAh.

STM32F401

The same sketch in the STM32F401CC Black-Pill from 24.48mAh obtain the result of 1.63mAh.

STM32F411

The same sketch in the STM32F401CC Black-Pill from 32.48mAh obtain the result of 6.56mAh.

Shutdown

As already described, shutdown (Standby) is simple to explain, the only oscillators available are the LSI and LSE, and the only peripherals that can function are the RTC and IWDG.

We do a minor change to the example sketch, and I put the wait before the shutdown because we must remember that when It wakes from this state, the device completely reboots and restart from the beginning (setup()).

STM32F1

We are going to start with the Blue-Pill as usual.

/**
 *	STM32 Low Power shutdown wake up test from RTC
 *
 * 	This sketch demonstrates the usage of Internal Interrupts to wakeup a chip
 *	in shutdown mode.
 *
 *	In this sketch, the internal RTC will wake up the processor.
 *
 *	Renzo Mischianti <www.mischianti.org>
 * en: https://mischianti.org/category/tutorial/stm32-tutorial/
 * it: https://mischianti.org/it/category/guide/guida-alla-linea-di-microcontrollori-stm32/
 */

#include "STM32LowPower.h"

// If you use generic STM32F103C8
// you don't need this explicit declaration
// This is needed by bluepill specified version
//HardwareSerial Serial(USART2);   // PA3  (RX)  PA2  (TX)

void setup() {
	Serial.begin(115200);
	while (!Serial){ delay(100); }
	Serial.println("START!");

	// Configure low power
	LowPower.begin();
}

void loop() {
	delay(100); // Needed to restore the Serial
	Serial.print("Wake for 10 seconds! ");
	for (int i=10; i>0; i--) {Serial.print(i);Serial.print(" ");delay(1000);}
	Serial.println();

	Serial.print("Entering shutdown in ");
	for (int i=5; i>0; i--) {Serial.print(i);Serial.print(" ");delay(500);}
	Serial.println();
	delay(100); // Needed to give the time to write on Serial
	LowPower.shutdown(5000); // Entering in shutdown

}

Also, the serial output has a new structure.

START!
Wake for 10 seconds! 10 9 8 7 6 5 4 3 2 1 
Entering shutdown in 5 4 3 2 1 
START!
Wake for 10 seconds! 10 9 8 7 6 5 4 3 2 1 
Entering shutdown in 5 4 3 2 1 

As you can see, every wake the START! string is written. And the power consumption goes down to 1.780mAh.

STM32F401

Also for this, every wake the START! string is written. And the power consumption goes down to 0.31mAh.

STM32F411

Also for this, every wake the START! string is written. And the power consumption goes down to 4.67mAh.

Comparison table

The results are as expected, now, we are going to resume in a table.

STM32F1 manage frequencies: clock diagram
STM32F1 manage frequencies: clock diagram

You must remember that we analyze the prototype board not only the chip STM32, so there is some additional power consumption like led and additional external clock.

ModeSTM32F1STM32F401STM32F411
Idle9.37mAh7.55mAh11.05mAh
Sleep9.35mAh7.55mAh10.90mAh
Deep Sleep1.914mAh1.63mAh6.56mAh
Shutdown1.780mAh0.31mAh4.67mAh

The first thing you can understand is that in RTC wake the Low power voltage regulator does not offer a real advantage, but remember in Low power sleep you can disable selectively the peripheral, and, if you don’t need to gain other milliamperes, the DeepSleep is preferable to Shutdown so you don’t lose the memory data and the device is not restarted.

You can notice also that STM32F401 offers the best low-power performance, for the other device, you must work also over peripherals and frequencies.

Thanks

  1. STM32F1 Blue-Pill: pinout, specs, and Arduino IDE configuration (STM32duino and STMicroelectronics)
  2. STM32: program (STM32F1) via USB with STM32duino bootloader
  3. STM32: programming (STM32F1 STM32F4) via USB with HID boot-loader
  4. STM32F4 Black-Pill: pinout, specs, and Arduino IDE configuration
  5. STM32: ethernet w5500 with plain HTTP and SSL (HTTPS)
  6. STM32: ethernet enc28j60 with plain HTTP and SSL (HTTPS)
  7. STM32: WiFiNINA with ESP32 WiFi Co-Processor
    1. STM32F1 Blue-pill: WiFi shield (WiFiNINA)
    2. STM32F4 Black-pill: WiFi shield (WiFiNINA)
  8. How to use SD card with stm32 and SdFat library
  9. \STM32: SPI flash memory FAT FS
  10. STM32: internal RTC, clock, and battery backup (VBAT)
  11. STM32 LoRa
    1. Unleashing IoT Potential: Integrating STM32F1 Blue-Pill with EByte LoRa E32, E22, and E220 Shields
    2. Unleashing IoT Potential: Integrating STM32F4 Black-Pill with EByte LoRa E32, E22, and E220 Shields
  1. STM32 Power saving
    1. STM32F1 Blue-Pill clock and frequency management
    2. STM32F4 Black-Pill clock and frequency management
    3. Intro and Arduino vs STM framework
    4. Library LowPower, wiring, and Idle (STM Sleep) mode
    5. Sleep, deep sleep, shutdown, and power consumption
    6. Wake up from RTC alarm and Serial
    7. Wake up from the external source
    8. Backup domain intro and variable preservation across reset
    9. RTC backup register and SRAM preservation
  2. STM32 send emails with attachments and SSL (like Gmail): w5500, enc28j60, SD, and SPI Fash

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *