I want to use home automation, so I am thinking of using INPUT to ESP8266 from PC814 bi-directional optocoupler for mains 230V physical switch.

Using this scheme I don't have to modify my house wiring and I will just connect physical wall switch output which was going to device will now go to PC814 optocoupler using some 100k resistor. Now PC814 output size NPN Switch will be connected to NODEMCU GPIO.

But I doubt that @ 50 Hz my input will be toggling every 20 ms. How can I avoid this toggling and by using mimimum components to get continuous signal until power is present on input of PC814?

Need experts advice if anyone had tried this scheme.

enter image description here

  • 1
    \$\begingroup\$ Possible duplicate of Opto-coupler output \$\endgroup\$ – Long Pham Jul 31 '18 at 12:57
  • 1
    \$\begingroup\$ Is Nodemcu not capable of processing an interrupt every 20ms? \$\endgroup\$ – Dmitry Grigoryev Jul 31 '18 at 13:08
  • 2
    \$\begingroup\$ What does "continuous pulse signal until Power is present on input of PC814" mean? It's not clear what you want. \$\endgroup\$ – Andy aka Jul 31 '18 at 13:30
  • \$\begingroup\$ have seen one simple circuit to detect low frequency pulsing in this form by Vince Patron. I have not tested it. Check your luck - electronics.stackexchange.com/questions/325118/… \$\endgroup\$ – user19579 Jul 31 '18 at 18:38
  • \$\begingroup\$ Sorry typo error. Its not pulse signal. Simple if 230 VAC is present input of Nodemcu should be 1. As soon as power is off input to GPiO is 0 \$\endgroup\$ – Kalpesh Aug 1 '18 at 0:45

50Hz input gives 100Hz positive pulses at zero crossings. ( power on = logic “0” out)

With 22k pullup the collector voltage needs to be below 1/3Vdd for marginal “0”. Since RC=T is 63% towards Vdd the Cap load on collector needs to be 2T min. to cut slew rate voltage rise < Vdd/3 or 2RC=10ms or C>=0.47uF.

Making C too big may delay the detection of power due to current limiting and cap pull down rate from input Current Transfer Ratio (CTR). You could use C>=0.047 and Rc=220k

A power switch rated for >2A cannot be used for <10% of rated current due oxidation of contacts so if you are planning to do this, use a gold plated switch rate for >=2A.


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.