🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    How to save battery with M5StickC

    Cores
    4
    5
    12.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • takanotume24T
      takanotume24
      last edited by takanotume24

      I want to make something that can be battery driven for a long time with M5StickC.
      As an operation, M5StickC is in Deep Sleep state → button is pressed → process is performed → Deep Sleep state is entered again.
      I tried the following code, but M5StickC runs out of battery in one day. Even if I press the button after one day, it doesn't return.

      #include <Arduino.h>
      #include <M5StickC.h>
      #include "driver/rtc_io.h"
      
      RTC_DATA_ATTR int bootCount = 0;
      
      void setup(){
        M5.begin();
        ++bootCount;
        M5.Lcd.println("Boot number: " + String(bootCount));
      
        rtc_gpio_pullup_en(GPIO_NUM_37);
        esp_sleep_enable_ext0_wakeup(GPIO_NUM_37,LOW);
      
        M5.Lcd.println("Going to sleep now");
        delay(1000);  
        M5.Axp.ScreenBreath(0);
        esp_deep_sleep_start();
      }
      
      void loop(){
      }
      
      

      The information I got stated that it was consuming power because it was in a pull-up state. So I set it to pull-down during normal times so that it returns when it goes high. However, if I do so, it will return immediately after entering the DeepSleep state, and it will repeat indefinitely.

      1 Reply Last reply Reply Quote 0
      • P
        Pepsi
        last edited by

        I only have limited expirience with sleep mode.
        But when a device comes out of Sleepmode it will not go in to the setup loop again. only during boot.

        And the second thing you could to it to reduce the CPU speed to 80 instead of the default 240. that also saves your battery

        1 Reply Last reply Reply Quote 0
        • C
          crami25
          last edited by

          @takanotume24

          https://lastminuteengineers.com/esp32-deep-sleep-wakeup-sources/

          or

          https://randomnerdtutorials.com/esp32-deep-sleep-arduino-ide-wake-up-sources/

          As you see in the tutorial I referenced above the ESP32 has different sleep modes, according how much battery you want to preserve:

          Modem-sleep, Light-sleep, Deep-sleep, Hibernation and Power off.

          During the real deep sleep the RAM is shut off. So your variable Bootcount will get lost after the deepSleep . You must write the values of all the variables you want to preserve into Eeprom (eg. of the RTC) before going into deep-sleep and the retreive them after wake up !

          1 Reply Last reply Reply Quote 0
          • R
            robalstona
            last edited by

            The esp in sleep mode consumes almost no power at all, but all the rest can additionally draw a few mA. In the link you have a discussion about what and how much electricity it draws additionally.

            http://community.m5stack.com/topic/1162/getting-longer-battery-run-time

            1 Reply Last reply Reply Quote 0
            • P
              Pepsi
              last edited by

              it also depends on the clock speed. sometimes speed is not needed. and it can save 50% of the power consumption on max CPU load
              https://www.savjee.be/2019/12/esp32-tips-to-increase-battery-life/

              1 Reply Last reply Reply Quote 0
              • First post
                Last post