So here are my measurements. I replaced the battery by an OTII tool, range 1uA - 5A
Power Off (long press on power switch): 1.92 mA
esp deep sleep (wifi/bt/adc): 8.37 mA
LDO2/EXTEN off: 6.68 mA
DC-DC1, OLED_VPP, 5V V_Ext: 2.43 mA
Disable battery charge: 2.44 mA
Diable Coulomb meter: 2.44 mA
Bias: register 35h: 200 uA for charging RTC which is not disabled
So there is obviously something consuming more power than it should. @m5stack , did you measure power consumption ? I am surprised that we have 1.92 mA in "AXP 192 power off state".
There is also 0.5 mA from something activated after AXP.Begin() as the power consumption stays at 2.44 mA instead of 1.92 mA. It is not the esp32 as I measure a consumption of 4.5 uA with the same sleep code with an esp32 dev board.
Here is the code I used:
uint8_t AXP192::SetSleep2(uint8_t reg)
// Disable LDO2 (OLED_VDD) and EXTEN (?)
// Those 2 bits seems to be a copy of 0x12. To be tested
buf = readI2C8(0x10);
buf &= 0b11111010;
writeI2C8(0x10, buf);
// Reset ADC to default state.
// Test to set 0x00 ?
writeI2C8(0x82, 0x83);
// Disable DC-DC1, OLED_VDD, 5B V_EXT
// DC-DC2 and EXTEN should already be disabled
writeI2C8(0x12, 0x00);
// Disable charge
buf = readI2C8(0x10);
buf &= 0b01111111;
writeI2C8(0x33, buf);
// Disable Coulomb meter
writeI2C8(0xB8, 0x00);
// // Disable ADC GPIO0
buf = readI2C8(0x90);
buf |= 0b00000111;
writeI2C8(0x90, buf);
// Sleep bit
buf = readI2C8(0x31);
buf = (1 << 3) | buf;
writeI2C8(0x31, buf);
}
uint8_t AXP192::readI2C8(uint8_t reg)
{
Wire1.beginTransmission(0x34);
Wire1.write(reg);
Wire1.endTransmission();
Wire1.requestFrom(0x34, 1);
return Wire1.read();
}
void AXP192::writeI2C8(uint8_t reg, uint8_t data)
{
Wire1.beginTransmission(0x34);
Wire1.write(reg);
Wire1.write(data);
Wire1.endTransmission();
}
void myDeepSleep(gpio_num_t PIN)
{
// Rewrite M5.Axp.DeepSleep() in order to enable ext0 wakep up.
esp_sleep_enable_ext0_wakeup(PIN, LOW);
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_AUTO);
esp_wifi_stop();
adc_power_off();
M5.Axp.SetSleep2();
esp_deep_sleep_start();
}