Live data from Hacker News

ESP32-C6 Power Consumption: Arduino vs. Zephyr vs. ESP-IDF Comparison

qoitech.com

11–20 of 21 posts

Re: ESP32-C6 Power Consumption: Arduino vs. Zephyr vs. ESP-IDF Comparison

#11
post #5

> execute instructions faster (via -O3) One problem with -O3 is that it disregards any effects of the cache (and yes, ESP32s have a bit of cache memory). I recommend using -Os as the default optimization level, as it often has the same or almost the same performance benefits as -O3. Less cache pressure is beneficial, especially for bigger applications, and the smaller code size is of course nice on embedded systems t…

This is how all the now defunct Symbian code was compiled.

Re: ESP32-C6 Power Consumption: Arduino vs. Zephyr vs. ESP-IDF Comparison

#12
post #9

I did something similar, but less scientific, comparing ESP-IDF and esp-hal (Rust). Unfortunately I learned that the optimizations that are already in ESP-IDF (most of all automatic light sleep between BLE advertisments) are hard to replicate in Rust/esp-hal/embassy and so for battery powered devices you might want to stick to C++/ESP-IDF

Do you have some more background information why it is hard to replicate?

Re: ESP32-C6 Power Consumption: Arduino vs. Zephyr vs. ESP-IDF Comparison

#13
post #7

As an off-topic remark, I've used the qoitech arc power analyzer quite a bit and it's quite nice and easy to use, when your DUT is <5V and low amps. There's also the Nordic PPK2 kit, which is cheaper but I haven't tried it. Both are aiming at the crowd that prefers a simple, handles-most-use-cases, little USB-connected box that runs the client on your computer, rather than a separate bulky thing with screen and whatn…

[dead]

Re: ESP32-C6 Power Consumption: Arduino vs. Zephyr vs. ESP-IDF Comparison

#14

ESP32 never was good for any powersaving applications.

While the ESP32 does have a high inrush current, its ULP coprocessor is quite capable, drawing only 12µA@3.3V during Deep Sleep. I have a fleet of AA-powered ESP32 devices at home that last 6–12 months, plus some solar-powered ones that run indefinitely.

Re: ESP32-C6 Power Consumption: Arduino vs. Zephyr vs. ESP-IDF Comparison

#15
post #5

> execute instructions faster (via -O3) One problem with -O3 is that it disregards any effects of the cache (and yes, ESP32s have a bit of cache memory). I recommend using -Os as the default optimization level, as it often has the same or almost the same performance benefits as -O3. Less cache pressure is beneficial, especially for bigger applications, and the smaller code size is of course nice on embedded systems t…

[deleted]

Re: ESP32-C6 Power Consumption: Arduino vs. Zephyr vs. ESP-IDF Comparison

#16
post #5

> execute instructions faster (via -O3) One problem with -O3 is that it disregards any effects of the cache (and yes, ESP32s have a bit of cache memory). I recommend using -Os as the default optimization level, as it often has the same or almost the same performance benefits as -O3. Less cache pressure is beneficial, especially for bigger applications, and the smaller code size is of course nice on embedded systems t…

Remember that -Os is much much more aggressive in GCC than it is in LLVM, with LLVM you need to use -Oz to get the same result.

GCC has historically been a bit of a pig about -Os, my favorite example is on x86 where it will emit a runtime divide for a division by a compile time constant power of two because it saves a byte of text!

  int fn(int n)
  {
    return n / 8;
  }
..becomes:

  0000000000000000 :
   0:   89 f8                   mov    %edi,%eax
   2:   b9 08 00 00 00          mov    $0x8,%ecx
   7:   99                      cltd
   8:   f7 f9                   idiv   %ecx
   a:   c3                      ret
..versus:

  0000000000000000 :
   0:   8d 47 07                lea    0x7(%rdi),%eax
   3:   85 ff                   test   %edi,%edi
   5:   0f 49 c7                cmovns %edi,%eax
   8:   c1 f8 03                sar    $0x3,%eax
   b:   c3                      ret

Re: ESP32-C6 Power Consumption: Arduino vs. Zephyr vs. ESP-IDF Comparison

#17
Hmm, those are some worrying news for Zephyr, but also for Linux. For reasons that escape my full understanding, a lot of embedded hardware needs Linux to work. If Zephyr, which I bet has been carefully crafted for microcontrollers, leaves some unnecessary things on, who knows what even an extremely trimmed down Linux running in, say, the beagle board, gets away with.

Re: ESP32-C6 Power Consumption: Arduino vs. Zephyr vs. ESP-IDF Comparison

#18
post #9

I did something similar, but less scientific, comparing ESP-IDF and esp-hal (Rust). Unfortunately I learned that the optimizations that are already in ESP-IDF (most of all automatic light sleep between BLE advertisments) are hard to replicate in Rust/esp-hal/embassy and so for battery powered devices you might want to stick to C++/ESP-IDF

This looks like it's doing that? https://github.com/esp-rs/esp-hal/tree/main/examples/async/e...

Re: ESP32-C6 Power Consumption: Arduino vs. Zephyr vs. ESP-IDF Comparison

#19

ESP32 never was good for any powersaving applications.

While the ESP32 does have a high inrush current, its ULP coprocessor is quite capable, drawing only 12µA@3.3V during Deep Sleep. I have a fleet of AA-powered ESP32 devices at home that last 6–12 months, plus some solar-powered ones that run indefinitely.

If you didn't mind sharing, I'd like to hear more about your use case. I'm assuming these would be things like temp/humidity sensors and such. I suppose you'd want to avoid wake-ups and radio use as much as possible.

I've not gotten around to trying, but I assume using deep sleep while waking up to batch send data with infrequent updates would be key.

Re: ESP32-C6 Power Consumption: Arduino vs. Zephyr vs. ESP-IDF Comparison

#20

It highlights that an idle loop in Arduino is energetically detrimental. That's not particularly uncommon. Many compilers or OSes default to wait loops when there's nothing to do, and they can be pretty power hungry.

RISC-V conveniently provides a `wfi` (wait for interrupts) instruction or hint -- it can act as a nop when not implemented.
Post reply on HN