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.
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.
@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.
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.
@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.