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

Поділитися
Вставка
  • Опубліковано 28 вер 2024
  • This is a replay of video 410 (during my summer break)
    We all know we send our ESP32s to deep sleep to save energy. But do you know other energy-saving possibilities like light sleep and clock reduction? And what about modem sleep or hibernation?
    My second channel: / hb9blawireless
    Links:
    ESP32 Adapter board: s.click.aliexp...
    Power Profiler Kit II: www.nordicsemi...
    USB-Serial Adapter 3.3V: s.click.aliexp... or amzn.to/3lBqSqD
    Patreon supporter companies:
    www.welectron....
    The links above are usually affiliate links that support the channel (at no additional cost to you).
    Supporting Material and Blog Page: www.sensorsiot.org
    GitHub: www.github.com...
    My Patreon Page: / andreasspiess
    Discord: / discord
    If you want to support the channel, please use the links below to start your shopping. No additional charges for you, but I get a commission on your purchases to buy new stuff for the channel
    My Amazon.com shop: www.amazon.com...
    For Banggood bit.ly/2jAQEf4
    For AliExpress: For AliExpress: bit.ly/3MtXUY8 (just go on from here to your product)
    For Amazon US: www.amazon.com...
    For Amazon.de: amzn.to/2r0ZCYI
    For Amazon UK: amzn.to/2mxBaJf
    For ebay.com: ebay.to/2DuYXBp
    / spiessa
    Please do not try to email me. This communication channel is reserved for my primary job
    As an Amazon Associate, I earn from qualifying purchases
    #no#midroll#ads

