# How to measure voltage across (pre-charged) capacitor using an MCU?

I have a pre-charged capacitor of which I want to read the voltage from using an MCU. The ADC pin can read the voltage of a separate supply but it gives very high values when I try to read the voltage across the capacitor using a voltage divider. Using a multi-meter I can for example read out 2V across the capacitor but my MCU gives the wrong value. Is it because I need somehow a ground connection or so?

SUPPOSE THE VOLTAGE ON THE CAPACITOR GETS EMPTY after for example 10 minutes so not that is drained in 1 second...

• Why should we assume the bold text is true? Given this circuit it will get "drained" very fast. And you should show how you connect it to the MCU. Jun 23, 2017 at 14:35
• If your happy with how a multimeter behaves design for the same 10 Mohm input impedance, you'll need a cmos buffer driving your adc input at those R values. Jun 23, 2017 at 14:40
• Bold text is true if resistor values are very high, so lets assume it won't get drained very fast. +to MCU connected to ADC pin of MCU and -to MCU connected to GND pin of MCU. @sstobbe you mean put 10 Mohm in series connection to +to MCU ? Jun 23, 2017 at 14:43
• @BrianvanKan So why wouldn't you show us the real diagram? With real values? Jun 23, 2017 at 14:45
• Your multimeter has an R1+R2 total of 10Mohms so you should aim for at least that if your happy with how a multimeter loads your cap. Note the current going into the ADC pin of your MCU is not zero and is loading your divider network. A buffer cmos opamp would be the natural candidate. Jun 23, 2017 at 14:48

Your two 100 ohm divider resistors will in fact reduce the voltage of the 1 uF capacitor to 50% of its original value in 0.13 milliseconds. You likely will not be able to charge the cap and take the reading fast enough to make this an effective circuit.

To improve your measurement technique, keep each resistor at a value of about 1/10 of the input impedance of your ADC. So if your ADC input impedance is 100k, use 10k resistors. With these resistors, the capacitor will still be at 99% if its original voltage in the same 0.13 milliseconds later.

A formula that is helpful to know is the following:

VC = VS*e-t/RC

where VC is the voltage across the capacitor at time t, VS is the voltage to which the capacitor was initially charged, t is the time in seconds, R is the resistance in ohms, and C is the capacitance in farads.

From this you can calculate that if you charge the cap and then wait t seconds to take the reading, you know what voltage to expect across the cap. A simpler version of the formula tells you what % of charge remains on the cap after some time has passed:

% of original voltage = e-t/RC*100

And finally, a comment about your schematic. The bottom leg to which the ADC is connected (shown as ADC -) must be grounded unless you have a differential ADC on your uP, which is very rare.