High Voltage AC detector for Arduino

Currently I am working with a automatic transfer switch for solar power and I needed something to detect if there is an AC voltage output of the power inverter and the Distribution utility.


The circuit is simple and uses an optocoupler for safety reason so the user won’t get electric shock. optocoupler is used to isolate the high voltage AC voltage to the low voltage supply of arduino.

R1 is used to reduce the current to current enough to turn on the LED in the optocoupler. D2 is used to limit the voltage output of the bridge rectifier D1. C1 is used to smoothen the output of the rectifier.

Peak input current can be calculated as I = ((Vac*1.414)-Vd-Vz)/150k. For 230Vac that would be around 2.1mA. Power consumption of R1 can be computed as P = I^2*R = (2.1mA^2)*150k = 0.68W. You can use 1W resistor for R1 but to be more safe, use 2W instead.