I was thinking about the accuracy of the battery measurements the other day, are these accurate or not? I measured the battery using Fluke 27 multimeter and compared that to the readout using the internal bangap method and found a small difference. Googling on the subject revealed that the supposedly 1.1V internal bandgap reference can actually vary. The Atmega328 datasheet states it can be anywhere between 1.0 and 1.2V, which is a pretty big margin:
That variation means slightly inaccurate ADC measurements too because you rely that the internal bandgap is exactly 1.1V when doing Vcc measurement to back calculate the ADC reading to voltage.
Another thing that Google revealed is that Glyn and Trystan from openenergymonitor.org have had exacty the same concerns recently, they even put together a calibration sketch. The sketch requires that you manually measure the Vcc using a multimer and compares that against Vcc measured assuming 1.1V bandgap voltage. This way it is able to calculate the exact bandgap voltage for that particular chip. You can then use that calibrated value to correctly measure the Vcc. The chip that I calibrated had a Vbg of 1.056V.
Interesting stuff, maybe an overkill for most home DIY projects, but good to know.
Page views: 4021