I do micro-controller programming, but I'm not very good in electronics. I'm trying to read some circuits to understand what I'm building. Through that I came across the attached circuit.

I couldn't understand it and I don't know how it could be connected directly to the ADC of micro controller as the controller can't handle voltages more than 5V.

Could someone explain it or at least give me a hint as to what I should look for to understand it?

measuring voltage

  • 2
    \$\begingroup\$ I can guess, but where is the microcontroller's ground? Adding where you found the circuit would help. \$\endgroup\$
    – ErikR
    Jun 21, 2021 at 10:59
  • 1
    \$\begingroup\$ horrible circuit - don't build and use. First of all it is putting over 300V peak across R6/RV2/R7, one of which is a pot/preset for manual adjustment. Second values of R6/R7 seem to be swapped so lots of that DC will likely go straight into ADC. No protection, no power ratings for resistors, no working voltage for C2 ... nasty! and direct connection to AC mains to boot - whoever posted this needs a severe telling off. \$\endgroup\$
    – danmcb
    Jun 21, 2021 at 11:07
  • \$\begingroup\$ Even though you say you are inexperienced with electronics, it looks like your bullshit detector is working well enough. Don't use this circuit. Even if let the micro circuit float somehow, so it doesn't burst into flames, this circuit is a blueprint for killing inexperienced users.. \$\endgroup\$
    – tobalt
    Jun 21, 2021 at 11:13
  • \$\begingroup\$ the point is that i took this circuit as a portion of a voltage stabilizer control circuit and it is working. thats why i made this post \$\endgroup\$ Jun 21, 2021 at 12:19

4 Answers 4


You would do well to first understand the operation of a basic bridge rectifier and filter cap circuit, which is what this is based on. Lots of stuff on the web, here is one.

Secondly, the circuit you have posted is DANGEROUS! Do NOT build this! It's a horror story that could result at least in smoking components, and quite possible in electric shock. Why?

  1. direct connection to mains - a no-no unless you REALLY know what you are doing.
  2. can put possibly lethal DC voltage or so straight into your uC circuit which will blow the lid off it and give you a very unpleasant and possibly fatal electric shock.

I'm not sure what the context or source of thsi diagram is, but it's really bad news.

(And by the by, AC electric shock is bad enough, high voltage DC is even worse.)

EDIT : IF you want to monitor mains volts this way, the way to do it would be via a proper mains rated stepdown transformer, perhaps 220 to 3V ac. Then you have the required isolation from line voltage, and also reduce the working voltage down to a safe level.


This circuit is bad and very dangerous for equipment and life.

If you want to sample the mains voltage with a microcontroller there are a few way you can use:

  1. a small transformer that converts mains to e.g. 12 AC, then use voltage dividers to bring it down further to your ADC input range. Quite safe, although you still have mains voltage on the primary side of the transformer of course.
  2. a capacitive dropper. Basically a voltage divider with capacitors. These caps need to be rated for mains safety explicitly. Less safe and not recommended for tinkering with micro circuits. Caps are smaller and less encapsulated than transformers, so it is easier to accidently misconnect something.
  3. probably there are a few isolated ICs which are made specifically for this purpose.

You are correct. That circuit is not what you want.

If you simulate it, you will see that it outputs a very high voltage:


simulate this circuit – Schematic created using CircuitLab


enter image description here

It takes a few seconds to get there, but you'll get nearly 200VDC out of that thing.

That circuit is a bad idea for a couple of reasons:

  1. The output voltage is much too high for an ADC input. You'll need to reduce it with a voltage divider (at the very least) and probably provide some overvoltage protection as well.
  2. The circuit is not isolated. Using it puts your whole circuit at 220VAC. Touch the wrong place (even on the supposed low voltage side) and it can kill you. Connect it to another device incorrectly, and it can destroy that device and maybe kill you at the same time.

A correct method to measure AC line voltage with a microprocessor has to consider more than just the input voltage. It has to consider safety and isolation. I'm pretty sure I could build something that wouldn't scare me to use but which would still provide usable results. I'm not sure I could provide you with a design that covers everything, so I'm going to stop here.


Since you used the word "sampling" here, I would like to add my opinion here.

I work in high power electrical measurements industry. We measure voltages as high as certain kV and MV and also currents as high as few hundred amperes. For HV measurement we use a 'probe' that looks like a long thick dart with wires coming out on the other side. It sounds fancy but actually the circuit is quite simple. There are a few dozens 1/4W resistors inside the probe forming a simple voltage divider. Now you can divide the voltage using 2-3 resistors but to withstand high voltages and powers it is recommended to use lot of resistors so that power they can withstand adds up. The voltage probe divides voltage by factor of 1000. That means at 1kV it outputs 1V. So if you simply connect a DMM on the output you'd have to use AC measurement feature to get the voltage in kV converted to equivalent number of volts.

Method 1: In your application you can keep this thing in mind and get the voltage division in similar manner. Division factor of 100 is something you might want but the divider you build must be a series of several smaller value resistor probably 5-10 to improve the power rating instead of a single large value resistor.



About Voltage Dividers

Method 2: If you use programming efficiently you can skip the rectifier (4 diodes). All you need to do is take samples of your divided AC signal at least at the rate of 20 times (Nyquist's theorem) your AC frequency. You can either store these samples or just use them to find the peak voltage on both sides (+ve peak and -ve peak) and then discard the samples. All this obviously if your ADC allows the said high speed sampling rate. You'll be needing to take samples for a couple of seconds to be accurate.

Nyquist Sampling Theorem

Method 3: What would be better is if you added a step down transformer to drop the voltage before the voltage divider (to about 10-20V) and tune the divider accordingly, you'll have lesser risk of burning your Micro controller circuit. The output of step down transformer will be directly proportional and linear to input voltage. Just make sure you get a good quality transformer. Then you can convert it to DC using capacitors and zener diode to measure directly using micro controller.

Also I would recommend using buffer amplifier rather than feeding the voltage directly to micro controller. This would give you a chance at calibrating the results and high input impedance of your controller circuit.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.