How to read 3v3 pin voltage with code?

You can setup another voltage reference less than 3.3V and read that–it needs be a true voltage reference IC or Zener, not a resistor divider from 3.3V. Maxim and TI and others make precision voltage references. Then when you get your reading you can backward calculate what the 3.3V reference for the ADC had to be. Here is an example:

Let’s say you have a 2.5V reference on A0. If the 3.3V supply was correct, you would have 2.5/3.3 * 4095 = 3102 ADC value. Now lets say the 3.3V supply is really 3.2V, you should get 2.5/3.2 * 4095 = 3199 ADC reading. Similarly if the 3.3V supply is 3.4V, you get 2.5/3.4 * 4095 = 3011 ADC reading.

So the to backward calculate this you take your ADC reading, you calculate (Vref * 4095)/ADC in floating point. Let’s say you read 3050 from the ADC with 2.5V reference, then you calculate (2.5 * 4095)/3050 = 3.356 V.

If this is a one-time thing, you should just buy a better multimeter!

3 Likes