Electronic – ESP8266 line voltage detection, schmitt trigger needed

esp8266mainsopto-isolator

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.

Best Answer

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.