Hi, this is about measure of VCC.
The bug (?) in board support lib package - currently Larduino_HSP_v3.6c still has it.
To measure VCC, one can use internal mux channel to internal VRef=1.024V (default),
by A/D reference=VCC, default. analogReference(DEFAULT);
uint16_t AtoD = analogRead(IVREF); // IVREF=27 for lgt8f
Then, calculate VCC=(1.024/AtoD)*4096; //Volt.
or else, VCC=4194304/AtoD,mV. (0x400000/AtoD)
For original AVR' 328p, instead of 4096 use 1024, for AtoD is 10 bit.
Currently, for lgt8f the code do not work, analogRead(IVREF) returns 0..2.
To fix the problem, need set the bit BGEN, bit7 in register ADCSRD,
ADC Control Status Register D.
e.g.: ADCSRD = 0x80;
Then, AtoD of IVREF: uint16_t AtoD = analogRead(IVREF);
will return correct value. e.g.:
for VCC=3.36 V, analogRead(IVREF) returns 1249. VCC=1.024/1249*4096=3.358V
for VCC=4.72 V, analogRead(IVREF) returns 889. VCC=1.024/889*4096=4.718V