Pls tell if you get better idea, or any consent about this circuit safety. Right side of switch is rside of optcplr. P521
I've research better method with lr8 (microchip), and even better more expensive mid400 (fairchild). But dont have enough time to order..
Update..
Put R between optocoupler n Neutral line.
Zener diode
*output is pulse wave 50hz. I do better in programming than doing hardware. If you want to have linear signal, just modify to fullwave rectifier bridge, bigger capacitor. However, using chip mid400 is recommended compare to this circuit.