How to save battery with M5StickC

  • 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.Lcd.println("Boot number: " + String(bootCount));
      M5.Lcd.println("Going to sleep now");
    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.