M5CoreInk wake up by EXT0 (PIR Hat)



  • I want to wake up an M5CoreInk by EXT0 (PIR Hat).
    If I connect USB counting works. If I disconnect the USB cable the display loses its contrast and the software crashes.
    I have no idea what's wrong. A program with wakeup by timer works.
    The source is saved at https://github.com/ckuehnel/Arduino2020/tree/master/M5Stack/CoreInk_PIR.
    Any hint is welcome.
    best regards, Claus



  • Hello @ckuehnel

    try adding these two lines before going into deep sleep:

      gpio_hold_en(GPIO_NUM_12); // POWER_HOLD_PIN
      gpio_deep_sleep_hold_en();
    

    This should keep the ESP32 powered even when going into deep sleep.

    Thanks
    Felix



  • @ckuehnel said in M5CoreInk wake up by EXT0 (PIR Hat):

    I want to wake up an M5CoreInk by EXT0 (PIR Hat).
    If I connect USB counting works. If I disconnect the USB cable the display loses its contrast
    Any hint is welcome.
    best regards, Claus

    The Display loosing contrast is because you need to set the screen HV to true before writing the frame buffer to the screen. In UIFlow there is a block for this but I have no idea about Arduino.
    It sounds like the battery has not charged and so by removing the power you are killing the program.

    As you are using the Arduino, you may want to look into using the ULP to handle the PIR instead of leaving it to the main cores.



  • @felmue said in M5CoreInk wake up by EXT0 (PIR Hat):

    gpio_hold_en(GPIO_NUM_12); // POWER_HOLD_PIN
    gpio_deep_sleep_hold_en();

    Hi Felix

    This are the last commands in my setup() now - but w/o success:

      esp_sleep_enable_ext0_wakeup(GPIO_NUM_36,1); //1 = High, 0 = Low
    
      //Go to sleep now
      if (DEBUG) 
      {
        Serial.println("Going to sleep now");
        Serial.flush();
      }
      delay(2000);
      gpio_hold_en(GPIO_NUM_12); // POWER_HOLD_PIN
      gpio_deep_sleep_hold_en();
      esp_deep_sleep_start();
    

    0_1636481727413_20211109_170602.jpg
    0_1636481740807_20211109_170613.jpg 0_1636481762005_20211109_170626.jpg



  • Hello @ckuehnel

    hmm, that is strange. I've just tried your code with the two additional lines and my M5CoreInk stays in deep sleep just fine. No fading display and counting up when GPIO36 goes high.

    My guess is that maybe the battery charge in your M5CoreInk is (too) low. Have you fully charged the battery before testing?

    I don't have the PIR hat so I am only testing with a wire between GPIO36 and GND or 3.3 V. Maybe the PIR hat is using too much power?

    Thanks
    Felix



  • Hi @felmue
    It was a good idea to replace the PIR by a wire. I have tried that w/o success.
    I have prepared a Vbat measuring to see if battery is ok when USB is disconnected.
    The CoreInk had now 3588 loops w/o USB connected. The battery goes from 4.1 V to 3.721 V after all these cycles (one second each). The battery is ok.
    Thanks again.
    Claus