I want to read 230V/50Hz line voltage input signals with an ESP8266. Please have a look at my schematic, I chose an opto-isolator with AC input (LTV-354T) and added a simple RC filter to keep the digital input at low level during the zero crossing:

line voltage detection circuit

I simulated the filter with LT spice and noticed that the output signal has a long rise time (approximately 10ms):

LT spice simulation

My question: Should I add a schmitt trigger/buffer?

The ESP's datasheet doesn't reveal much about its input stage, maybe the chip already has schmitt inputs?

Another (additional) question, I hope this is allowed: What is the lowest input/LED current you would recommend?

The current circuit drives the opto isolator's LED with 1,6mA. I'd like to lower the power consumption and heat dissipated by the resistors.


1 Answer 1


1) Your circuit is fine. I have made these work with 600vac power lines. Each 100K resistor is dissipating only 0.184 watts, but use 1/2 watt resistors which have at least a 300 volt breakdown rating.You could make the resistors as low as 47K ohm 1/2 watt and still be ok (.368 watts per 47K resistor).

2) The opto isolator pulls the voltage across C4 down to zero volts quickly, but C4 must charge from R11, hence the slow rise time. This is ok because you need a time constant longer than 1 AC power cycle (16.66mS/2)for the output to be 'clean'. Remember, the opto isolator is pulling C4 low at a 120HZ rate.

3) The slow rise time should not cause detection problems because most every MPU has a glitch filter, but a schmitt trigger input is best. The results will be more predictable.

4) By the way, when I was designing these circuits for my employer I used 68K for R11 and .47uF for C4. This created about a 1/4 second response delay so short power glitches were ignored. CMOS Logic gates have a high input impedance so R11 can vary in value by a wide margin, but should be at least 47K if C4 is only .1uF.

  • \$\begingroup\$ Thank you, that was very helpful! I'll increase R11 to improve glitch filtering and add a 74LVC1G14 Schmitt-trigger inverter to clean the signal. An additional benefit of the inverter is that it simplifies firmware development, the logic levels will then match the line voltage signals. \$\endgroup\$
    – Dobbler
    Jun 11, 2016 at 22:15
  • \$\begingroup\$ @Sparky256 Can you recommend R7 & R9 resistor values for 120VAC? (How did you arrive at these values?) \$\endgroup\$
    – Brad
    Nov 27, 2018 at 3:16
  • 1
    \$\begingroup\$ For 120VAC you can take the R7 and R9 values and divide by 2. Due to breakdown/arcing issues they should still be rated 1/2 watt. Do not use tiny SMD resistors to tap power off of AC lines. Formula is rather simple. VAC in / R7+R9 (22K each) gives you the current, 2.727mA. I*V = 327mW or 163mW per resistor. If the optocoupler works great at 3 mA AC then you just adjust the resistor values per given AC voltage to maintain about 3 mA AC into the optocoupler. \$\endgroup\$
    – user105652
    Nov 27, 2018 at 3:47
  • \$\begingroup\$ Thanks! Yea - that was my big question - how much current do I need - datasheet seemed to allude to between 1mA and 5mA - I will use [two] 22k as a starting point - thanks! \$\endgroup\$
    – Brad
    Nov 29, 2018 at 13:47

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.