Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Development Boards & SBCs

Microcontroller Sleep Mode: Reduce ESP32 and STM32 Power Use

Microcontroller Sleep Mode: Reduce ESP32 and STM32 Power Use

March 11, 2026 /Posted byJayesh Jain / 0

Implementing microcontroller sleep mode for ESP32 and STM32 power reduction is critical for any battery-powered IoT device. India’s diverse deployment environments — from remote agricultural sensors to urban smart meters — demand months-long battery life. This guide covers all major sleep modes with practical code examples.

Table of Contents

  • Why Sleep Modes Matter for IoT
  • ESP32 Sleep Modes
  • ESP32 Deep Sleep with Wake Sources
  • STM32 Sleep, Stop, and Standby Modes
  • Power Comparison Table
  • Calculating Battery Life
  • Frequently Asked Questions

Why Sleep Modes Matter for IoT

A sensor node sending data every 10 minutes runs active for perhaps 0.5 seconds, then should sleep for 9 minutes 59.5 seconds. If active current is 100 mA and sleep current is 10 µA on ESP32, average current drops to approximately 0.1 mA — extending a 1000 mAh battery from 10 hours to 416 days. Getting ESP32 and STM32 microcontroller sleep mode right is the single biggest factor in battery-powered IoT longevity.

Recommended: 2×18650 Lithium Battery Shield for Arduino ESP32 ESP8266 — 2×18650 Lithium Battery Shield — pairs with ESP32 or STM32 sleep mode projects for robust portable IoT sensor nodes deployable across India.

ESP32 Sleep Modes

ESP32 has several power states:

  • Modem Sleep: CPU active, WiFi/BT radio off. ~20 mA. Good for active processing without communication.
  • Light Sleep: CPU paused, RAM retained, wakes quickly (~2 ms). ~0.8 mA. Ideal for tasks needing fast wake.
  • Deep Sleep: Only RTC and ULP coprocessor active. RAM cleared (except RTC_DATA). ~10–20 µA. Best for long-interval sensor logging.
  • Hibernation: Minimal RTC only. ~2.5 µA. Longest battery life, wakes on external pin only.

ESP32 Deep Sleep with Wake Sources

#include "esp_sleep.h"
#include "driver/rtc_io.h"

// RTC_DATA_ATTR persists across deep sleep
RTC_DATA_ATTR int bootCount = 0;
RTC_DATA_ATTR float lastTemp = 0.0;

void setup() {
  Serial.begin(115200);
  bootCount++;
  
  // Read sensor
  float temp = readTemperature(); // Your sensor function
  lastTemp = temp;
  
  // Upload if significant change
  if (abs(temp - lastTemp) > 0.5) {
    connectWiFiAndUpload(temp);
  }
  
  // Timer wake-up: wake after 10 minutes
  esp_sleep_enable_timer_wakeup(10 * 60 * 1000000ULL); // microseconds
  
  // GPIO wake-up: wake on button press (GPIO 33)
  esp_sleep_enable_ext0_wakeup(GPIO_NUM_33, 0); // 0 = LOW trigger
  
  Serial.println("Entering deep sleep...");
  Serial.flush();
  esp_deep_sleep_start();
}

void loop() {} // Never reached in deep sleep design
Recommended: ESP32-WROOM-32E Development Board Module for Arduino — ESP32-WROOM-32E — the best platform for deep sleep IoT applications, achieving 10–20 µA sleep current for months-long battery operation.

STM32 Sleep, Stop, and Standby Modes

STM32 offers three main low-power modes:

  • Sleep Mode: Core clock stopped, peripherals running. ~1–3 mA on STM32F4. Wake by any interrupt.
  • Stop Mode: All clocks stopped, HSI/HSE off, SRAM/register content retained. ~2–100 µA depending on settings. Wake by EXTI or RTC alarm.
  • Standby Mode: Almost everything off, only WKUP pin/RTC active. ~2–5 µA. SRAM content lost.
/* STM32 Stop Mode 2 entry (STM32L4 series, lowest power) */
#include "stm32l4xx_hal.h"

void enterStopMode(uint32_t seconds) {
  // Configure RTC wakeup
  HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, seconds, RTC_WAKEUPCLOCK_CK_SPRE_16BITS);
  
  // Enter Stop Mode 2 (0.4 µA on STM32L4)
  HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
  
  // Wake here - restore clocks
  SystemClock_Config();
  HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
}

Power Comparison Table

Mode ESP32 STM32F4 STM32L4
Active (WiFi TX) 160–260 mA 100 mA 40 mA
Active (CPU only) 50–80 mA 100 mA 10 mA
Light Sleep 0.8 mA 1–2 mA 0.5 mA
Deep Sleep / Stop 2 10–20 µA ~100 µA 0.4 µA
Standby / Shutdown 2.5 µA 2 µA 0.03 µA
Recommended: 4×18650 Lithium Battery Shield V8 V9 for Arduino ESP32 ESP8266 — 4×18650 Battery Shield for ESP32 — for long-term IoT deployments in India, 4×18650 at 10,000+ mAh combined provides year-long operation with deep sleep.

Calculating Battery Life

Formula: Battery Life (hours) = Battery Capacity (mAh) / Average Current (mA)

Example: ESP32 wakes every 15 minutes, active 2 seconds (50 mA average), then deep sleeps (20 µA):

  • Active duty: 2s / 900s = 0.22%
  • Average current: (0.0022 × 50) + (0.9978 × 0.02) = 0.11 + 0.02 = 0.13 mA
  • With 3000 mAh battery: 3000 / 0.13 = 23,077 hours ≈ 963 days ≈ 2.6 years

Frequently Asked Questions

Does deep sleep on ESP32 lose WiFi connection?

Yes. Deep sleep powers off the WiFi radio. The ESP32 reconnects to WiFi on waking. Use esp_wifi_set_ps() for modem sleep to maintain connection at the cost of higher current.

Can I retain variable values across ESP32 deep sleep?

Yes. Declare variables with RTC_DATA_ATTR — they are stored in RTC slow memory (8 KB) which is powered during deep sleep.

Which STM32 series is best for battery-powered IoT in India?

STM32L4 series (ultra-low power) — designed specifically for battery-powered IoT with 0.4 µA Stop 2 current and smart peripherals that work without waking the CPU.

Shop Development Boards & SBCs at Zbotic →

Tags: battery IoT India, ESP32 Deep Sleep, ESP32 sleep mode, low power embedded, microcontroller sleep, STM32 low power
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Fingerprint Sensor AS608: Door...
blog fingerprint sensor as608 door lock access with arduino 599013
blog monocrystalline vs polycrystalline solar panel india guide 599018
Monocrystalline vs Polycrystal...

Related posts

Svg%3E
Read more

Battery Charger Module TP4056: LiPo and 18650 Charging Guide

April 1, 2026 0
The TP4056 battery charger module is one of the most essential components for any battery-powered electronics project. Costing under ₹30,... Continue reading
Svg%3E
Read more

Buck Converter vs Boost Converter: Voltage Regulation Guide

April 1, 2026 0
Understanding buck converters vs boost converters is essential for every electronics project involving power management. Whether you are stepping down... Continue reading
Svg%3E
Read more

Google Coral TPU: Accelerating AI Projects on Raspberry Pi

April 1, 2026 0
The Google Coral TPU (Tensor Processing Unit) transforms a Raspberry Pi from a sluggish AI hobbyist tool into a real-time... Continue reading
Svg%3E
Read more

NVIDIA Jetson Nano Projects India: Getting Started Guide

April 1, 2026 0
The NVIDIA Jetson Nano is the most accessible GPU-accelerated AI computer for developers in India. With 128 CUDA cores, a... Continue reading
Svg%3E
Read more

ATtiny85 Projects: Tiny Microcontroller for Space-Constrained Builds

April 1, 2026 0
The ATtiny85 is the Swiss Army knife of tiny microcontrollers — just 8 pins, 8 KB of flash, and a... Continue reading

Add comment Cancel reply

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

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now