# Measuring AC voltage

Status
Not open for further replies.

#### elecaau

##### New Member
i want to measure ac voltage up to 250v rms using Arduino for over voltage protection purpose? I'm new for it . here's my circuit

am i correct? somebody help me pls! is there other way that is cost efficient?

#### MikeMl

##### Well-Known Member
Very dangerous circuit. It puts the Arduino at AC line voltage potential with no isolation.

#### SPDCHK

##### Member
Have a look at THIS page for a safer way of doing it.

#### elecaau

##### New Member
thank u bro for your help!!!
what if i put Zener diode before connecting to Arduino just i want to save money by not buying transformer

#### MikeMl

##### Well-Known Member
thank u bro for your help!!!
what if i put Zener diode before connecting to Arduino just i want to save money by not buying transformer
Saving a few coins is not worth your life or the life of the next innocent that picks up your project. An Arduino tied directly to the AC line is a death trap.

In this country, there are thousands of old transformer based plug-in power supplies available at yard sales, garage sales and thrift shops for one US$or less. Ideally, get one that has an low-voltage AC output (looks like this). Dont use a modern one that is regulated and based on a switching power supply. Otherwise, a transformer-based one that is unregulated DC output will work as well. Just use a voltage divider (or 10KΩ pot) across the output to get the voltage less than 5V for the Arduino. Last edited: #### Cicero ##### Active Member Bottom line is you need isolation from AC, be it from a transformer, or some other device like an opto. #### MrAl ##### Well-Known Member Most Helpful Member Hi, At the very least put resistors in BOTH lines of the AC line voltage source and make their values significant. For example, one 100k in each line of the AC source and then choose the other components after that. If you had 200vac input and two 100k resistors, then a 3k resistor for the bottom of the divider would give you roughly 3vac just to name one real example. The fault current is then figured as the current that might go through one resistor: 200/100000=1ma which is still a little high, so maybe use 200k resistors or something like that and choose the bottom resistor as 6k. Again this is a simple example using 200v but you have 230v i guess so it will be slightly different. It's not as good as a double isolated transformer (usually to meet the required electrical code) but at least it limits the fault current to something that will not be as deadly as an accidental direct connection to the AC line. A second issue that comes up in AC measurements using diodes to convert to DC first is the ratio of the peak voltage to the voltage drop of one diode. We want to keep this as high as possible for best accuracy, however it does lead to a more expensive circuit because the filter cap has to have a much higher voltage rating. This means you might not want to do this (for cost reasons) unless you need the best possible accuracy you can get from a rectifier type measurement circuit. #### elecaau ##### New Member thank u for u all, i think i miss very important thing that i should consider thanks 4 ur advice #### MrAl ##### Well-Known Member Most Helpful Member Hi again, You're welcome. I should have also mentioned that the rectifiers and cap BEFORE the voltage divider is the more accurate way but will not always be necessary. Also, the double resistor divider would look like this: 230v Line o---R1---+---R3---+---R2---o 230v neutral and the voltage is then taken from across R3. R1 and R2 could each be 100k or greater. Also keep an eye on power dissipation in each resistor. #### elecaau ##### New Member Can i use general purpose resistors for this purpose or have any other specification? And, how can i calculate wattage value? #### MikeMl ##### Well-Known Member Most Helpful Member I'm still telling you that you are foolish to do this without proper isolation, regardless of what Mr Al says.... (Vrms)^2/R = 240*240/R = 57600/R If R=100K, then the resistor dissipation is over 1/2W, so I would use 1W or 2W power resistors. Bigger problem is the voltage rating of a 100K resistor, which is 350V for a 1W metal film resistor. 1.414*240V = 339V, which leaves not much safety margin. I would use two 50K in series, instead of one 100K. #### J O'C ##### New Member Even I can see that this is great advice, and I know nothing.... I'm still telling you that you are foolish to do this without proper isolation, regardless of what Mr Al says.... #### MrAl ##### Well-Known Member Most Helpful Member Hello again, [I provide a circuit diagram to reduce confusion] As Mike says, the transformer circuit is better isolated and safer. A somewhat cheap AC or DC wall wart would work well here. I mention the offline rectifier only because you brought it up and it is used in many commercial products. You should know though that in commercial products the safety issues are usually thought out very carefully, and may involve a lot of different things like case type, switch type, potentiometer type, etc. So you must assume some risk when you run anything directly offline. The circuit modification with the two input resistors instead of one (R3 is now two separate resistors) is meant to provide a better safety profile for the circuit but can not be guaranteed to provide the necessary safety if part of the output circuit is touched by human hands. This means that in addition to the two resistors you have to provide a means to prevent any part of the output circuit from coming into contact with the human body under normal operating conditions. That is one way it is handled in commercial products like light dimmers. Without that extra protection, you have to bank on the somewhat low current from the 100k resistor (only one will be involved in a fault) which should probably be 200k or more for 230vac operation. With the above in mind and carefully considered, the second circuit pictured in the attachment is probably more accurate, but you need higher voltage rated diodes (note the part number has been removed from the diodes in the bottom circuit). Just to recap, this kind of circuit is not new and the direct offline idea is used in commercial products and appears in many, many app notes as such, but experienced engineers know how to mitigate the lack of direct isolation as it relates to the safety of the device. Beginners beware, it could be very dangerous depending on how and when it is used and in what kind of application. So use at your own risk. #### Attachments • 18.8 KB Views: 161 Last edited: #### be80be ##### Well-Known Member Put 4 200k resistors 2 on each line side be a little safer. #### Superdat ##### Member I've been looking at circuits for AC mains detection and IMO the simplest and safest method is to use a neon and light spectrum phototransistor. The one I used was SP213F from Ebay. The neon drops about 60V, the supplied resistor is 82K so only about 2mA and total current is about 300mW. On the AC side you only have to isolate the neon and one resistor. I did manage to get it to work using the Phototransistor and 2 x series resistors, 1 x 220 ohm to the collector to limit current and a 10k from emitter to earth. Signal taken from the emitter. It was however not very sensitive. In a Darlington arrangement it was too sensitive. With a small NPN transistor to amplify the current, 1K load, collector to MicroP and a 10K pot instead of 10K resistor to adjust the sensitivity it works perfectly. #### Colin ##### Active Member 240v rarely goes above 245v in Australia. Where do you live???? If you want to measure voltages above 240v, use zeners and resistors and a cap. When the voltage is above 240v, an optocoupler comes on. You can have 2 optocoupers for 2 voltages. They are small and cost$1.00
You will need to set up the whole thing with a home made isolating transformer(s) as shown on talkingelectronics.com website and then you will need a boost transformer to get the higher voltage.

