Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ESP32-C3 Modem sleep for always connected application.

Not open for further replies.


Member level 2
Aug 2, 2016
Reaction score
Trophy points
Activity points
I have developed a custom ESP32-C3 board for my home lock. I am using a lithium battery 18650 with 2200mAH. I am poor in coding and started to code from past 2 months.

Well, I need to connected with the WiFi always, as if I press unlock on the blynk app, the motor should rotate to anticlockwise and unlock the door.

My problem is the battery consumption. I am using ESP32-C3-MINI-N4 and for the coding Arduino IDE framework on the VS code studio.

How can I achieve lowest Power consumption on the ESP32 to achieve the low current consumption on the ESP32-C3?

I have already having options to turn off the 5V regulator for motor, having proper hardware structure to lower the consumption.

I am using the WiFimanager and achieved 17-20mA continuous while connected with WiFi.

Here is my code -
#include <Arduino.h>
#include <WiFiManager.h> //
#include <WiFiClientSecure.h>
#include <DNSServer.h>
#include <BlynkSimpleEsp32.h>
#include <Wire.h>
#define debug_en 1
//#define threshold 1000
#define PRINTF_BUF 50
#define StartWordCount 32
#define reconnect_try 1 // How many times the wifi will try to reconenct
#define dooropen_thresshold 3 // not required as of now.
#define batt_sw 22
#define batt_sense_pin 32
#define BATT_VOLT_DIV_R1  10  //kohm
#define BATT_VOLT_DIV_R2  10  //kohm
#define BATT_VOLT_OFFSET  2.25906
#define BATT_AVG_COUNT  60
char auth[] = "##############"; //Sourav Token
//char auth[] = "##########"; //
int reconnect_count = 0;
boolean doorOPEN = false;   // to figure out who woke up the board
boolean firealarm = false;  // to figure out who woke up the board
boolean con_status = false; // to figure out connection establishment
WiFiManager wifiManager;    // for provisioning
char door_State = 0;
int fire_State = 0;
unsigned long previousMillis = 0;
const long interval = 6000; // milli seconds, wait after detecting door is opened.
float voltage = 0; // Variable to keep track of LiPo voltage
void start_wifi_blynk(void);
void release_power(void);
void checkdoor(void);
void check_door_state(void);
void setup()
  start_wifi_blynk(); //Starting the WiFi Facility;
  Serial.println("Applciation Started . . . ");
void loop(){
void start_wifi_blynk(void)
  wifiManager.setTimeout(60); //1min, if can't get connected just go back to sleep
                              // WiFiManager wifiManager;
  Serial.println("connected...yeey :)");
  Serial.println("WiFi Process started");
  if (!wifiManager.autoConnect("dumadum-dum-dum"))
  { // SSID you connect to from browser
#if debug_en
    Serial.println("failed to connect WiFiand hit timeout");
#if debug_en
  Serial.println(""); // WiFi info
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  while (!(con_status = Blynk.connect()))
#if debug_en
    Serial.println("connecting to Blynk Server");
    Serial.println("Reconnecting try -");
#if debug_en
    if (reconnect_count == reconnect_try)
#if debug_en
      Serial.println("Failed to connect Internet. Power is turing OFF");
      Serial.println("Releasing Power");
#if debug_en
  if (con_status)
    Serial.println(" Blynk Connected!");
    Blynk.notify("I am on...");
    //"", "ESP32 Alert", "Connected");
(code tags added by moderator)
Last edited by a moderator:

I think you can try the low power modes (active/light sleep/deep sleep) of ESP32 depending on your application.

I'm doing the same thing but with the ESP-IDF framework.
The biggest issue is that the WiFi does wake up every so often (depending on how you set up the type of sleep and other power save settings) but it does still draw in the low mA region on average.

Maybe Aussie Susan can comment on this. I find with ESP8266 designs that the
time to perform the network association with the router limits how long you can sleep
w/o ignoring user loss of command servicing.

And the ESP32 itself takes 200 - 300 ms startup. Guess is internal clock PLL startup

So "classic" low power designs that achieve the 1 mA or better class of power down
more difficult with this type of design. However the following link does show some
sub mA kinds of sleep performance for some boards designed for that purpose.

Regards, Dana.

Not open for further replies.

Part and Inventory Search

Welcome to