• I want to use the PowerC as a backup battery for the small internal.
    I use your program example and it works.
    After switching on the PowerC I can see the external Vbat and seconds later PowerC switches off and I can see the internal Vbat. This is not the expected behavior. Additionally, the switch loses its membrane already (after 20 presses).

  • @ckuehnel After reading the Data Sheet for the charging IC on the PowerC module, It is triggering the low load cutoff. The M5Stick draws only about 10-20mA and I think the shutoff threshold is 100mA. I'm currently fixing the PowerC example code since the current and voltage calculations aren't taking into consideration that the data is a 14bit two's complement number when converting to 16bit signed.

    I'm looking at ways to keep the PowerC turned on and two come to mind. One would be to turn off/lower the auto shutoff threshold. Some problems with this are that if the M5StickC shuts off, it leaves the pack on indefinitely or goes below the recommended threshold of 100mA which could cause the pack to fail to shutoff due to drift in the current measurement or turnon randomly. I think at least disabling the shutoff might be worth it if using the StickC in an always on role or Deep Sleep with periodic wake ups from the RTC. I'm not sure how much power the PowerC uses when the StickC is asleep.

    The other idea I'm playing with is to set a periodic interrupt to repeatedly set the Low Load Shutdown Timeout to the max value. My thinking is that it might reset the countdown timer for shutoff every time you update it... That way if you turn off the M5Stick, it'll allow the powerC to shut off. I'm currently writing the code, so I'll let you know how it goes.

    IP5209 IP5109 IP5207 IP5108 I2C registers.pdf




  • Thanks for posting that info, djhopkins2, it's hard to come across!
    I have found that this function keeps the board from shutting off after a few seconds, but I only started using an hour ago; I don't know if it has any adverse effects on the hardware yet:

    void disable_shutoff() {
      return M5.I2C.writeByte(0x75, 0x02, 0x00);

    Also, here are the corrected voltage and current functions alluded to above; I don't think the voltage can go negative, but the current certainly does, and displays meaningless values without this correction:

    int16_t readBatV(uint8_t Reg) {
        uint8_t dataV[2] = {0, 0};
        M5.I2C.readBytes(0x75, Reg, 2, dataV);
        if(dataV[1] & 0x20) dataV[1] |= 0xC0;   // 14 bit 2's complement to 16 bit
        return (dataV[1]<<8) | dataV[0];
    int16_t readBatI(uint8_t Reg) {
        uint8_t dataI[2] = {0, 0};
        M5.I2C.readBytes(0x75, Reg, 2, dataI);
        if(dataI[1] & 0x20) dataI[1] |= 0xC0;   // 14 bit 2's complement to 16 bit
        return (dataI[1]<<8) | dataI[0];