STM32F103C8T6 Ultra-Low Power Modes – Deep Sleep & Standby
Complete guide to ultra-low power operation for STM32F103C8T6 (Blue Pill) – Stop Mode (50-500µA) and Standby Mode (2µA).
Overview
The STM32F103C8T6 (Blue Pill) is a powerful ARM Cortex-M3 microcontroller, but it consumes 10-20mA in active mode – too high for battery-powered projects. Fortunately, the STM32 offers several low-power modes:
- Sleep Mode – CPU stops, peripherals continue.
- Stop Mode (Deep Sleep) – Almost everything halts, RAM retained, current ~50-500µA.
- Standby Mode – Ultra-low power (~2µA), RAM lost, reset on wake.
This page documents how to achieve ultra-low power consumption for the Blue Pill, including hardware optimisations, software configurations, and wake-up strategies.
Architecture
Power Mode Comparison
| Mode | CPU | Peripherals | RAM | RTC | Wake Sources | Current |
|---|---|---|---|---|---|---|
| Active | Running | On | Retained | Optional | – | 10-20mA |
| Sleep | Off | On | Retained | Optional | Any interrupt | 2-5mA |
| Stop (Deep Sleep) | Off | Off (except RTC) | Retained | Optional | External interrupt, RTC | 50-500µA |
| Standby | Off | Off | Lost | Optional | PA0 (WKUP), RTC alarm | ~2µA |
Hardware Optimizations
1. Turn Off PC13 LED
The Blue Pill has a built-in LED on PC13. It draws current even in sleep modes if left on.
pinMode(PC13, OUTPUT);
digitalWrite(PC13, HIGH); // Turn off LED (active LOW)
2. Bypass the AMS1117 Voltage Regulator
The onboard AMS1117-3.3V regulator consumes ~5-10mA continuously. Power the board via 3.3V directly to VCC to bypass it.
[Blue Pill] ┌─────────────┐ │ VCC (3.3V) │ ← Power directly with 3.3V (bypass regulator) │ GND │ └─────────────┘
3. Disconnect USB-to-Serial Chip
If powered via USB, the CH340/CP2102 consumes ~2-10mA. For low-power operation, power externally and disconnect USB.
4. Disable Internal Pull-ups
Unused I/O pins with internal pull-ups may draw current. Configure them as analog inputs before sleep:
// Disable pull-ups on unused pins
pinMode(PB7, INPUT_ANALOG); // Example
pinMode(PB6, INPUT_ANALOG);
5. Cut Power to External Sensors
Use a MOSFET to disconnect power to external peripherals (sensors, displays, etc.) before entering sleep.
Stop Mode (Deep Sleep) – RAM Retained
Stop Mode is ideal when you need to retain RAM and resume quickly.
Example: Stop Mode with RTC Wake-Up (5 seconds)
#include <STM32LowPower.h>
#define LED PC13
void setup() {
Serial.begin(9600);
delay(1000);
// Turn off LED
pinMode(LED, OUTPUT);
digitalWrite(LED, HIGH);
Serial.println("Going to Deep Sleep...");
delay(1000);
LowPower.begin();
LowPower.deepSleep(5000); // Sleep for 5 seconds
}
void loop() {
Serial.println("Woke up from Deep Sleep!");
digitalWrite(LED, LOW);
delay(2000);
digitalWrite(LED, HIGH);
delay(500);
}
Power Consumption: ~50-500µA (depending on peripherals and clock).
Standby Mode – Ultra Low Power (~2µA)
Standby Mode is the lowest power mode, consuming only ~2µA. However:
- RAM is lost – variables are reset.
- MCU resets on wake – execution starts from
setup(). - Only PA0 (WKUP) and RTC alarm can wake the MCU.
Example 1: Standby Mode with PA0 Button Wake-Up
#include <STM32LowPower.h>
#define WAKEUP_PIN PA0 // Connect button from PA0 to GND
void setup() {
Serial.begin(9600);
delay(1000);
pinMode(WAKEUP_PIN, INPUT_PULLUP);
Serial.println("Entering Standby Mode in 3 seconds...");
delay(3000);
LowPower.begin();
LowPower.enableWakeupFrom(WAKEUP_PIN, FALLING); // Wake on button press
LowPower.standby(); // Enter Standby (MCU resets on wake)
}
void loop() {
Serial.println("Woke up from Standby!");
delay(2000);
}
Wiring: Connect a button between PA0 and GND. Internal pull-up is enabled.
Example 2: Standby Mode with RTC Alarm Wake-Up
#include <STM32LowPower.h>
#define WAKEUP_PIN PA0
void setup() {
Serial.begin(9600);
delay(1000);
pinMode(WAKEUP_PIN, INPUT_PULLUP);
Serial.println("Entering Standby Mode in 3 seconds...");
delay(3000);
LowPower.begin();
// Enable both RTC alarm and external wake-up
LowPower.enableWakeupFrom(RTC_ALARM);
LowPower.enableWakeupFrom(WAKEUP_PIN, FALLING);
// Standby for 10 seconds OR until button press
LowPower.standby(10000);
}
void loop() {
Serial.println("Woke up from Standby!");
delay(2000);
}
Complete Deep Sleep with RTC & External Interrupt
If you need RAM retention and flexible wake sources, use Stop Mode with both RTC and external interrupts:
#include <STM32LowPower.h>
#define WAKEUP_PIN PA0
#define LED PC13
void setup() {
Serial.begin(9600);
delay(1000);
pinMode(LED, OUTPUT);
digitalWrite(LED, HIGH);
pinMode(WAKEUP_PIN, INPUT_PULLUP);
attachInterrupt(WAKEUP_PIN, wakeUp, FALLING);
Serial.println("Going to Deep Sleep...");
delay(2000);
LowPower.begin();
LowPower.deepSleep(5000); // Sleep 5s or until interrupt
}
void loop() {
Serial.println("Woke up from Deep Sleep!");
digitalWrite(LED, LOW);
delay(2000);
digitalWrite(LED, HIGH);
delay(500);
}
void wakeUp() {
// Empty ISR – just wakes the MCU
}
Power Consumption Results
| Condition | Current |
|---|---|
| Normal Running (LED ON, USB connected, AMS1117) | 10-20mA |
| Deep Sleep (LED OFF, USB disconnected) | 50-500µA |
| Optimized Standby (LED OFF, bypass regulator, no USB) | ~2µA |
Battery Life Estimate (1000mAh LiPo)
| Mode | Current | Estimated Life |
|---|---|---|
| Active | 15mA | 67 hours |
| Deep Sleep | 100µA | 10,000 hours (~1.1 years) |
| Standby | 2µA | 500,000 hours (~57 years) |
Key Achievements
- ✅ Stop Mode – 50-500µA with RAM retention.
- ✅ Standby Mode – 2µA ultra-low power.
- ✅ Multiple wake sources – PA0 button, RTC alarm, external interrupts.
- ✅ Hardware optimizations – LED off, regulator bypass, USB disconnect.
- ✅ Production-ready – Code tested on Blue Pill with STM32Duino core.
Technology Stack
| Category | Technology |
|---|---|
| MCU | STM32F103C8T6 (Blue Pill) |
| Core | STM32Duino (Arduino IDE) |
| Library | STM32LowPower |
| Wake Sources | PA0 (WKUP), RTC Alarm, External Interrupts |
| Power Supply | 3.3V (direct to VCC) |
Related Projects
- Embedded Systems Engineering – Main embedded systems page.
- Arduino Pro Mini Ultra-Low Power – Similar power optimization.
- Arduino Server-Side Compiler – STM32 support included.
This STM32 low-power guide is part of my broader Embedded Systems Engineering practice. For a detailed technical walkthrough or custom battery-powered design, feel free to reach out.