Page 2 of 3

Re: Saving power

Posted: Mon Mar 27, 2017 6:02 am
by pythoncoder
To disable WiFi you need the following:

Code: Select all

import network
ap = network.WLAN(network.AP_IF)
ap.active(False)  # Disable access point
sta_if = network.WLAN(network.STA_IF)
sta_if.active(False)  # Disable station interface

Re: Saving power

Posted: Mon Mar 27, 2017 9:23 am
by Roberthh
Without wanting to be pedantic (but being so) it should be noted, that disabling WiFi this way does not reduce power consumption much. It still stays at about 80 mA.

Re: Saving power

Posted: Mon Mar 27, 2017 7:19 pm
by kfricke
The ESP8266 radio can be turned off, but it is not implemented. It is a startup flag and switching this involves rebooting the MCU completely.

Re: Saving power

Posted: Thu Jul 13, 2017 2:06 pm
by mhepp
Hi all,

is there an update on this? I can see many applications that do either not need wifi at all, or only for a small fraction of their duty cycle, so reducing power by the various sleep modes does not really help. Think of a sensor that will collect data over an hour or so and post only averages to a server once for each interval.

Martin

Re: Saving power

Posted: Wed Oct 18, 2017 2:17 am
by swanduron
The ESP8266 has provided a deep sleep mode which has been implemented in micropython power management. Please see the document as below:

https://docs.micropython.org/en/latest/ ... rctrl.html

I write a demo for my IoT project, the sensor has a ESP8266 and one DHT22 sensor and the size of sensor's shell only about 60mm * 25mm * 10mm. To avoid the impact of DHT22 result, I put ESP8266 in deep sleep mode every ~70s. Paste code as below, I hope it is useful to you.

In additional, I test this code both in Aruba AP205 and Cisco WLC2504 with 3702i, they can hold the wifi association for this module during deep sleep and ESP8266 can get its network info in 1 second.

CAUTION: Please read below info carefully

The deep-sleep mode will shut down the ESP8266 and all its peripherals, including the WiFi (but not including the real-time-clock, which is used to wake the chip). This drastically reduces current consumption and is a good way to make devices that can run for a while on a battery.
To be able to use the deep-sleep feature you must connect GPIO16 to the reset pin (RST on the Adafruit Feather HUZZAH board).


Code: Select all

import machine
import network
import time
rtc = machine.RTC()
rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)
rtc.alarm(rtc.ALARM0, 90000)
time.sleep(2)

if machine.reset_cause() == machine.DEEPSLEEP_RESET:
    print('woke from a deep sleep')
else:
    print('power on or hard reset')

sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)

if sta_if.isconnected():
	print('Wireless association is reserved!')
	print(sta_if.ifconfig())
else:
	sta_if.connect('XXXXXXX', 'XXXXXXXX')
	time.sleep(2)
	print(sta_if.ifconfig())


for i in range(10): #for wake test here
	time.sleep(1)
	print('Before deep sleep, system working in [%s] seconds' % i)

print('Prepare to sleep in 2s')
time.sleep(2)
machine.deepsleep()

Re: Saving power

Posted: Sun Oct 21, 2018 11:23 pm
by devnull
Has there been any change in the ability to completely switch off the wifi radio on the esp8266 ?

Re: Saving power

Posted: Mon Oct 22, 2018 1:03 am
by WhiteHare
Regarding the OP, if you're serious about wanting to run low power, you're better off switching to a platform like, for example, the nRF52, that's designed from the ground up to be low power. Use the ESPx's as gateways instead.

Re: Saving power

Posted: Mon Oct 22, 2018 2:28 am
by devnull
@WhiteHare - Thanks, I have just ordered a few nRF52840 from seeed for testing.

I see there's a list of things that are working in the nrf port readme, but do you know specifically what is NOT working :-)

I presume that the radio can be completely disabled ?

Re: Saving power

Posted: Mon Oct 22, 2018 4:15 am
by WhiteHare
devnull wrote:
Mon Oct 22, 2018 2:28 am
I presume that the radio can be completely disabled ?
yes.

Re: Saving power

Posted: Mon Oct 22, 2018 11:54 am
by WhiteHare
Of course, depending on what you want to do, there is this (or similar) as a way to save power and still use an ESPx:
https://www.tindie.com/products/kdcircu ... -platform/

So, for instance, if you were making a water leak detector, maybe this would be good enough. In that case it would only need to wake up in the rare event of a water leak and perhaps to give you a heartbeat once every two hours to report on its battery level. The rest of the time it would simply be turned completely OFF (i.e. including full loss of RAM contents), during which time the hardware would be drawing mere nanoamps. It's admittedly a rather brute force way to address the issue, but, meh, if it fits your use case, maybe you'd want to consider it.