In the menueconfig I can set the clock to 80Mhz,160Mhz,240Mhz with the result that power consumption is reduced.
However, this applies to all boards with the same ESP32
It is also possible to make the individual clock with a C-code.
I have tried, there is no error but the clock is not changed either
Menu working:
C-Code in main:
Supplementary Code:
ESP32 Poweroption 80Mhz,160Mhz,240Mhz
-
- Valued Contributor
- Posts: 1009
- http://meble-kuchenne.info.pl
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 192 times
- Been thanked: 217 times
-
- Valued Contributor
- Posts: 1487
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 137 times
- Been thanked: 715 times
Re: ESP32 Poweroption 80Mhz,160Mhz,240Mhz
esp_pm_configure(&pm_config); 'should' do this. I've tested - and you need to have power management enabled in menuconfig (component config/power management).
Note that delays should still work correctly (this is handled by RTOS)
I use 5.3.2 - and esp_clk.h is now 'private' - and may disappear. Location may be different (see supplementary code)
Allowing light sleep (set to true in Set80MHz) - seems to stop the clock changing.
The output - shows clock before and after change:
Note that delays should still work correctly (this is handled by RTOS)
I use 5.3.2 - and esp_clk.h is now 'private' - and may disappear. Location may be different (see supplementary code)
Allowing light sleep (set to true in Set80MHz) - seems to stop the clock changing.
The output - shows clock before and after change:
MartinClock test
Clock Set = 240000000
fښ▒j%▒(453) pm: Frequency switching config: CPU_MAX: 80, APB_MAX: 80, APB_MIN: 80, Light sleep: DISABLED
Clock Set = 80000000
- Attachments
-
- esp32_clock.fcfx
- (13.76 KiB) Downloaded 16 times
-
- Valued Contributor
- Posts: 1009
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 192 times
- Been thanked: 217 times
Re: ESP32 Poweroption 80Mhz,160Mhz,240Mhz
Hi Martin
Ok I have tried but a small error...
Ok I have tried but a small error...
idf/main/CMakeFiles/__idf_main.dir/esp-project.c.obj -c C:/Users/stefan.erni/Desktop/esp-idf-2/mtxesp32s_sdkconfig/main/esp-project.c
C:/Users/stefan.erni/Desktop/esp-idf-2/mtxesp32s_sdkconfig/main/esp-project.c: In function 'FCM_Set80MHz':
C:/Users/stefan.erni/Desktop/esp-idf-2/mtxesp32s_sdkconfig/main/esp-project.c3: error: unknown type name 'esp_pm_config_t'; did you mean 'esp_netif_config_t'?
-
- Valued Contributor
- Posts: 1009
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 192 times
- Been thanked: 217 times
-
- Valued Contributor
- Posts: 1487
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 137 times
- Been thanked: 715 times
Re: ESP32 Poweroption 80Mhz,160Mhz,240Mhz
There was deprecated struct - this must be only available on later versions
I'm out at present and can't remember my first attempt - which used the old version...
Martin
I'm out at present and can't remember my first attempt - which used the old version...
Martin
-
- Valued Contributor
- Posts: 1487
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 137 times
- Been thanked: 715 times
Re: ESP32 Poweroption 80Mhz,160Mhz,240Mhz
I don't have anything less than 5.1.4 (and BT are running in treacle tonight) - but try changing the struct from esp_pm_config_t to esp_pm_config_esp32_t
Otherwise hopefully everything else would be the same?
I tested using 5.1.4 (the earliest I have installed) and it does work - using the older struct name. However - the 'change' in clock speed doesn't take place until the MCU has an idle section - this is easily achieved by adding a delay....
Martin
Otherwise hopefully everything else would be the same?
I tested using 5.1.4 (the earliest I have installed) and it does work - using the older struct name. However - the 'change' in clock speed doesn't take place until the MCU has an idle section - this is easily achieved by adding a delay....
Martin
- Attachments
-
- esp32_clock.fcfx
- (13.79 KiB) Downloaded 21 times
-
- Valued Contributor
- Posts: 1009
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 192 times
- Been thanked: 217 times
Re: ESP32 Poweroption 80Mhz,160Mhz,240Mhz
Hi Martin
Perfect! It's working nice.
It is very comfortable to use. Just import the macro and place it at the begin.
If you need to test with 240Hz just toggle disable the macro.
With this setting my recorder runs twice as long on one battery charge
The whole board needs:
40mA-50mA at 80Mhz
80mA-100mA at 240Mhz
2mA at lightsleepmode for both clock
Main:
Perfect! It's working nice.
It is very comfortable to use. Just import the macro and place it at the begin.
If you need to test with 240Hz just toggle disable the macro.
With this setting my recorder runs twice as long on one battery charge

The whole board needs:
40mA-50mA at 80Mhz
80mA-100mA at 240Mhz
2mA at lightsleepmode for both clock
Main:
-
- Valued Contributor
- Posts: 1487
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 137 times
- Been thanked: 715 times
Re: ESP32 Poweroption 80Mhz,160Mhz,240Mhz
The idea of dynamic frequency scaling is quite appealing - what happens on setting max speed to 240MHz and min to 80MHz.
Also - are other speeds allowed (40MHz?) - underclocking further, might give further power savings.
Have you tested the power requirement in deep sleep too? It can wake on a timer - and depending on the sample interval might give further savings?
Martin
Also - are other speeds allowed (40MHz?) - underclocking further, might give further power savings.
Have you tested the power requirement in deep sleep too? It can wake on a timer - and depending on the sample interval might give further savings?
Martin
-
- Valued Contributor
- Posts: 1009
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 192 times
- Been thanked: 217 times
Re: ESP32 Poweroption 80Mhz,160Mhz,240Mhz
Hi Martin
Yes deep sleep save power.
On my complet board:
deep sleep =0.7mA
light sleep = 2.0mA
Yes deep sleep save power.
On my complet board:
deep sleep =0.7mA
light sleep = 2.0mA