Skip to content

M5ToughC5: getWakeSource() always returns 0 #431

Open

Description

@felmue

Observed:
On M5ToughC5 the wake source value returned for any wake source (power button, timer, ...) is always 0.

Expected:
The reported wake source should match the actual wake source as defined in m5pm1_wake_src_t in file M5PM1.h.

Code:

#include <M5Unified.h>
#include <M5PM1.h>

M5PM1 pm1;

void setup(void)
{
  uint8_t wake_source = 255;

  M5.begin();
  pm1.begin(&M5.In_I2C, M5PM1_DEFAULT_ADDR, M5PM1_I2C_FREQ_400K);
  pm1.getWakeSource(&wake_source, M5PM1_CLEAN_ALL);

  M5.Display.setTextSize(2);
  M5.Display.printf("Wake Source: %d\n", wake_source);
}

void loop(void)
{
  M5.update();
  if(!M5.Touch.getCount()) return;

  M5.Display.println("Power ON after 5s");
  delay(1000);
  pm1.timerSet(5, M5PM1_TIM_ACTION_POWERON);
  pm1.shutdown();
}

Libraries used:

M5Unified: 0.2.29
M5GFX: 0.2.36
M5PM1: 1.0.7

Thanks
Felix

Activity

  1. ainyan03 commented on Nov 5, 2026

    @ainyan03
    Contributor

    Thank you for the report. The fix is merged into the develop branch and will be part of the next M5Unified release. It is not in a release yet.

    What to do after updating

    Read the wake source through M5Unified instead of the M5PM1 library:

    M5.begin();
    uint8_t wake_source = M5.Power.M5pm1.getWakeSource();

    The bits are the same as m5pm1_wake_src_t, for example 0x01 for the timer and 0x04 for the power button. It returns 0 when no reason was recorded, for example after a reset.

    Why the value was 0

    M5.begin() has to clear the PM1 WAKE_SRC register on ToughC5, because the PM1 IRQ output stays low until it is cleared. Anything that reads the register afterwards gets 0.

    M5Unified now keeps the value before clearing it, and getWakeSource() above returns that kept value. The register itself is still cleared, so this behavior does not change.

    About M5PM1.h

    M5PM1.h belongs to the separate M5PM1 library, which is not part of M5Unified. M5Unified does not use it, so pm1.getWakeSource() from that library still reads the register directly and still returns 0 after M5.begin(). Reading it before M5.begin() is not something M5Unified supports.

    Details are in #432. The M-Bus pins of ToughC5 were also added to getPin() there.

  2. felmue commented on Nov 6, 2026

    @felmue
    ContributorAuthor

    Hello @ainyan03

    thank you for the quick fix and the detailed explanation. I appreciate it.

    I tested and verified the fix using M5Unified 0.3.0 (alongside M5GFX 0.3.0) and I can confirm that reading the wake source via M5.Power.M5pm1.getWakeSource(); reports the correct wake source.

    Thanks
    Felix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions