ESP8266 Turn off WiFi to save power

In this tutorial we see how to turn off ESP8266 WiFi, 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.

Turn off ESP8266 WiFi

ESP8266 WiFi Example Code

You control WiFi using wifi.setmode(). ESP8266’s WiFi is very versatile. You can be a client and/or an access point. You can get your IP from DHCP or static.

Per default, ESP8266 start in STATION_AP mode (as client and access point).

wifi.setmode()

Configures the WiFi mode to use. NodeMCU can run in one of four WiFi modes:

  • Station mode (WIFI_STA), where the NodeMCU device joins an existing network
  • Access point (WIFI_AP) mode, where it creates its own network that others can join
  • Station + AP mode (WIFI_AP_STA), where it both creates its own network while at the same time being joined to another existing network
  • WiFi off (WIFI_OFF)

When using the combined Station + AP mode, the same channel will be used for both networks as the radio can only listen on a single channel.

Note

WiFi configuration will be retained until changed even if device is turned off.

Syntax

Results

In below picture you will see Before turning off wifi and after turning off wifi scan results

  1. Before turning WiFi Off it shows ESP_47A070  MAC address last six digits.
  2. After Turning WiFi Off

Leave a Reply