I need to detect AC voltage with MCU for ensure relay health condition, the cheapest and smallest solution are most welcome. I have no hard time restrictions or noise canceling\debounce requirements (will processed inside MCU).

Most of cheapest optocouplers (OC) has adequate CTR only with If >= 1mA. But with VAC 230V, the dropping resistor (Rdr) must have decent power dissipation raiting, size and price.

To use SMD or cheapest THT resistors, in worst case Vac == 270V, i must have Prdr < 0.2W. It means, what Rdr must be not less 360k (or 510k for long life safety). So in another wrost case Vac == 185, i will have If ~= 0.3mA with pretty low CTR. For example, for TCMT110x what i used in project it would be near 0.2x.

Ok, that looks pretty clear, i just need to use:

  1. Double diode optocoupler (otherwise the OC will breaked by reversed 230VAC voltage).
  2. Amplifting transistor on the output.


simulate this circuit – Schematic created using CircuitLab

Does my thoughts has mistakes? Does i not consider some effects, what i must consider?

  • 1
    \$\begingroup\$ Note: when your question title says HV most of us will be expecting > 1 kV. "Mains" would be a better description. There are dozens of zero-cross detection circuits on this site which would do the job for you. A capacitive dropper will solve most of the power dissipation problem since you don't care about any phase shift that it would introduce. \$\endgroup\$
    – Transistor
    Commented May 19, 2021 at 17:44
  • 3
    \$\begingroup\$ You might want to consider using 2 (or 3) resistors in series. A single failure mode can make your circuit dangerous. \$\endgroup\$
    – Lior Bilia
    Commented May 19, 2021 at 17:44
  • \$\begingroup\$ Series of resistors are not an option because lack of place. Capacitive dropper too because same problem and also BOM cost. I am doesn't need zero-crossing detection, only voltage presence without any time restrictions. What you mean under dangerous? If Rdr are going to break, device just detects relay fault and disable the circuit. \$\endgroup\$
    – segar
    Commented May 19, 2021 at 17:57
  • \$\begingroup\$ If you can debounce in software why can't you use a single LED optocoupler? How quickly must you detect a loss of ac? \$\endgroup\$ Commented May 19, 2021 at 18:13
  • \$\begingroup\$ Do you have any safety requirements for this? What happens if Rdr fails short instead of open? You are using resistors rated for high voltage, aren't you? \$\endgroup\$ Commented May 19, 2021 at 18:14

1 Answer 1


Anything that requires you to attach to the line is a hazard, even with an optocoupler. Dropping circuits are the worst. They're totally unsafe, for a number of reasons:

  • they bring line close to low voltage
  • they dissipate power
  • they have to deal with creepage
  • they don't protect from transients

Consider instead using a capacitive sensor, something like those cheap testers that pick up live voltage. Then there's complete galvanic isolation, certainly better than what you will have with the optocoupler. This requires no direct attachment to the line, only proximity to it, so all the insulation distance and creepage issues go away. It saves the cost of the optocoupler, and your board can be smaller owing to not needing the opto or the stand-off distance. So this meets your 'cheapest' requirement, by far.

This kind of a sensor is a popular and cheap hobby project. Example here: https://www.electronicshub.org/non-contact-voltage-tester/

  • \$\begingroup\$ Can you explain the point of hazard in dropping circuits with optocoupler? \$\endgroup\$
    – segar
    Commented May 19, 2021 at 18:24
  • \$\begingroup\$ Any contact you make with the line is a hazard, and must provide adequate stand-off distance between the line voltage and low voltage, including allowing for creepage. Resistors must be large enough to deal with the voltage differential across them, and be sized for adequate power (other commenters noted this.) \$\endgroup\$ Commented May 19, 2021 at 18:36
  • \$\begingroup\$ Dropping circuits usually also use a capacitor by the way. Nevertheless I still don't recommend your approach. \$\endgroup\$ Commented May 19, 2021 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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