Easy MG24 battery measurement

pinMode(PD3, OUTPUT);
digitalWrite(PD3, 1); //enable VBAT to ADC switch

int mv = (analogRead(PD4) * 1000) / 610;
Serial.print("Battery mV = ");
Serial.println(mv);

edit:
if (mv < 3500) { //still above 3300 so no ADC issues
//TODO shutdown what you started
digitalWrite(PD3, 0); //disable VBAT to ADC switch
//beware not all pins work, you might need C0 escape_hatch (4 didn’t work)
LowPower.attachInterruptWakeup(5, nullptr, FALLING);
LowPower.deepSleepMemoryWrite(0, saved_variable);
LowPower.deepSleep(); //this resets the board when waking
}

ACCU-ICR14500.pdf.zip (908.6 KB)
From this datasheet even 3v3 is close to discharged, I’m using about 200mA max so 3v5 is a good shutdown point. Also a form of overcurrent protection to prevent 3A draining the battery too fast extending battery lifetime.

1 Like

Hi there,

So that’s great if it works, But let’s keep it in one thread NO need to spread it around.

GL :slight_smile: PJ :v:

Hi

In the other thread it was way at the bottom of the discussion and somewhat harder to see.
So I put this one in the solutions forum and just left it as an answer.

1 Like

Hi there,

So that’s not how it works here… Keep it in one thread.
Thanx.

GL :slight_smile: PJ :v:

This method uses the default AD converter settings, Vref=3.3V(VDD), analogGain=1. With this method, battery voltage cannot be measured in the range of approximately 3.4V or lower.

To measure down to the range below 3.4V is discussed in the following link

1 Like