I’m trying to read the battery voltage on pin A7, but the highest the value ever goes when the charger hardware reports the battery is fully charged is 212 of 1023. If I hook A0 to v3.3, the analog reading 1023 of a possible 1023.
Is there some scaling going on here with a resistor that I should be taking into account, or am I doing this wrong entirely?
The code I am using (based on the ReadAnalogVoltage demo):
If you take a look at the schematic there a voltage divider with two resistors: 10M and 2M, and in the middle is connected the A0 pin. If you’re using default analog reference, it means that your 212 measure corresponds to: (3,3/1023)*212 *(12/2) = 4.1V (the 12/2 factor is the voltage divider you’ve to undone in your calculation).
If you want/need more accurate reading of the voltage, I recommend you to change the analogReference to INTERNAL and do the previous math with 1,1 volts instead of 3,3