Core2: AXP2101 giving false values



  • Hi there,

    I have a problem getting my arduino program to work on my new Core2 with an AXP2101 power management chip. The exact same code works properly on an older Core2 with an AXP192.

    When I request M5.axp.isCharging(), this value always stays 1, also when it is not plugged in. Also GetBatPower() and GetBatChargeCurrent() give incorrect values. It seems that the arduino Core2 library is not up-to-date..
    Can anyone help me and tell me how to get the correct data?

    Thanks a lot! Tjeerd



  • Hello @TuigWerk

    these functions are not (yet) implemented for the AXP2101. For instance isCharging() always returns true. See here.

    Maybe have a look at M5Unified library. isCharging() seems to be implemented here.

    Thanks
    Felix



  • Hi @felmue , thank you very much for your help. With that I was able to add some lines to the axp2101.h and axp2101.cpp of the Core2 library. I can now successfully check .isCharging() of the axp2101. I am will try to do the same thing for other functions..

    Thanks again!

    added to axp2101.h:

    bool isCharging(void);
    

    added to axp2101.cpp:

    bool AXP2101::isCharging()  {
        uint8_t registerValue = readRegister8(_addr, 0x01, _speed);      
        return (registerValue & 0b01100000) == 0b00100000;
    } 
    

    Changed in axp.cpp:

    bool AXP::isCharging() {
        if (_pmic == pmic_axp192) {
            return axp192.isCharging();
        }
        if (_pmic == pmic_axp2101) {
            return axp2101.isCharging();
        }
        return true;
    }