Hi everybody,
I've installed micropython on esp32 and it's functioning properly. I'd like to reduce the power consumed so I can power the boards from a battery. I've seen a few posts that try to address the same problem on ESP8266 but I didn't see a clear conclusion. Is there a way to turn off wifi, like duty cycle it. It can turn on every minute, send some data then turn off
also is there a way to reduce the overall cpu power consumption, I probably have to recompile the image with different clock settings
thanks a lot!
ESP32 power reduction for battery powered
Re: ESP32 power reduction for battery powered
The ESP32 has a deepsleep mode in which you can achieve (with carefully designed board) minimal consumption of only 5 uA if powering directly from LiFePO4 battery.
ESP32 can wake up from deepsleep by timer, external wakeup 0 & 1 (pin level), touchpad (touch sensor interrupt) and ULP coprocessor wakeup.
There is also RTC slow memory which will retain variables content during deepsleep.
After boot up the software can determine the wake up reason and continue program execution accordingly.
The first 3 wake up sources are supported in my MicroPython implementation, the rest will be supported later.
If lowering the cpu speed will result in lower power consumption, depends on the usage scenario. Dynamic cpu speed change is not yet available in esp-idf, but it is expected to be available soon.
I have used deepsleep method with MicroPython in battery powered system with quite satisfactory results.
ESP32 can wake up from deepsleep by timer, external wakeup 0 & 1 (pin level), touchpad (touch sensor interrupt) and ULP coprocessor wakeup.
There is also RTC slow memory which will retain variables content during deepsleep.
After boot up the software can determine the wake up reason and continue program execution accordingly.
The first 3 wake up sources are supported in my MicroPython implementation, the rest will be supported later.
If lowering the cpu speed will result in lower power consumption, depends on the usage scenario. Dynamic cpu speed change is not yet available in esp-idf, but it is expected to be available soon.
I have used deepsleep method with MicroPython in battery powered system with quite satisfactory results.
Re: ESP32 power reduction for battery powered
thanks a lot @loboris, I will definitely test it out
Re: ESP32 power reduction for battery powered
Would you share what needs to happen on the board in order to implement deep sleep? I was looking at this site;loboris wrote:The ESP32 has a deepsleep mode in which you can achieve (with carefully designed board) minimal consumption of only 5 uA if powering directly from LiFePO4 battery.
http://www.instructables.com/id/ESP32-Deep-Sleep/
It describes various deep sleep modes but I am not sure which of them have been implemented in Python for the ESP32. I see "wake-up by an external source" being described in step 5. This appears to simply require a state transition on GPIO36 (RTC_GPIO00). Is there more to it than that? What code will implement the sleep? Is it similar to this?
https://docs.micropython.org/en/latest/ ... sleep-mode
Re: ESP32 power reduction for battery powered
Using deepsleep mode is quite simple (some boot up messages are omitted):
ESP32 is powered on:
FreeRTOS running on BOTH CORES, MicroPython task started on App Core.
uPY stack size = 19456 bytes
uPY heap size = 81920 bytes
Reset reason: Power on reset Wakeup: Power on wake
MicroPython ESP32_LoBo_v2.0.4 - 2017-10-08 on ESP32 board with ESP32
Type "help()" for more information.
Configure wake up from deepsleep on low level on pin #27:
>>> import machine
>>> pin=machine.Pin(27)
>>> pin.init(mode=pin.IN, pull=pin.PULL_UP)
>>> rtc=machine.RTC()
>>> rtc.wake_on_ext0(pin, 0)
>>> machine.deepsleep(0)
ESP32: DEEP SLEEP
ESP32 is now in deepsleep mode. To wake it up we must pull the pin #27 low, then ESP32 wakes up:
FreeRTOS running on BOTH CORES, MicroPython task started on App Core.
uPY stack size = 19456 bytes
uPY heap size = 81920 bytes
Reset reason: Deepsleep reset Wakeup: GPIO wake
MicroPython ESP32_LoBo_v2.0.4 - 2017-10-08 on ESP32 board with ESP32
Type "help()" for more information.
>>> import machine
>>> machine.wake_reason()
(1, 3)
>>> machine.wake_description()
('Deepsleep reset', 'GPIO wake')
>>>
Enter deepsleep and wake up after 30 seconds:
>>> import machine
>>> machine.deepsleep(30000)
ESP32: DEEP SLEEP
ESP32 is now in deepsleep mode. It wakes up after 30 seconds:
FreeRTOS running on BOTH CORES, MicroPython task started on App Core.
uPY stack size = 19456 bytes
uPY heap size = 81920 bytes
Reset reason: Deepsleep reset Wakeup: RTC wake
MicroPython ESP32_LoBo_v2.0.4 - 2017-10-08 on ESP32 board with ESP32
Type "help()" for more information.
ESP32 is powered on:
FreeRTOS running on BOTH CORES, MicroPython task started on App Core.
uPY stack size = 19456 bytes
uPY heap size = 81920 bytes
Reset reason: Power on reset Wakeup: Power on wake
MicroPython ESP32_LoBo_v2.0.4 - 2017-10-08 on ESP32 board with ESP32
Type "help()" for more information.
Configure wake up from deepsleep on low level on pin #27:
>>> import machine
>>> pin=machine.Pin(27)
>>> pin.init(mode=pin.IN, pull=pin.PULL_UP)
>>> rtc=machine.RTC()
>>> rtc.wake_on_ext0(pin, 0)
>>> machine.deepsleep(0)
ESP32: DEEP SLEEP
ESP32 is now in deepsleep mode. To wake it up we must pull the pin #27 low, then ESP32 wakes up:
FreeRTOS running on BOTH CORES, MicroPython task started on App Core.
uPY stack size = 19456 bytes
uPY heap size = 81920 bytes
Reset reason: Deepsleep reset Wakeup: GPIO wake
MicroPython ESP32_LoBo_v2.0.4 - 2017-10-08 on ESP32 board with ESP32
Type "help()" for more information.
>>> import machine
>>> machine.wake_reason()
(1, 3)
>>> machine.wake_description()
('Deepsleep reset', 'GPIO wake')
>>>
Enter deepsleep and wake up after 30 seconds:
>>> import machine
>>> machine.deepsleep(30000)
ESP32: DEEP SLEEP
ESP32 is now in deepsleep mode. It wakes up after 30 seconds:
FreeRTOS running on BOTH CORES, MicroPython task started on App Core.
uPY stack size = 19456 bytes
uPY heap size = 81920 bytes
Reset reason: Deepsleep reset Wakeup: RTC wake
MicroPython ESP32_LoBo_v2.0.4 - 2017-10-08 on ESP32 board with ESP32
Type "help()" for more information.
Last edited by loboris on Sat Oct 14, 2017 11:13 am, edited 1 time in total.
Re: ESP32 power reduction for battery powered
Wow, nice explanation. I'll try some of these modes out over the next couple of days.
So maybe there isn't anything particularly critical about the hardware/pin setup of the ESP32 module itself? Unlike the ESP8266?
So maybe there isn't anything particularly critical about the hardware/pin setup of the ESP32 module itself? Unlike the ESP8266?
Re: ESP32 power reduction for battery powered
The ESP32 Micropython firmware I am running is a few weeks old, but apparently there isn't any deep sleep available in it. Or even the realtime clock?
I assume RTC and the machine.deepsleep() method are specific to your custom port of micropython?
Code: Select all
>>> import machine
>>> rtc = machine.RTC()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'RTC'
>>> dir(machine)
['__name__', 'mem8', 'mem16', 'mem32', 'freq', 'reset', 'unique_id', 'idle', 'disable_irq', 'enable_irq', 'time_pulse_us', 'Timer', 'Pin', 'Signal', 'TouchPad', 'ADC', 'DAC', 'I2C', 'PWM', 'SPI', 'UART']
Re: ESP32 power reduction for battery powered
Yes, all the examples are specific to my MicroPython implementation and won't work on standard MicroPython.Capstan wrote:...
I assume RTC and the machine.deepsleep() method are specific to your custom port of micropython?
By the way, the full documentation for various power saving modes will be available in a couple of days.
Re: ESP32 power reduction for battery powered
I downloaded and built your version of the firmware, and was able to flash it to a WROOM-32 successfully. The RTC code I have tried worked fine, and other code of my own that I loaded worked also. Impressive!loboris wrote: ↑Thu Oct 12, 2017 6:53 pmYes, all the examples are specific to my MicroPython implementation and won't work on standard MicroPython.
It looks like the loboris version of Micropython for the ESP-32 has a lot of nice additional features and some, like the RTC, are pretty critical. Do you have any plans to reconcile this with the 'official' version?