I am playing around with Arduino Core V2.0.2. My board is connected to the PC via the USB cable and i get this in the serial monitor:
One can see that the vcc/3 values are around 36700. Assuming 14-bit ADC resolution and 2.0V as reference we can calculate the voltage like that 36700/16384 * 2.0 = 4,4799V
However supply_V is reported to be around 13,4V. If that was true, then i would have the original Sparkfun experience 💥 😉
I believe float getVCCV(void) { return ((float)analogReadVCCDiv3() * 6.0) / 16384.0; } is wrong, as the reference voltage is not 6.0.
By changing that to float getVCCV(void) { return ((float)analogReadVCCDiv3() * 2.0) / 16384.0; } i get supply voltage values of 4,46666 V which is much more creditable. Actually my potentiometer measures 4,282 V on the VBAT pin.
Would be even nicer to actually fetch the reference voltage setting from the ADC CFG register (REFSEL field) once while booting up and store that value for later usage within getVCCV().
I am playing around with Arduino Core V2.0.2. My board is connected to the PC via the USB cable and i get this in the serial monitor:
One can see that the vcc/3 values are around 36700. Assuming 14-bit ADC resolution and 2.0V as reference we can calculate the voltage like that 36700/16384 * 2.0 = 4,4799V
However supply_V is reported to be around 13,4V. If that was true, then i would have the original Sparkfun experience 💥 😉 I believe
float getVCCV(void) { return ((float)analogReadVCCDiv3() * 6.0) / 16384.0; }
is wrong, as the reference voltage is not 6.0.By changing that to
float getVCCV(void) { return ((float)analogReadVCCDiv3() * 2.0) / 16384.0; }
i get supply voltage values of 4,46666 V which is much more creditable. Actually my potentiometer measures 4,282 V on the VBAT pin.Would be even nicer to actually fetch the reference voltage setting from the ADC CFG register (REFSEL field) once while booting up and store that value for later usage within getVCCV().