Disabling WiFi on the ESP-01S for Power Saving

Hello, I'm working on a project that uses the ESP-01S WiFi module, and I'm looking for a way to conserve power by turning off WiFi. Since I will never use WiFi, it can be completely turned off, no need for "WiFi wakeup" (if such a thing exists). Correct me if I'm wrong, I found "Modem-Sleep" mode, in which the WiFi modem is off but the CPU and other peripherals are still running.
What is the best way to do this? Any help and guidance would be greatly appreciated, thanks!

I think this should work:

Command to disable WiFi to save power · Issue #460 · esp8266/Arduino · GitHub

/*
    Sketch uses 223,380 bytes (21%) of program storage space. Maximum is 1,044,464 bytes.
    Global variables use 31,625 bytes (38%) of dynamic memory, leaving 50,295 bytes for local variables. Maximum is 81,920 bytes.
 */

#include <ESP8266WiFi.h>


void setup() {                
  WiFiMode(WIFI_STA);
  WiFi.disconnect(); 
  WiFi.mode(WIFI_OFF);
  delay(100);
}


void loop() {
}

Added:
Useful reference:
Welcome to ESP8266 Arduino Core’s documentation! — ESP8266 Arduino Core documentation (arduino-esp8266.readthedocs.io)

2 Likes

Thank you for this!

Saw here post by nseidle, he used this line

WiFi.forceSleepBegin(sleepTime * 1000000L);

What does it do, and do I need to use it?

One can easily Google (or Bing) this one!

ESP8266 + WiFi.forceSleepBegin - Search (bing.com)

But, for readers who need an immediate answer:

There are two methods to turn off wifi first is to use simple ESP8266WiFi.h Library and use WiFi.mode(WIFI_OFF); and another method to use WiFi.forceSleepBegin(); By turning wifi off you can save some power. or using only (WIFI_STA) station mode you can hide ESPs own Access point.

2 Likes

I'm a newbie, so please bear with me. Is it necessary to use both lines or is one sufficient, and if so which one should I use? What is the difference between them?

I'm a Crotchety Old Man; pretend you are the WiFi electronics:

  • WiFi.mode(WIFI_OFF);
    -- I remove your power (no life)
  • WiFi.forceSleepBegin();
    -- I put you to sleep for a period of time (you will wake)
2 Likes

As an WiFi electronic, I should remove your power! Right?

(obviously, I know the answer, just wondering if you do as well :thinking:)

You put your cell phone in airplane mode..... Does the phone shut off? No, it just shuts OFF the WiFi, BT chips.

SAME!!!!!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.