I am trying to make an AC voltage reading system according to the circuit below which I found online.

My voltage is coming out cyclical - why is that? Is the capacitor perhaps to blame for not discharging quick enough?

Wiring diagram:

Below is the BOM used:

• One 12-0-12 transformer
• 1N4007 diode
• 1uf capacitor 400V
• Resistors 10k; 4.7k.
• Zener diode (5V)
• Arduino UNO
• Connecting wires

It's a beautiful pattern but just useless.

Below is the plot when I remove all delay in sampling, 9600 baud rate:

Below is my plot, 115200 baudrate, no delay:

• Probably too high voltage? May 26 at 12:14
• @Antonio51 But after rectification it should give a straight line, right? even if its higher than standard. In my country the domestic voltage is 220V ac. I have used a step down transformer to step it down to 12 volts. I checked, the variance isn't too great from 12 V. May 26 at 12:19
• Not really constant. Add a discharge resistor, say 1k? May 26 at 12:23
• 50ms is too slow for line voltage reading. You are getting aliasing on the ripple. May 26 at 12:33
• Try working at higher speed rs232. 115 k without delay. May 26 at 12:36

Yes you are simply reading the ripple on you capacitor. Also your source impedance toward the converter is quite high (more than 3kΩ) so it's possible that your ADC is starved and cannot sample properly.

What you have built is actually an envelope detector, a quite useful circuit in its own. You are charging your capacitor thru D1 but it can only discharge through D2's leakage and the input impedance of the ADC.

I'd expect to see the big triangular ripples (look at the frequency, it should be twice your mains frequency) but not the oscillation inside; this is quite strange.

Try to reduce the input divider resistor to lower the impedance (4.7k and 2.2k are more or less half the one you are using)

It's even possible that the wiring is picking up noise; lowering the impedance would help with that too.

• I am using the code delay(50). Maybe that is why the oscillations? So are you saying I should change 4.7K to 2.2K. May 26 at 12:33
• if you are using a delay then it's simply an aliasing artifact (search for sampling theorem). The outer ripple however remains, you can also try a bigger capacitor May 26 at 12:40
• Like a 10uF capacitor? And I still have to reduce the resistance to 2.2K? I have updated my question, you are right, when I remove delay only the outer ripple remains. I tried 115200 baudrate at another recommendation, the outer ripple is clearly visible. May 26 at 12:44
• well if only the envelope remains you have solved the problem. depending on your need you can average or find the peak or whatever you need from your waveform. search for "diode envelope detector" to tune your values, you could add a resistor to the output to stabilize the time constant May 26 at 12:55
• It's a half wave rectifier, so the ripple should be the same as the mains frequency. May 26 at 13:27

If you want a good filtered voltage, you can try this ... "Little" ripple.
R3, R4 used to adjust voltage for Arduino.
NB: I forgot ... the time for a "good" value is ... 2 s.

• Being new to electronics this is going to take a moment for me to understand. Why have you taken out the zener diode? ALso, I understand R1 =R2 =R3 =500ohm, but what is the value of R4? And how to know the polarity of a transformer? I thought AC did not have any polarity, my transformer does not even have color coded wires. May 26 at 15:19
• If R3 and R4 are "well-chosen", voltage is always in limit for ADC input (ok, take a margin). R1, and R2 are lower for charging C1 "more" faster. No worries about polarity "+" on "my" generator, it is indicated because it says that the first starting half "wave" is positive when phase = 0. May 26 at 16:14
• Just one clarification, the connection to arduino analog pin needs to be at Vo, right? May 27 at 4:36
• Yes, right. it is the output of the "system". Always check that voltage is not greater than 4V if the Arduino supply is 5V, or 2.8V if 3.3V. May 30 at 10:44
• alright...got it. thanks. Jun 1 at 5:40

In the wiring diagram the 1uF cap is connected with wrong polarity. Using it that way introduces a large inner leakage current with fast discharge rate. And it will destroy the cap on the long run.

• Please forgive if this query appears too simplistic. My capacitor has a long leg and a short leg. The long leg I understand is the positive pole. But how to know which is positive and negetive pole of the Transformer? My transformer isn't color coded. And isn't ac supposed to keep shifting polarity unlike dc? May 26 at 15:14
• @tiktok: This does not depend on the transformer, it delivers AC. Your diode creates a positive voltage relative to GND and you must connect the cap in the same polarity = short leg to GND. The symbol in the wiring diagram shows a white marker as indicator for the negative pin and this must be the other way round.
– Jens
May 26 at 16:30
• aha...ok. got it. Didn't know that about diodes. Thanks for the knowledge, will keep in mind. May 27 at 3:34

If you want a "circuit" that gives (within one-half period) the voltage, use something as the first part of this schematic (some adaptation is needed).

The idea is to phase 90° the voltage input, then compare to the ground with an op-amp, and then sampling with ADC at the rising or falling edge (positive or negative voltage) of the comparator ...