Using Arduino with high voltages

Hello,

I need to use Arduino as a sensor for high voltage - 220V. Basically, when a high-voltage device turns on it turns 220V power. I need that 220V transform somehow to the 5V and send to the Arduino which will take care of rest.
So, I am looking for hardware solution. I have successfully did 5V->220V with Solid State Relay and some minor components, but now is opposite what I am looking for.

I have the same need and plan to use an optocoupler to protect the arduino. One will need to poll the input often otherwise if unlucky you detect at a zerocrossing. Some kind of filter or delayed off on the input would work as well.

The solution will depend on exactly what you are trying to detect.

If your goal is to detect the presence of high voltages, a resistive divider + current limiting diode would be sufficient.

If you want to detect the presence of high ac voltage, you may have to rectify the signal, and or detect its repeated presence.

If you want nto detect the presence of 50hz high ac voltage, you may have to count the cycles.

...

using a transformer or opto-coupler helps ensure safety.

Here is a circuit that worked very well for me:

For 220V, I'd use a 0.1µF 400V capacitor instead. Note that this circuit is meant to interrupt the MCU at the mains frequency. It's a pretty straightforward interrupt to deal with, but if a simple high/low logic level input were preferred, some RC circuit on the output side of the optocoupler could accomplish that, although there would be a bit of a delay involved due to the RC time constant.

It can be much simpler.

Use an opto-coupler to sense the ac. On the photo-transistor side, parallel it to a small capacitor and pull up the whole thing with a resistor. Essentially, the presence of ac signal is shorting the capacitor, preventing the voltage across it to go up. Put a mcu IOC or INTx pin on the capacitor, active high.

When power is lost, nothing is shorting the capacitor and its voltage gets pulled up triggering the IOC or INTx.

If you don't already have an opto-coupler, you can make one out of a LED + photo transistor / diode or a photo resistor: you must have some in your junk box, right?

dava_2:
I need to use Arduino as a sensor for high voltage - 220V. Basically, when a high-voltage device turns on it turns 220V power. I need that 220V transform somehow to the 5V and send to the Arduino which will take care of rest.

5V wall wart?