Page 1 of 1

Measure the supply voltage of an AVR

Posted: Mon Dec 15, 2025 5:56 pm
by pantelispv5
Hi, There. I need to measure the voltage that supplies the AVR 8bit ATtiny series using this very same MCU. Maybe I can use the Vgap reference 1.1V But I would like to ask if this can be done directly in Flowcode 11?

Re: Measure the supply voltage of an AVR

Posted: Tue Dec 16, 2025 9:37 am
by Steve-Matrix
It should be easy to measure the Vcc within Flowcode using an analogue input and the voltage reference. A web search brought up this article and this article which might be of help.

Re: Measure the supply voltage of an AVR

Posted: Tue Dec 16, 2025 10:23 am
by chipfryer27
Hi

Following on from above, I think Steve001 posted a solution in the old forum. A search there would probably be worth trying.

Regards

Re: Measure the supply voltage of an AVR

Posted: Sun Dec 21, 2025 10:20 am
by pantelispv5
chipfryer27 wrote:
Tue Dec 16, 2025 10:23 am
Hi

Following on from above, I think Steve001 posted a solution in the old forum. A search there would probably be worth trying.

Regards
My question was only how to calculate in flowcode (if this is possible without C code) the difference voltage VDD-Vbg. Thanks

Re: Measure the supply voltage of an AVR

Posted: Mon Dec 22, 2025 11:47 am
by BenR
If you have a spare ADC pin then the easy way is to connect the ADC pin to something like this.
Screenshot 2025-12-22 114355.png
Screenshot 2025-12-22 114355.png (10.59 KiB) Viewed 784 times
The diode will have a specific forward voltage drop across it, usually around 0.7V for a standard diode and more like 0.45V for a schottky. As your VCC drops the ADC reading will rise allowing you to calculate the value of VCC.

Assuming a 10-bit ADC and a 0.7V diode. ADC resolution is ((1 << 10) - 1) = 1023

Code: Select all

VCC Voltage = (0.7 / FLOAT ADC Reading) * 1023.0
A fixed voltage reference would be better then a diode but in a pinch a diode will work.

Note there is some variation of the forward voltage drop across a diode with temperature, hence why the diode isn't ideal. The resistor value doesn't really matter just keep it over 10K to reduce current usage.

If your device has an internal reference then it may be fairly simple to use this instead to do the same thing.