КОМЕНТАРІ • 141

  • @dougbas3980
    @dougbas3980 Місяць тому +10

    Enjoy your summer 👍

  • @grimtagnbag
    @grimtagnbag Місяць тому +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.

  • @martyb3783
    @martyb3783 Місяць тому

    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  Місяць тому +1

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

  • @PhG1961
    @PhG1961 Місяць тому +18

    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  Місяць тому

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

    • @PhG1961
      @PhG1961 Місяць тому

      @@AndreasSpiess Awesome! Have fun there!

  • @AJB2K3
    @AJB2K3 Місяць тому +1

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

  • @Chris-ut6eq
    @Chris-ut6eq 22 дні тому

    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  13 днів тому

      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...

  • @austinhiggs7257
    @austinhiggs7257 Місяць тому

    Thanks!

  • @BerndRenzing
    @BerndRenzing Місяць тому

    Thanks, Grüße aus dem Ruhrgebiet

  • @SA-oj3bo
    @SA-oj3bo Місяць тому

    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 Місяць тому +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 Місяць тому

      @@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.

  • @Grrr2048
    @Grrr2048 Місяць тому

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

  • @dunnyroll3646
    @dunnyroll3646 Місяць тому +1

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

    • @mikejones-vd3fg
      @mikejones-vd3fg Місяць тому

      i thought the c3 did blue tooth low power

    • @AndreasSpiess
      @AndreasSpiess  Місяць тому

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

  • @MeisterQ
    @MeisterQ Місяць тому

    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  23 дні тому +1

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

    • @MeisterQ
      @MeisterQ 23 дні тому

      @@AndreasSpiess Thank you

  • @KC-nd7nt
    @KC-nd7nt Місяць тому

    Oh cool

  • @retokaderli9010
    @retokaderli9010 Місяць тому

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

  • @mikejones-vd3fg
    @mikejones-vd3fg Місяць тому +5

    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!

  • @techiesms
    @techiesms Місяць тому +7

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

    • @ManasChachra
      @ManasChachra Місяць тому

      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  Місяць тому

      Glad to hear that!

    • @AndreasSpiess
      @AndreasSpiess  Місяць тому

      Glad to hear that!

  • @nezbrun872
    @nezbrun872 Місяць тому +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  Місяць тому

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

    • @austinhiggs7257
      @austinhiggs7257 Місяць тому

      @@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 Місяць тому

      @@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 Місяць тому

      Link please

  • @innomkr
    @innomkr Місяць тому +2

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

  • @DuroLabs85
    @DuroLabs85 Місяць тому +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  Місяць тому

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

  • @hexidev
    @hexidev Місяць тому +3

    Is this a reupload?

    • @markusm.4556
      @markusm.4556 Місяць тому

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

  • @flyviawall4053
    @flyviawall4053 Місяць тому +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  Місяць тому +1

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

  • @pitacotavo5938
    @pitacotavo5938 Місяць тому

    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  Місяць тому

      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.

  • @ismylhakkituran
    @ismylhakkituran Місяць тому

    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  Місяць тому

      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.

  • @leocurious9919
    @leocurious9919 Місяць тому

    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  Місяць тому

      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...

  • @fersunk
    @fersunk Місяць тому +1

    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  Місяць тому

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

  • @Cyklonus
    @Cyklonus Місяць тому

    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  Місяць тому

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

  • @thomashuyghebaert5622
    @thomashuyghebaert5622 Місяць тому

    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  Місяць тому

      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.

  • @Vraj3110
    @Vraj3110 Місяць тому

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

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

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

  • @TheAstronomyDude
    @TheAstronomyDude Місяць тому

    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  Місяць тому

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

  • @Ed19601
    @Ed19601 Місяць тому +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  Місяць тому +1

      Maybe things changed. This is a replay video.

  • @4bSix86f61
    @4bSix86f61 Місяць тому +2

    RIP C18 on the esp [5:38]

  • @jamesmichener7526
    @jamesmichener7526 Місяць тому +1

    Another great video! THANKS!

  • @phlexy
    @phlexy Місяць тому +1

    Are you going to do Pico 2 review?

    • @AndreasSpiess
      @AndreasSpiess  Місяць тому +1

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

    • @phlexy
      @phlexy Місяць тому

      @@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.

  • @gepetotube
    @gepetotube Місяць тому +1

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

  • @ScottPlude
    @ScottPlude Місяць тому +1

    Thanks!

  • @RommudohDev
    @RommudohDev Місяць тому

    5:39 C18 is not happy?

  • @zyghom
    @zyghom Місяць тому

    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);

  • @emmoemminghaus6455
    @emmoemminghaus6455 Місяць тому

    @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)

  • @ericmintz8305
    @ericmintz8305 Місяць тому

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

  • @kbce
    @kbce Місяць тому

    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"?

  • @DAASSIv2
    @DAASSIv2 Місяць тому

    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  Місяць тому

      Modem sleep sleeps the radio. So no receiving or transmission

  • @underwoodblog
    @underwoodblog Місяць тому

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

    • @DuroLabs85
      @DuroLabs85 Місяць тому

      Yes. ESP8266 Works with the WiFi.mode command

  • @PatricAeberhard
    @PatricAeberhard Місяць тому

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

  • @AFSMG
    @AFSMG Місяць тому

    Excelente

  • @belalmohammed2265
    @belalmohammed2265 Місяць тому

    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.

  • @sulcusulnaris
    @sulcusulnaris Місяць тому

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

    • @AndreasSpiess
      @AndreasSpiess  Місяць тому +1

      Not good! Deepsleep definitely is better

  • @wjn777
    @wjn777 Місяць тому

    The video was useful and interesting, thank you for sharing

  • @wolpumba4099
    @wolpumba4099 Місяць тому +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 Місяць тому

    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  Місяць тому

      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 Місяць тому

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

  • @michaeleitel7186
    @michaeleitel7186 Місяць тому

    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

  • @ddlsmurf
    @ddlsmurf Місяць тому

    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  Місяць тому

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

    • @ddlsmurf
      @ddlsmurf Місяць тому

      @@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

  • @lollonelollino1549
    @lollonelollino1549 Місяць тому

    Amazing content!

  • @muctop17
    @muctop17 Місяць тому

    9:07 nearly 600mA !

  • @johnwiltson3164
    @johnwiltson3164 Місяць тому

    thank you
    👍

  • @rdyer8764
    @rdyer8764 Місяць тому

    Excellent!

  • @holgerschurig4430
    @holgerschurig4430 Місяць тому +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 Місяць тому +4

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

    • @hagopboghossian6841
      @hagopboghossian6841 Місяць тому +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 Місяць тому

      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 Місяць тому

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

    • @tin2001
      @tin2001 Місяць тому

      ​@@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.

  • @evilkittyofdoom195
    @evilkittyofdoom195 Місяць тому

    Fantastic!

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

    Nice

  • @fullpower8382
    @fullpower8382 Місяць тому

    Erst mal ein Like!! ...

  • @richonguzman
    @richonguzman Місяць тому

    great timing :P CA2RXU, 73!