#### Superdat

##### Member
Was that comment to me Colin? I'm in the UK 220vac. This is a DIY optocoupler but the AC side is IMO much simpler.
I simply want to sense 220vac and produce a digital output @ 5V for on or off.
This is the circuit for the neon activated optotransistor. I used an LED to test it (now replaced with 10K resistor) so the output will be Neg (0) when the neon is on. If you want Pos (1) just use a PNP and switch the position of the 10K resistor and transistor. Signal taken from the junction of collector to 10K.

As said before the voltage drop across the Neon is about 60vac. The 220 ohm resistor is just a precautionary current limiter for the optotransistor. The 82k resistor came with the neon, I've seen them with a resistor as high as 150K but I wasn't sure how bright they would be so went for the higher current rating. It would be very easy to hide most of the 220vac part in an insulated cover/tube and since it's only about 300mW, heat dissipation isn't a major issue.

Last edited:

#### JimB

##### Super Moderator
Have you checked the output of this circuit using an oscilloscope?

I expect the neon to be flashing at 100hz, not a simple continuous glow.

JimB

#### MrAl

##### Well-Known Member
Was that comment to me Colin? I'm in the UK 220vac. This is a DIY optocoupler but the AC side is IMO much simpler.
I simply want to sense 220vac and produce a digital output @ 5V for on or off.
This is the circuit for the neon activated optotransistor. I used an LED to test it (now replaced with 10K resistor) so the output will be Neg (0) when the neon is on. If you want Pos (1) just use a PNP and switch the position of the 10K resistor and transistor. Signal taken from the junction of collector to 10K.

As said before the voltage drop across the Neon is about 60vac. The 220 ohm resistor is just a precautionary current limiter for the optotransistor. The 82k resistor came with the neon, I've seen them with a resistor as high as 150K but I wasn't sure how bright they would be so went for the higher current rating. It would be very easy to hide most of the 220vac part in an insulated cover/tube and since it's only about 300mW, heat dissipation isn't a major issue.
View attachment 106377
Hi,

Neons are somewhat unreliable, you can use an LED instead, or better, use an opto coupler.
To compensate for the pulsing due to the line frequency, use a capacitor just before the base resistor.

#### Superdat

##### Member
Hi,

Neons are somewhat unreliable, you can use an LED instead, or better, use an opto coupler.
To compensate for the pulsing due to the line frequency, use a capacitor just before the base resistor.
Although I have had some neons fail on household sockets, I've got many that have worked for years, so unless you know something I don't, I'd say neons are reliable. At 50 for £2 I'm not too worried about having to replace one now and then. Also this is an optocoupler it's just using a neon instead of an IR LED, it may not be one piece, but an optocoupler none the less. Some of the datasheets for visible light optotransistors suggest neon as a possible light source. That's what gave me the idea of using one. I know that transformer less 220ac to 5vdc are technically sound but I'm not over keen on them, too many components. I find it interesting that people are happy to use a transformer but then say that a transformer less circuit isn't safe. Why do they trust 2 copper coils wrapped around each other? If the insulation failed or it was overloaded, the resultant meltdown wouldn't be very isolated. If a capacitor/resistor/diode in a transformer less circuit failed it is highly unlikely to fail as a short, most likely open circuit, just like a fuse!
I'm trying to avoid using capacitors and I don't see why flicker is an issue, the optotransistor turns on and off very nicely using the neon as is.

I just noticed the OP wants to measure overvoltage so I have to plead guilty to going off topic.

If it's just over voltage protection that's needed what about a varistor?

Last edited:
Status
Not open for further replies.