How to know if a 220V switch is opened or closed

I need to control if a switch is pressed or not, and that switch is from a light line, so its 220V, I want the Arduino to read somehow when its pressed, but i dont know how to, because all the relays or the optocoupler that i found are only to activate loads, so the input is low voltage and the output is high voltage, and i want the opposite. It is possible?

Sure it is possible. You just have to be a little careful given that voltage you are working with here. You need to have something that can scale the voltage down AND covert it from AC to DC that you can read with your Arduino.

Scaling it down should come first. If you can safely tie directly into the switched line you could use a simple resistive voltage divider circuit. It looks like a 100K and a 2.2K resistor in this configuration might be just about right.

If you want to go about it without tying directly to the high voltage you can wrap a few turns of wire around the high voltage line and use that to sense the AC current and turn it into a smaller voltage. Some others here may be able to give you more guidance here, as I have not done this before.

Then you need to rectify either of these signals to make it DC. A 1/2 wave rectifier (google that for plenty of info) and a little capacitor should do just fine. Just use a resistor and capacitor that sets the time constant at about 1/20th of a second or more.

Or you could do it a lot more safely, and wire in a relay, and use the contacts to indicate the state of the switch.

connect a cell phone charger, measure 5v?

AWOL: Or you could do it a lot more safely, and wire in a relay, and use the contacts to indicate the state of the switch.

A relay with 220V Input? And how do i connect it to the arduino? Still need to low down the voltage and rectificate right?

Use a neon lamp (rated for 220Vac) and a photo-detector (in a potential divider)?

jroorda: Sure it is possible. You just have to be a little careful given that voltage you are working with here. You need to have something that can scale the voltage down AND covert it from AC to DC that you can read with your Arduino.

Scaling it down should come first. If you can safely tie directly into the switched line you could use a simple resistive voltage divider circuit. It looks like a 100K and a 2.2K resistor in this configuration might be just about right.

If you want to go about it without tying directly to the high voltage you can wrap a few turns of wire around the high voltage line and use that to sense the AC current and turn it into a smaller voltage. Some others here may be able to give you more guidance here, as I have not done this before.

Then you need to rectify either of these signals to make it DC. A 1/2 wave rectifier (google that for plenty of info) and a little capacitor should do just fine. Just use a resistor and capacitor that sets the time constant at about 1/20th of a second or more.

But with this voltage divider, the final voltage that comes down through the load is tiny too right? if its that case then is not a solution for my problem. Wrapping the wire around the line could be a solution, but im not sure how to do it, just wrap a buch of turns and connect it to the rectificator and then to the arduino?

Archibald: Use a neon lamp (rated for 220Vac) and a photo-detector (in a potential divider)?

Wow I think that would make the thing much bigger right?

Tripinbell: A relay with 220V Input? And how do i connect it to the arduino? Still need to low down the voltage and rectificate right?

the relay has a 220v coil that closes contacts. the contacts have no voltage on them so you send vcc from the adruino to the relay contacts then connect a wire back as a input. Its the safest way to do this. google a diagram for a 220v relay

gpop1: the relay has a 220v coil that closes contacts. the contacts have no voltage on them so you send vcc from the adruino to the relay contacts then connect a wire back as a input. Its the safest way to do this. google a diagram for a 220v relay

It makes sense, Im going to try this. Thankyou very much!

Tripinbell: I need to control if a switch is pressed or not, and that switch is from a light line

If it turn on a light, use an LDR to detect the light, no need to go anywhere near the 220v line.

Other than that, #3 using a power supply unit would be my suggestion also.

This appears to be a light switch. I don't know about where you folks are, but here it's [u]very unusual[/u] to have a neutral wire in a light switch. He'll have to place his relay or wall wart near the light fitting to be able to connect the neutral side. This may be impossible if there is no ceiling void, e.g. a wall light, in which to fit the relay or wall wart.

Connecting anything between the live and switched live wires would mean that the light fitting is connected to the live supply even when the switch is off. Not a good (i.e. safe) idea!

The only feasible and safe solution would be a well insulated coil wrapped around the switched live wire. For extra safety, I would connect the output of the coil through an optocoupler. You'd only need about 2.5V from the coil and no rectification (the LED would rectify the current), although some smoothing on the output side may be necessary.

1 Like

Henry_Best: The only feasible and safe solution would be a well insulated coil wrapped around the switched live wire.

Have you considered the direction of the magnetic field around a current-carrying wire?

Archibald: Have you considered the direction of the magnetic field around a current-carrying wire?

Doesn't matter when the wire is carrying AC, where the direction of the current (and, therefore, the magnetic field) is changing at 50 or 60Hz. The direction that the coil is wound in is bound to be right 50% of the time. The important thing is the amount of current the wire is carrying. Lower currents require more turns to produce the same voltage.

Henry_Best: Doesn't matter when the wire is carrying AC, where the direction of the current (and, therefore, the magnetic field) is changing at 50 or 60Hz. The direction that the coil is wound in is bound to be right 50% of the time. The important thing is the amount of current the wire is carrying. Lower currents require more turns to produce the same voltage.

The alternating magnetic field will be going around the wire, not parallel to the wire, so I don't understand how your proposed coil will produce any voltage.

Current sensors are available, for example this: https://store.arduino.cc/product/E000020 and this: http://raspimart.co.uk/shop/acs712-5a-analogue-current-sensor-module-hall-effect/

You want one (or more) of these.

Archibald: The alternating magnetic field will be going around the wire, not parallel to the wire, so I don't understand how your proposed coil will produce any voltage.

Current sensors are available, for example this: https://store.arduino.cc/product/E000020

That appears to be a coil that goes around the current carrying cable. How does that work?

Henry_Best: That appears to be a coil that goes around the current carrying cable. How does that work?

It's a toroidal pickup - the current-carrying wire forms in effect, a single turn through the magnetic core, whilst a coil of some thousands of turns transforms this to a much lesser current to be sensed, at a much greater voltage.

Note well: It only works if only one of the AC current-carrying wires passes through, if both do, there is no response.

While it has to be wired in to the circuit - across the load - I cited the correct approach to sense the voltage with isolation.