(490) Unknown ESP32 saving: Light Sleep, Clock Reduction, Modem Sleep, Hibernation, and a few tricks

Поділитися
Вставка
  • Опубліковано 3 лют 2025

КОМЕНТАРІ • 146

  • @PhG1961
    @PhG1961 5 місяців тому +19

    I love the recaps... it prevents my memory from forgetting things and at the same time it's nice entertainment! Enjoy the summer holidays.

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      Thank you. Currently, I am at Def Con in Las Vegas😁

    • @PhG1961
      @PhG1961 5 місяців тому

      @@AndreasSpiess Awesome! Have fun there!

  • @techiesms
    @techiesms 5 місяців тому +7

    Thanks for this video.
    A lot of new learnings for me in a single video

    • @ManasChachra
      @ManasChachra 5 місяців тому

      hey buddy , been seeing ur videos for a while. just wanted to ask whether ordering things from china is safe or not, and which site or place to order from

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      Glad to hear that!

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      Glad to hear that!

  • @dougbas3980
    @dougbas3980 5 місяців тому +10

    Enjoy your summer 👍

  • @innomkr
    @innomkr 5 місяців тому +2

    Thank you for the amazing video! I would love to see more videos on using low power modes with different MCUs!

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      I do not use many other chips...

  • @nezbrun872
    @nezbrun872 5 місяців тому +6

    The Nordic Power Profiler II is an absolute game changer if you're into low power microcontroller applications, especially those with widely varying current draw.
    Its USP is its unique current measuring method, using a series of comparators to dynamically change current range, thus offering a huge dynamic range. Thus, burden voltage issues inherent to traditional static shunt resistor current measuring methods are no longer a problem.

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      I agree. However, you also get other such devices. But more expensive.

    • @austinhiggs7257
      @austinhiggs7257 5 місяців тому

      @@nezbrun872 I agree. I bought one of these at Andrea’s’ recommendation and it does not disappoint. I use it any time I’m developing any kind of project where power is a concern. I have just started using the digital inputs and decoding features.

    • @nezbrun872
      @nezbrun872 5 місяців тому

      @@AndreasSpiess As well as the Power Profiler II, I have a couple of SMUs and an Otii power analyser. The Power Profiler II is used almost on a daily basis. The SMUs maybe once a month. The Otii: I used it once and it's sat in a drawer ever since, its current measurement in the single digit uA range and lower is so noisy it's useless. The Power Profiler II is 1/6th the cost and offers a far better real time low current (ie, under 5uA) analysis than the Otii. My point is that the Power Profiler II's auto ranging implementation to increase dynamic range is unique to it as far as I am aware, certainly at the price point.

    • @itaynave5770
      @itaynave5770 5 місяців тому

      Link please

  • @grimtagnbag
    @grimtagnbag 5 місяців тому +1

    Yes sir thank you again. Once again you are in my head. I’m playing with solar and power consumption has been on my mind. I do need WiFi and was wondering but don’t have all the toys to know. Love it.

  • @phasemargin
    @phasemargin 3 місяці тому

    Very thorough treatment of power consumption topics on ESP32 - thank you! A companion topic of power source selection would compliment this topic: from battery and multi-battery strategies to achieve a target battery life for a given application, on up to solar or other recharge subsystems.

    • @AndreasSpiess
      @AndreasSpiess  3 місяці тому

      Indeed a wide area. I did videos on various aspects like solar already.

    • @phasemargin
      @phasemargin 3 місяці тому

      @@AndreasSpiess wonderful, I will search some more through your extensive posts. Any favourites video numbers that you recommend to pair with this sleep topic? The coin cell video was very insightful, for example. Thank you for your videos - very inspiring.

  • @martyb3783
    @martyb3783 5 місяців тому

    This is very good information. I am new to the ESP32 and am considering using it in a few projects as apposed to my current use of Raspberry PI, which I am familiar with and have been too lazy to learn another single board computer or microcontroller. Thanks for this and your other videos. You explain things very well.

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому +1

      You will like it! Raspberry Pis sometimes are too big...

  • @PatricAeberhard
    @PatricAeberhard 5 місяців тому

    Thank you very much! Exaclty what I needed and KI didn't knew yet.
    From another guy with a swiss accent.

  • @jamesmichener7526
    @jamesmichener7526 5 місяців тому +1

    Another great video! THANKS!

  • @AJB2K3
    @AJB2K3 5 місяців тому +1

    Always useful and interesting and just shared it to a group.

  • @gepetotube
    @gepetotube 5 місяців тому +1

    Great video. I was not aware you can do all these.

  • @mikejones-vd3fg
    @mikejones-vd3fg 5 місяців тому +6

    Another tip to save power - desolder the power LED. That thing takes 10x more power then the MCU does in deep sleep. thats what eating your battery, that tiney led!

  • @fersunk
    @fersunk 5 місяців тому +2

    I worked in my last job with a battery operated ESP32 project that reads the information from a magnetic sensor and send it using LoraWAN, and my calculations to hit the needed battery life were sub 100uA on standby, but that budget were ESP32 + sensor + lora radio.
    I used the IDF to program it, Arduino is useless for any serious task that implies a micro that isn't Atmel.
    All the fun stuff to manipulate the hw of the ESP is behind IDF.
    And there's a lot of HW design to hit a good low sleep power consumption.
    Of course the ESP32 hides a lot of quirks that needs to be addressed in the final design.

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      Fir professional projects, the IDF is a good choice. However, it works only for Espressif chips.

  • @wjn777
    @wjn777 5 місяців тому

    The video was useful and interesting, thank you for sharing

  • @lollonelollino1549
    @lollonelollino1549 5 місяців тому

    Amazing content!

  • @flyviawall4053
    @flyviawall4053 5 місяців тому +1

    There's also a ULP co-processor and RTC memory you can use, a very low speed CPU but full capability, consuming power in nA range.
    For real-world application you would want the ULP to listen to peripherals(with no interrupt capability) and wake the main CPU in certain criteria.
    But realistically if you are doing very tiny application and you can bit big everything in a slow clock, you can put your whole code into ULP.

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому +1

      You are right. I once made a video about it ;-)

  • @evilkittyofdoom195
    @evilkittyofdoom195 5 місяців тому

    Fantastic!

  • @johnwiltson3164
    @johnwiltson3164 5 місяців тому

    thank you
    👍

  • @Ed19601
    @Ed19601 5 місяців тому +1

    great info. I was under the impresion that "WiFi.setSleep(true);" was enough for modem sleep, but i could be wrong. I do not use the ESP32 for sleep projects that often

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому +1

      Maybe things changed. This is a replay video.

  • @Chris-ut6eq
    @Chris-ut6eq 5 місяців тому

    looking forward to your fall updates. Would love a recap of dev24 highlights as you see them. Also what chips you recommend for hobbyists. plus whatever else about esp32 in 2024.

    • @AndreasSpiess
      @AndreasSpiess  4 місяці тому

      I did not film at Devcon because they do not like it and had strict rules. Some people even were masked to protect their identity...

  • @BerndRenzing
    @BerndRenzing 5 місяців тому

    Thanks, Grüße aus dem Ruhrgebiet

  • @fullpower8382
    @fullpower8382 5 місяців тому

    Erst mal ein Like!! ...

  • @DuroLabs85
    @DuroLabs85 5 місяців тому +2

    10:10 WiFi.mode works for me with ESP8266 even at 80Mhz. I had a project where the esp fetches time from a LAN NTP server and then updates it if the clock hits 11.30Pm the modem turns off and the internal timer starts and the wifi turns back on at 6.30Am in the morning. Never got a chance to try the command with an ESP32 though. It reduces the consumption from 130mA to just around 20mA and the esp8266 is still running everything else in the code. ADC measurements to. But I faced a issue with ESP8266 is that you cannot use the ADC too much when using WiFi so the ADC update rate is around 10S or so.

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      The ESP8266 has a standard clock speed of 80MHz. So, everything should work as designed.

  • @AFSMG
    @AFSMG 5 місяців тому

    Excelente

  • @4bSix86f61
    @4bSix86f61 5 місяців тому +2

    RIP C18 on the esp [5:38]

  • @Чумак-щ8и
    @Чумак-щ8и 5 місяців тому

    Nice

  • @pitacotavo5938
    @pitacotavo5938 5 місяців тому

    I have a suggestion, measure the time that every microcontroller you have takes to register an input, like a button. I saw a video of you doing it for stm32 and esp32, but I can't find it anymore! New microcontrollers like rp2040 will be awesome.
    It's important for gamers to have the most low delay microcontroller.
    Thanks!

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      The reaction time of such microcontrollers is way below 1 millisecond. So this is hardly an issue for your application. However, what they do with this information usually takes much longer.

  • @ericmintz8305
    @ericmintz8305 5 місяців тому

    Off topic but important: WiFi uses persistent memory. Your program will crash if you disable it. I learned this the hard way.

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      Interesting. I did not know that.

  • @emmoemminghaus6455
    @emmoemminghaus6455 5 місяців тому

    @Andreas The Wifi library... its compiling... amazingly it works on ESP... But only WIFI, so now you can add lowpower modes to the list of things not working with the Arduino Wifi class.
    (Just use the IDF functions for wifi and you might get a better result)

  • @phlexy
    @phlexy 5 місяців тому +1

    Are you going to do Pico 2 review?

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому +1

      I am not sure. There are already many such reviews out.

    • @phlexy
      @phlexy 5 місяців тому

      @@AndreasSpiess But there are none that go into improvements of deep and lightsleep and it seems to me you are the expert for power saving.

  • @thomashuyghebaert5622
    @thomashuyghebaert5622 5 місяців тому

    If the clock speed is reduced then the code takes way longer to run. Judging by the area below each section of the measurements at 8:30 it looks like the most milliwatthours have been consumed at the lowest frequency of 10MHz (the total area looks way larger than at 240MHz in my opinion) Would it be fair to say that the current is in fact lower but battery life would be worse? Or am i missing something

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      You are correct if the processor is fully loaded. However, microcontrollers often wait for a very long time and then react to a signal. Then, a lower clock makes sense.

  • @KC-nd7nt
    @KC-nd7nt 5 місяців тому

    Oh cool

  • @Cyklonus
    @Cyklonus 5 місяців тому

    Nice, but for battery-powered projects I prefer to use nRF24L01. I make sensors with one AAA battery on them and it works for a few months.

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      Also, a good idea when you do not need an internet connection.

  • @SA-oj3bo
    @SA-oj3bo 5 місяців тому

    I would like to see how the ESP can actually sleep at minuimum current of only a few micro-amps and wakes up by triggering an input, like a sensor contact. The datasheet mentions it can be woken up when just consuming a few microamps, bit I never saw someone doing and proving this.

    • @fersunk
      @fersunk 5 місяців тому +1

      In my last job I was working with a ESP32 on battery and the requirements were like 1yr of standby.
      I used the ULP to wake up the main processor when the ULP detected an interrupt from a magnetic sensor.
      Not only doing fw magic but also a lot of hw design is needed to hit micro amps and a good sleep

    • @SA-oj3bo
      @SA-oj3bo 5 місяців тому

      @@fersunk so in your opinion without ULP it is not possible, even when the datsheet mentions a few uA?
      Power consumption in Deep-sleep mode is 10 µA, here they mean the ESP32 not the ULP right? 10uA would be perfect for battery mode... but I never saw someone succeeding in reaching only 10uA. Strange... hopefully Andreas will figure it out in the next video's.

  • @ddlsmurf
    @ddlsmurf 5 місяців тому

    I think there was confusion about modem sleep. It's supposed to keep the modem alive while letting the cpu sleep, this maintains connections etc. It requires an external 32khz square wave iirc, and obviously doesn't make any sense to use without wifi. It's meant to let the modem wake up and just do the wifi book-keeping stuff.

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      I don't know if this is a new definition used by the new WiFi 6 functionality of some chips.

    • @ddlsmurf
      @ddlsmurf 5 місяців тому

      @@AndreasSpiess it seems youtube won't allow me to reply with links, but no, i'm very far from any risk of being too up to date, this was how it worked when esp32 was new, without need for ancs/ble (see watchy) it's not useful, the esp32 will never be a great device where power is at a premium, but still

  • @RommudohDev
    @RommudohDev 5 місяців тому

    5:39 C18 is not happy?

  • @MeisterQ
    @MeisterQ 5 місяців тому

    I have 2 questions in this:
    1. I cant use wifi, but can i use ESP now with lower clockrates than 80MHz?
    2. Is there a way to keep the pin state on HIGH during deepsleep?
    Thank you for this videos

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому +1

      1. Yes
      2. I do not know. I never used it :-(

    • @MeisterQ
      @MeisterQ 5 місяців тому

      @@AndreasSpiess Thank you

  • @zyghom
    @zyghom 5 місяців тому

    there are commands you can use within the runtime - not in overall:
    setCpuFrequencyMhz(10); - 10 MHz etc
    but to make Serial working:
    // Serial has to start again after CPU frequency is changed
    Serial.flush();
    Serial.end();
    setCpuFrequencyMhz(10);
    Serial.begin(115200);

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      Thank you for the info! Valuable!

  • @belalmohammed2265
    @belalmohammed2265 5 місяців тому

    The problem with the sleep function in esp32 is the cpu resets from the beginning again, which makes it very hard to save power, unlike arm processors.

  • @Grrr2048
    @Grrr2048 5 місяців тому

    Interesting as always, would the power consumption during deep sleep be lower if the clock frequency was set to 10mhz?

  • @ismylhakkituran
    @ismylhakkituran 5 місяців тому

    Thank you very much for the helpful video.
    I was wondering, what could be the reason why Wi-Fi doesn't operate at frequencies below 80 MHz? How can the Wi-Fi module inside transmit symbols at such high frequencies (like 2.4 or 5 GHz) during the transmission stage ? Is the frequency required for radio transmission supplied from another source ?

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      The 2.4 GHz signals are produced in a radio module. The MPU has a different clock. I do not know if they are interconnected.

  • @wolpumba4099
    @wolpumba4099 5 місяців тому +2

    *Summary*
    ## ESP32 Energy Saving Modes Summary
    Here's a summary of the video's key points about optimizing your ESP32's energy consumption:
    *General Tips:*
    * *(**00:00:00**) Use optimized hardware:* Standard ESP32 Dev boards are power hungry. Use optimized boards, your own PCB designs, or a barebone ESP32 module.
    * *(**00:10:05**) Disable unused features:* If your project doesn't need Wi-Fi or Bluetooth, avoid enabling them.
    *Clock Rate Optimization:*
    * *(**00:02:23**) Reduce CPU frequency:* You can significantly decrease power consumption by lowering the ESP32's clock rate from the default 240MHz.
    * Reducing to 160MHz or 80MHz offers substantial savings without impacting most sensors and with full Wi-Fi/Bluetooth functionality.
    * Going below 80MHz requires adjusting serial console speed and impacts Wi-Fi/Bluetooth.
    * Remember that lowering clock rate reduces processing speed.
    * *(**00:13:39**) Adjust clock rate dynamically:* You can change clock frequency within your sketch depending on the task.
    * *(**00:10:01**) Note about Modem Sleep:* The presenter couldn't verify clear benefits of this mode and suggests avoiding it for now.
    *Sleep Modes:*
    * *(**00:14:19**) Light Sleep:*
    * Acts like a delay with lower power consumption (around 1.5mA).
    * Suitable for replacing delays when Wi-Fi/Bluetooth are not in use.
    * *(**00:15:15**) Deep Sleep:*
    * Most effective power saving mode, consuming only microamps.
    * Requires careful management of peripherals and memory as the ESP32 reboots upon waking.
    * *(00:15:32) * Disabling the ULP (Ultra Low Power) and RTC memory can further reduce power consumption during deep sleep, but eliminates persistent data storage.
    *Overall:*
    * *(**00:15:54**) Testing is key:* Verify functionality after implementing power saving techniques.
    * *(**00:15:54**) Choose strategies that fit your needs:* Balance energy efficiency with functionality and project requirements.
    I used Google Gemini 1.5 Pro to summarize the transcript.
    Cost (if I didn't use the free tier): $0.1242
    Time: 90.62 seconds
    I added a 60 second delay to prevent a rate limit of the free tier.
    Input tokens: 32723
    Output tokens: 923

  • @klassichd10
    @klassichd10 5 місяців тому

    Thank you for your effort to achieve low power AND Wifi. I gave up. Hoping for a Zigbee solution combining Zigbee data transfer with epaper display.

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      I switched to ZigBee wherever possible. But only with commercial devices. I fear the ESPs will consume too much. But so far, I did not try.

    • @klassichd10
      @klassichd10 5 місяців тому

      @@AndreasSpiess Yes, Zigbee uses e.g. CC2530 which seems to have limited programming support.

  • @DAASSIv2
    @DAASSIv2 5 місяців тому

    As I understood in the documentation ModemSleep is nict a sleep mode, it ist just the mode, when the modem ist not working active, so it is in general turned on (initialised WiFi or BT) but is nocht sending or receiving. I researched for this a while ago for very long, because its very confusing

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      Modem sleep sleeps the radio. So no receiving or transmission

  • @Vraj3110
    @Vraj3110 5 місяців тому

    Hello please make video on waveshare RP2040-ETH board it will be helpful regards

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      This seems to be a rather standard MCU board with an Ethernet plug. So nothing for a particular video on this channel :-(

  • @muctop17
    @muctop17 5 місяців тому

    9:07 nearly 600mA !

  • @michaeleitel7186
    @michaeleitel7186 5 місяців тому

    Are you sure that you use hardware based i2c? I think with your implementation you use bitbang. I think I had interferences with f.x. wifi when using any kind of bitbang. Similar with one wire for less. m5c

  • @dunnyroll3646
    @dunnyroll3646 5 місяців тому +1

    It's disappointing that the ESP32 doesn't support low power BLE operation like the NRF chips.

    • @mikejones-vd3fg
      @mikejones-vd3fg 5 місяців тому

      i thought the c3 did blue tooth low power

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      I did not check the newer chips for power consumption. The old ones were horrible for BLE

  • @TheAstronomyDude
    @TheAstronomyDude 5 місяців тому

    So if my esp is in full beans mode (240mhz + wifi) then I should reboot it without initializing wifi and then enter deep sleep mode?

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      That depends on what you want to do with it...

  • @kbce
    @kbce 5 місяців тому

    How about the esp32's which have dual cpu (like the standard esp32). Doesn't the wifi run on a dedicated cpu? Can you put the other processor in deep sleep and keep wifi connected? Or do all cpu have to be in the "sleep-state"?

  • @hexidev
    @hexidev 5 місяців тому +3

    Is this a reupload?

    • @markusm.4556
      @markusm.4556 5 місяців тому

      Yes, as Andreas mentioned in the video description. Re-upload of video 410.

  • @matthiasdyer9759
    @matthiasdyer9759 27 днів тому

    Thank you also for this video. However, your conclusion about the sleep modes with WiFi is disappointing. I had hoped for more here. Had been researching this for hours. Lightsleep is fully automatic with WiFi. But as others have pointed out, not with Arduino IDE. Apart from the IDF ‘wifi power safe’, there are no useful examples anywhere on the net. Would you be interested in investigating this in more detail? Everyone would like to have a low power wake on wifi node! I'll keep experimenting and if needed I recompile the arduino libs with enabled advanced power options. I post if I succeed. I can also do a Swiss accent :-)

    • @AndreasSpiess
      @AndreasSpiess  22 дні тому

      You find me in the telephone book if you found a solution! I am interested, too.

  • @leocurious9919
    @leocurious9919 5 місяців тому

    You keep mentioning "no WiFi" power consumption down to 10 MHz. But WiFi does not work there, as you say at the beginning? So one should really avoid this and instead turn it off? to reduce the current draw to 1/7 of the WiFi-On-value.

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому

      I made this video a few years ago (this is a replay during my summer break). I do not remember all the details anymore, but as you write, WiFi does not work on low clock frequencies. Maybe the radio still consumed power but was useless...

  • @richonguzman
    @richonguzman 5 місяців тому

    great timing :P CA2RXU, 73!

  • @retokaderli9010
    @retokaderli9010 5 місяців тому

    Could You get Serial (USB) with Light sleep working? No problem with Serial1, but USB ... seems not working after Light sleep

  • @sulcusulnaris
    @sulcusulnaris 5 місяців тому

    I need Deepsleep myself... only have modern sleep waking up every x hour.

    • @AndreasSpiess
      @AndreasSpiess  5 місяців тому +1

      Not good! Deepsleep definitely is better

  • @underwoodblog
    @underwoodblog 5 місяців тому

    does the ESP8266 behave the same with WiFi.mode( WIFI_OFF );?

    • @DuroLabs85
      @DuroLabs85 5 місяців тому

      Yes. ESP8266 Works with the WiFi.mode command

  • @holgerschurig4430
    @holgerschurig4430 5 місяців тому +12

    I'm a programmer ... since almost ever. And I always hate when people talk about "sketches" instead of "programs". Maybe it was a marketing stunt from Arduino, to make µC programming accessible to non-programmers by coloring the bike-shed in a different color. But do we need this to non-Arduino programs?

    • @technoman9000
      @technoman9000 5 місяців тому +4

      I still cringe when people call them "apps" instead of programs... But I think that battle has been lost

    • @hagopboghossian6841
      @hagopboghossian6841 5 місяців тому +1

      If you are using arduino ide for mcu programming, maybe it takes 1 hour but in embedded c or others will take you maybe whole day or longer. You have to read the datasheet, and every mcu has its own datasheet. 😫 and sometimes you need someone to help you. can't do it by yourself "Arduino ide help you a lot if we lost arduino. We regret I telling you.

    • @DVSProductions
      @DVSProductions 5 місяців тому

      Maybe they made the distinction because the sketch is not a full program. It's a part of it but all your functions are being called by the actual main program running on the controller

    • @y2ksw1
      @y2ksw1 5 місяців тому

      As far as I recall, there was a discussion about how to call the code. I personally find the choice horrible.

    • @tin2001
      @tin2001 5 місяців тому

      ​@@technoman9000
      "App" to me means a small program for a touch screen phone or tablet.
      My brain grinds gears trying to process when someone calls desktop Microsoft Excel an "app", as I try to work out if they mean on a phone or their computer.

  • @ScottPlude
    @ScottPlude 5 місяців тому +1

    Thanks!

  • @rdyer8764
    @rdyer8764 5 місяців тому

    Excellent!

  • @austinhiggs7257
    @austinhiggs7257 5 місяців тому

    Thanks!