olliw42 / mLRS

2.4 GHz & 915/868 MHz & 433 MHz/70 cm LoRa based telemetry and radio link for remote controlled vehicles
GNU General Public License v3.0
279 stars 58 forks source link

Provide an option to lower CPU frequency for M5Stack ATOM Lite. #113

Open rotorman opened 11 months ago

rotorman commented 11 months ago

Keeps ESP32 CPU running cooler and taking less energy. Experimentally found out that 160 MHz is still enough at least for UDP connectivity. Lowering further down to 80 MHz, did not get nice results anymore.

olliw42 commented 11 months ago

interesting. are there any data as regards how effective this really is? I find it frankly a bit difficult to imagine that it should do a lot.

vrquaeler commented 11 months ago

Hi, I do very similar things (like clocking down the MCU) for the "ESP-Now" flashed modules. It just works. The ESP's run cooler. Did also current measurements on the ESP modules, but can't remember the numbers.

jlpoltrack commented 11 months ago

On my ESP-Now setup I run 80 MHz no problem - I can run some high speed captures if there's interest. Here's some numbers pulled from Espressif forum. Looks like moving to 160 MHz saves ~20 mA. The ESP32 dev boards that I have are powered from 5 V linear regulators so would be 100 mW in savings.

image

https://esp32.com/viewtopic.php?t=2662

rotorman commented 11 months ago

Hmm... was not my intention to close this... was just rebasing on top of current main. I likely did something wrong then during rebase. Anyhow, re-opening. Will do some measurements soon.

olliw42 commented 11 months ago

hahaha ... yuchee ... I'm not the only one to whom this happens :D:D:D

rotorman commented 11 months ago

I measured the current draw of an Espressif ESP32-DevKitC V4 running mlrs-wireless-bridge. The results:

TCP mode (while client is connected to it, no data flowing): 240 MHz - 139 mA; 160 MHz - 126 mA; 80 MHz - 113 mA UDP mode (while client is connected to it, no data flowing): 240 MHz - 139 mA; 160 MHz - 126 mA; 80 MHz - 113 mA UDP client mode (not connected to AP): 240 MHz - 139 mA; 160 MHz - 114 mA; 80 MHz - 107 mA UDP client mode (connected to ESP8266 running mLRS UDP AP, no data flowing): 240 MHz - 65 mA; 160 MHz - 53 mA; 80 MHz - 39 mA Bluetooth mode (paired state, no data flowing): 240 MHz - 73 mA; 160 MHz - 60 mA; 80 MHz - 48 mA

From the results above I can conclude that having a lower clock, does lower the power consumption of an ESP32 board. Especially for modules in closed containers, such as M5Stack ATOM Lite at the back of Flysky FRM303 micro JR bay, as in my case, this will be IMO beneficial.

olliw42 commented 11 months ago

cool to see some data. I think the question however is not so much if it does draw less power ... I mean, it's a priori clear that it will draw lower power the lower the frequency, that's just a basic principle for this sort of electronics ... I think this is hardly disputed. To me the question rather would be if it's mandatory in the sense that it has a substantial effect, e.g., on the temperature, so that one just should do it to preserve the well-functioning, or if it is just a yeah it's better but one can live well also without it.

rotorman commented 11 months ago

The question is best formulated other way around - is it mandatory to have a higher clock frequency paired with higher energy consumption or if a lower clock freq. would already suffice.

olliw42 commented 11 months ago

I tend to go with the default and to divert only if needed, not the other way around :) for the STM32s we also just go with the max frequency for as long as it doesn't hurt, it doesn't hurt ... :)