I'd like to use an HCPL3700(M) (datasheet) to sense if a 220 Vac mains is present. In my application, the device needs to raise an alarm if the mains voltage is lost. Backup power will be provided by a battery or super cap.

I've found this (which is, at least in part, based on this), but I am not smart enough to figure out if the values in the schematic below are appropriate for 220 V mains...


So, my questions are:

  1. Does C1 need to be 400 V rated?
  2. Are the values for R2 and R3 appropriate?
  3. What rating would R2 and R3 need to have? 2 W?
  4. I have seen some examples with a cap between MAINS_PRES and GND - is that necessary? If so, what values would be appropriate?
  • \$\begingroup\$ The values of R2 & R3 are calculated from tables in the app note. What voltage threshold are you trying to detect? (is the detection of brown-outs important). \$\endgroup\$
    – Mattman944
    Aug 6 at 7:26

2 Answers 2


A 220 V ~ relay may be used instead.

enter image description here

The digital input would be 'high' with the relay energised and vice versa.

  • \$\begingroup\$ Good solution if the threshold is not critical. \$\endgroup\$
    – Mattman944
    Aug 6 at 7:24
  • \$\begingroup\$ @Mattman944 - Thank you! \$\endgroup\$
    – vu2nan
    Aug 6 at 7:34

Maximum threshold is about 3 mA, so the two 47k resistors on the 220V input would provide about 2.3 mA average and 3.3 mA peak. It will probably work, but 39k might be more reliable. They will see about 600 mW each at 300 VAC, so 1 watt are OK and 2 watt even better, but make sure they are rated at least 200V.

The capacitor on the DC+ and DC- will only see the LED voltage, so anything more than about 10V will be OK. The capacitor should tend to hold enough current through the LED to maintain the output on through zero crossings. A capacitor from MAINS_PRES to GND will help filter noise as well as ride through zero crossings. About 100 nF should be good with 10k pull-up, giving a TC of 1 ms.

[edit] Answering a comment below, the input current will be approximately 220/R, so your two 47k resistors would provide about 2.3 mA, with peak current about 3.3 mA. Two 39k resistors result in 220/78 = 2.8 mA and peak current 3.99 mA. You may need to do some actual testing to see what works best for your needs. If you want to minimize power, higher values will give a pulse of a few mSec every half-cycle, so you could use software to detect a missing pulse.

  • \$\begingroup\$ Sounds good. Can you explain the calculation behind your recommendation of 39K? Then maybe - just maybe - I might be able to figure it out in the future... \$\endgroup\$ Aug 6 at 8:48
  • 1
    \$\begingroup\$ There is more than a LED on the DC terminals. The DC input of the HCPL-3700 appears as a 1000 Ω resistor in series with a one volt offset ... \$\endgroup\$
    – Mattman944
    Aug 6 at 9:17
  • \$\begingroup\$ @Mattman944 I don't understand what the implications of that are...? \$\endgroup\$ Aug 6 at 11:28
  • 2
    \$\begingroup\$ @MichaelLarsen Ring Detection with the HCPL-3700 Optocoupler says "The Zener diode bridge at the input of the HCPL-3700 clamps the voltage across the Ac inputs at approximately 7 V" [emphasis mine]. \$\endgroup\$ Aug 6 at 15:11
  • \$\begingroup\$ That app note certainly gives valuable information, although perhaps the equations are more complex than needed for this application. And the HCPL-3700 might be "overkill" here. It is more than $5. A digikey.com/en/products/detail/onsemi/H11AA4SR2M/1054097 is a simpler device with AC input for about a dollar. And you could also use a common single LED optocoupler with an external LED to provide a visual indication of voltage. \$\endgroup\$
    – PStechPaul
    Aug 6 at 21:27

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.