Sorry, the theory of how to measure the voltage still doesn't make too much sense to me. Have I got this right:
- Typically the internal voltage for my mini pro would be 1.1V. This analogue value when displayed in digital is represented from 0 to 1024 (where 0 = 0V and 1024 = 1.1V)
- With the above, each "step" is 1.1/1024 = 0.00107421V
- Given each processor will have a slighting different internal voltage, each step would actually be a slightly higher or lower voltage
- I ended up finding on the spec sheet that this voltage can be measured on pin 20 of the atmega328P Au. With my digital meter, I found mine was steady at 1.087V
- This equates to a step value of 1.087/1024 = 0.0010615V
- So when a voltage (say battery) is applied say to pin A1, can the reading then be attained as a % of the reference (i.e. just under 300% if 3V)
- If that's the case, a 3V supply would say it is 276% of the internal reference, so I can work out the actual value?
jremington:
To read the battery voltage, I use a method similar to Nick Gammon's. Do not mess with AREF.
I did look at Nick's before posting this thread but it was a bit confusing for my limited code knowledge (ADMUXs and ADCSRAs). I tried to run it however in a sketch with a setup and void loop, but couldn't work out how to get it to display a voltage.
DrDiettrich:
For measuring the supply voltage two methods can be used...Unless you have the exact value for your chip, use the 1100*1024UL constant instead.
DrD, given I measure my voltage as 1.087 rather than 1.1, is the value I use 1087*1024UL = 1113088UL in JR's code above (when I get it working)?