Can Argon (or Xenon) Read the Battery State?

Looking forward to my new Mesh generation devices arriving and wanted to start prepping some code. One of the things I was looking for in the reference documentation was how to read the state of the battery connected to the Argon (or Xenon) but did not see anything about it.

Is this even possible? It is by no means a show stopper for me but it definitely does put a bit of a twist into one of my main uses cases (the device was going to determine when it was running low, charge up, then get back to work until it runs low again). Obviously there are workarounds possible but with the integrated battery charger and battery header I figured there must be a way that the battery state could be determined natively.

1 Like


It looks like pin P0.05 on the Xenon is used for reading the LiPo voltage.

We just need some code to read this pin and format it, so the voltage reading makes sense.

CHRG Status may be the pin feeding the yellow battery charging LED. Not sure if we can read this pin status via code also or not?

@rickkas7 I’m sure has already done this and may be able to shed some light on the best way to do this.

1 Like

Looking at the schematic section of the datasheet P0.05 does appear to be connected as an input for battery detection in the NRF52840 section. Although it does not look to be broken out as one of the “normal” I/O pins… so I am not sure how it could be read without some underlying API call.

Only a Boron comes with a Fuel Gauge for you to check the SOC of the battery.

How about just reading the battery voltage, that’s what the pin is for right?

Or was that pin never broken out to be used and was left in the schematic drawling?

Good news, have fun :slight_smile:

I measured 3.97V on my multimeter and the analogRead() says 3.92V

Still within 1% tolerance i guess :smiley:



Are the resistors built onto the devices or did you add them externally?

It’s internally available.



Thanks for the example code!

Thank you very much! Good to know that part of my project will be reasonable to do.

@kennethlimcp For your voltage divider calculation you have R2 = 2100k, but from the schematic the corresponding resistor divider is actually 2M & 806k. A bit of error will creep in due to that.
The labelling on the Xenon schematic is a bit confusing as it says 2M1%R16 - but that appears to just be a lack of separating spaces between 2M / 1% / R16. You’ll see the same 1% text on R15, the 806k resistor, and the same components & values on the Argon schematic with a little bit more spacing on the text.


Thanks for pointing out! I’ll fix it :slight_smile:


The multiplier changes from 1.3838 to 1.403, and your analogRead() example above would now be spot on at 3.97.


I’m sure I’m just being dense, but where is the BATT variable defined?

That’s a #define in the system firmware that represents the corresponding pin number (P0.05 = port 0 bit 5).
I’m not sure if that part of the code is already open sourced, but if you want to know the numeric value, you can always use Serial.println(BATT) to read that out - AFAICT it’s 24 for Xenons and 33 for Argons.

Thanks fellas.

@ScruffR, Should this be available on the Boron? I may be missing something obvious, but for me Serial.println(BATT) says " ‘BATT’ was not declared in this scope"

I was looking at reading the battery states on the mesh devices last night. The Electron, the closest comparison to the Boron, uses a “FuelGuage” class to get richer details on the battery state. That Fuel Gauge class is missing on the Boron reference docs at the moment. I don’t think they implemented that yet.

fuel.getVCell(); woks on the Boron.