AC Optocoupler for 230V line detection
Where I use to work at we detected 230 VAC with a 4 pin H11AA814 AC optocoupler. Use a 220K 1/4W resistor to get 1.045 mA of current at 0.24 watts, which is plenty enough to sense AC. The output will be a 120 HZ ripple on 60 HZ power lines.

After research the H11AA814 is obsolete and can be replaced with a Vishay SFH628 series.

We used the simple ripple filter below to output a clean DC voltage equal to Vcc (+5V to +12V) minus about 1.25 volts.

As long as there is AC input Vout is at close to zero volts. If AC fails then Vout is +3.75 to +10.75 volts, depending on the voltage you power this circuit with. This circuit will respond to a power fail within 1/4 second. This simple filter also blocks reaction to brief power flickers lasting less than 200 mS.







simulate this circuit &ndash; Schematic created using CircuitLab

Copied from datasheet. It shows operation at 500uA and 1mA.