# How do you generate a reference voltage in a circuit?

Hi Im very new to electronics and had a pretty basic question about voltage reference.

So Ive finally understood that in order to check a voltage in most circuits, a voltage reference is used. The way i visualize this is a chip having 5 wires; the first 2 go to the battery which the voltage needs to be measured, another 2 go to a steady power source(the voltage from the first battery gets compared to this steady source and a voltage reading is obtained) and the last wire is an analog wire(ex. to use on arduino for displaying the voltage read).

I know that if i use only 1 battery for both the voltage readings and to power the voltage reference chip, i will always get a value of 1023, because the voltage measured is always compared to that same value giving a max voltage all the time.

With this in mind my question is: How do i use only 1 power source(in this case the battery, without the steady power source) to power the whole circuit and read the voltage of that same battery? Im basically asking how for example phones are able to measure their battery voltage even without a mini battery powering the voltage reference circuit. Thanks in advance.

• i think that the whole paragraph, that you have written, is asking how do you generate a stable reference voltage in a circuit? ... can you please edit your question to make it "simpler". – jsotola Dec 19 '17 at 0:41
• Haha sorry for the length, i wanted to be as precise as possible – Donsa Dec 19 '17 at 0:43
• it could possibly be broken into paragraphs but it seems clear enough what you want to know,.. – Jasen Dec 19 '17 at 0:45

You want to know how to measure the battery voltage that's powering the analogue to digital converter. well unless you can use a different voltage as the anaglogue reference voltage you can't

You want to know why you get 1023 (the highest ADC reading possible on your device) - that's because the battery voltage is equal to (or higher than) the reference voltage.

So what can you do?

One option is to get a reference voltage source to provide a fixed "V_AREF" supply to the ADC. this is often using a shunt reference (more on that later) this will produce a lower voltage than the battery gives, so you also need to reduce the battery voltage (eg. using a resistive divider to reduce the battery voltage by some ratio) so that it falls inside the new measurement range of the ADC

another option is to get use the battery voltage as reference and mesure a known lower voltage "VREF" that is less than the battery voltage and measure that with the ADC

Eg. The VREF is 1.25V you measure it and to comes out at 315 on the ADC. you then do some arithmetic: if 1.25V is 315 what voltage would be 1023 ? 1023 / 315 * 1.25 =

This is a good method because you can power the voltage reference source from one of the GPIO pins, so when you don't need it you can turn it off so that it doesn't consume energy.

The voltage reference could be something cheap like a LED, or a precision reference like TL431CLPG depending on how much precision you need.

• Ok finally, super helpful, that all makes sense but i have a question at this point. I was also building a boombox and wanted to see the battery voltage(its a 12v lead acid 7ah); they sell these little car usb which also display the voltage. It doesnt come with any battery and only plugs in the 12v car plug, how does that work? Do you think it has a little battery inside that gets activated with the 12v? Or maybe i thot about a capacitor(could be completely wrong but i thought that since capacitors store energy for x time then they could be used as voltage reference?) Thank you – Donsa Dec 19 '17 at 4:41
• Here amazon.com/gp/aw/d/B010HM43RQ/… is what im talking about, that thing is super cheap so i doubt it can have a battery inside, so how does that read the voltage? – Donsa Dec 19 '17 at 4:51
• You really ought to have asked this as a separate question, but... (1) Use voltage regulator to supply the ADC with a known stable supply. (2) Use a pair of resistors as a voltage divider to produce a known fraction of the battery voltage. For instance, if you measure that 1/4 of the battery voltage is 2.95V, then the meter should display 11.8V. – Simon B Dec 19 '17 at 9:39
• Man ive been trying to find that out for 2 weeks of continuous thinking...thanks youre a life saver ;) – Donsa Dec 19 '17 at 20:02