I need to detect a AC mains outage, isolated way. Output marked as [?] goes to AVR MCU. I don't need to detect undervoltage or zero-crossings. I actually need a simple feedback to MCU interrupt which will trigger interrupt only in mains outage. MCU are powered from UPS. I've picked following circuit found on the net based on PC817, but adjusted C1/R1 to 230VAC.

ac mains detector circuit

Any errors, i.e. will this work? Suggestions/comments on parts/values are welcomed.


Simply use something like HCPL3700, which is basically your circuit in one package. You only need one input resistor and bypass cap to make it work.

Note, that either your circuit or HCPL3700-based one are not actually "isolated", but rather "optocoupled", because you still have to connect wires to mains somehow, so full voltage is present at least on part of the board.

Truly isolated circuit would be something like Non-contact voltage (NCV) sensor found in some multimeters. For example circuit like this or this can be used without ever coming in contact with mains.

  • \$\begingroup\$ I always thought that "isolated" and "non-contact" aren't the same thing. Optocoupler also called "Opto-isolator", because it provides galvanic isolation. I don't actually need NCV, any sort of galvanic isolation should be fine for me. I've picked OC because it seems to be reliable, low cost & footprint solution. \$\endgroup\$
    – NStorm
    Jan 24 '20 at 13:14
  • \$\begingroup\$ All I meant is that your circuit has mains voltage on it. Nothing wrong with it, except you have to make sure it is safe to handle. For example, you can use old wall adapter from some device, replace its electronics with your circuit and 2-conductor cable with 3-conductor, close everything up and have a safe device that you can simply plug into wall socket you want to monitor. \$\endgroup\$
    – Maple
    Jan 24 '20 at 15:57

Actually circuit from my questions confirmed to work flawlessly in real environment for a few months now. Here is a pic of device which utilizes this circuit (lower left HV area corner): enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.