ESP32 power Power Management and sleep

For general Flowcode discussion that does not belong in the other sections.
Post Reply
stefan.erni
Valued Contributor
Posts: 758
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 171 times

ESP32 power Power Management and sleep

Post by stefan.erni »

Hi to All

To set the CPU clock I always get a fail.

But to let an ESP32 sleep works

I am doing something wrong
// Enter C code below this comment
//#include "esp_pm.h"
CONFIG_PM_ENABLE();
ESP_PM_CPU_FREQ_MAX();


To let a ESP32 sleep i found some c-code and it's working fine
I use a button on gpio39 to wake up
Democode here:
Snag_17d8947.png
Snag_17d8947.png (169.26 KiB) Viewed 330 times
just add this:
Snag_17e0935.png
Snag_17e0935.png (109.45 KiB) Viewed 330 times

stefan.erni
Valued Contributor
Posts: 758
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 171 times

Re: ESP32 power Power Management and sleep

Post by stefan.erni »

Hi to All

I found a way to change the clock from the ESP32.

in the menu,
component config -> ESP32-specific -> CPU frequency set to 80Mhz

and in Flowcode in the project option set to 80Mhz.

This way I can save 20mA current and for my project it's still fast enough.

What is still missing is a wakeup with Bluetooth. Maybe someone knows how to do this.


In the setup menue:
Snag_200285ca.png
Snag_200285ca.png (31.41 KiB) Viewed 263 times
in Flowcode:
Snag_20029cec.png
Snag_20029cec.png (41.09 KiB) Viewed 263 times

mnfisher
Valued Contributor
Posts: 956
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 509 times

Re: ESP32 power Power Management and sleep

Post by mnfisher »

https://docs.espressif.com/projects/esp ... connection.

Has some details - will take a little C and I suspect might not be supported on some variants

Martin

stefan.erni
Valued Contributor
Posts: 758
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 171 times

Re: ESP32 power Power Management and sleep

Post by stefan.erni »

Hi Martin

I found this site and already tried, but always i get a fail.
but sleeping and waking up with pin is working.
Am I doing something wrong in the C code?

Command in FC:
Snag_202750db.png
Snag_202750db.png (5.38 KiB) Viewed 256 times
Command in PDF:
Snag_20274439.png
Snag_20274439.png (19.76 KiB) Viewed 256 times

stefan.erni
Valued Contributor
Posts: 758
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 171 times

Re: ESP32 power Power Management and sleep

Post by stefan.erni »

I can found if i look in V5.0.6 commands, but if i look in V4.4.7 there is no command for wakeup with BT
It's it looks like it only works from version 5 but then with version 5 Bluetooth does not work with Flowcode
Attachments
Snag_203052d3.png
Snag_203052d3.png (11.88 KiB) Viewed 255 times
Snag_203041dc.png
Snag_203041dc.png (15.4 KiB) Viewed 255 times

mnfisher
Valued Contributor
Posts: 956
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 509 times

Re: ESP32 power Power Management and sleep

Post by mnfisher »

I think most of the variants turn off BT when in sleep too. Not sure if there is an easy solution - unless the BT can get a fix for v5?

As a cheat (and a test)- connect BT using C (use the example programs - can add to supplementary code - and rename app_main()) and see if it works with sleep. I can maybe have a try this evening...

stefan.erni
Valued Contributor
Posts: 758
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 171 times

Re: ESP32 power Power Management and sleep

Post by stefan.erni »

I have Python3.7 and Idf 5.1.2 on an another computer installed. I can compile using the "BT sleep command"
Bluetooth is working this way but it's not wakeup correct like the port wakeup.
i guess i should not use python 3.7 and Idf 5.1.2 better a higher version python.
But then i can not start the config menue and BT will not work

mnfisher
Valued Contributor
Posts: 956
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 509 times

Re: ESP32 power Power Management and sleep

Post by mnfisher »

Hmm - something is awry with the BT - even using espressif examples.
I upgraded to v5.2 (brave maybe - not sure I recommend this at the moment) - and get the message/error:
I (569) coexist: coex firmware version: 77cd7f8
I (575) main_task: Started on CPU0
I (585) main_task: Calling app_main()
I (615) BTDM_INIT: BT controller compile version [a38dc5c]
I (625) BTDM_INIT: Bluetooth MAC: a4:cf:12:82:16:da
E (625) GAP: c_app_main enable controller failed: ESP_ERR_INVALID_ARG
This after enabling BT classic (using menuconfig) I'll play some more see it's just a config issue.

As another issue - is wake on BT only available with BLE?

Martin

Post Reply