According to http://support.sodaq.com/sodaq-one/battery/ it is possible to read the battery voltage with a call to analogRead() on the SODAQ One (the original, not the v2).
Certainly doing so returns a somewhat realistic number, but I can’t for the life of me figure out why this would work!
The schematic shows no connection from the battery voltage to an analog pin (unlike the v2 schematic, which clearly shows a batt voltage measurement).
Calling print() on BATVOLT_PIN returns 36, but pin 36 is VDDIO2 and certainly not an AIN pin.
Is there a part of the schematic missing? Is there a way to inspect the definition of BAT_VOLT? Where are BATVOLT_R1 and BATVOLT_R2? Is this all done on the One board or does it need the Base board?
Sorry I clearly haven’t explained myself properly. There is absolutely no question about what a voltage divider is. I got that 20 years ago.
The question is… where is the voltage divider? R1 and R2 on the schematic have different values to the constants in the sample code and are not connected to an analog pin.
What does BAT_VOLT refer to? Which pin is used? How is that pin connected to the battery voltage? Is there a way to inspect the BAT_VOLT source in case there’s any clues there?
I see the Rev4 schematics have already been posted on the support page and now that I’ve found those board files(1), it all makes sense!
I see now that Arduino “pin numbers” have no relationship to IC pin numbers, so BAT_VOLT being 36 doesn’t tell you much without reading variant.cpp. As westfw describes here, Arduino pin numbers tend to follow a pattern to some extent, but can be entirely arbitrary.
By reading variant.cpp I see that BAT_VOLT corresponds to PORTA, pin 5, which is IC pin 10, which is assigned to AIN5. And as the new schematic clearly shows, that’s connected to a 2M/2M voltage divider of the battery voltage!
Thanks for your help. Amazed I’m the first to ask.
On macOS, they’re here: /Users/<user>/Library/Arduino15/packages/SODAQ/hardware/samd/1.6.11/variants/sodaq_one/