1
\$\begingroup\$

I have a smart module used for home automation. It is equipped with two relays, a wifi mcu, and two switch input.

For the switch input it uses AC mains detection using transistor (non-isolated.)

In the following picture we can see a simplified schematic of the AC main detection part:

AC MAIN DETECTION USING TRANSISTOE

As we can see anytime 220V is detected on input the transistor base is activated at 50 Hz frequency, and the GPIO of the MCU is sensing alternatively ground then 3.3V. Based on these pulses it can switch the relay.

The problem i have is that I tried to use this module with a rocker light switch (2 point.) In most case it was good, but in some cases it didn't work well - I got some random and fast light activation.

When I inspected the problem, I found that when the two wires of the rocker light were passing by close to other energized wires (220V,) it happens that the empty wire of the rocker light carry some voltage when measured by a high impedance multimeter.

The empty wire wich normaly is a open wire. When not energized, it acts as a capacitor with other nearby energized wires.

When using a low impedance multimeter I got 0V which shows that it's just a stray capacitance and ghost voltage.

Unfotunately this ghost voltage is activating my transistor randomly as if it's a true live wire.

In other cases, where I have 3 lives passing by near a rocker light wire, changing switch state does nothing because the ghost voltage is too strong keeping the transistor base activated (at 50Hz) exactly like a live (220V) wire.

I verified that the transistor base is not floating since the base is connected to ground via a 15Kohm resistor to pick parasitance and to pull base to ground and avoid such situation but it doesn't seems to work. I think that maybe the problem is that the input is at high impedance.

I thought to connect a resistor to ground just before the two 680k resistors but I'm not sure.

What do you think is the solution to stop the ghost voltage from activating the transistor?


To provide more information , this is the schematic of one side of the PCB:

LOWER SIDE PCB

In the picture I highlighted the AC mains detection part (picture found on internet, same module that I have, I did the highlighting to show the AC mains detection part.)

On the other hand, I have done some research and found a quite similar module, used as a dimmer, using the same AC mains detection principle , but this time they have used a capacitor rated 10 nf connected to ground after the two 680K resistors instead of a zener diode used in the module I have:

AC MAINS DETECTOR-CAPACITOR

I wonder if this slight modification could resolve the stray voltage sensed at transistor base. Should I try to connect the capacitor just after the two resistors to ground to resolve this issue?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ That circuit is truly horrible… there's nothing about safety or protection by transients. Well at least they put a double resistor on the input. For you information the input impedance of "low Z" testers is about 3K, and that's not too different by the one in your circuit. The RC cut is at about 13 ohm but probably it isn't enough. You could try lowering the base resistor and adding some digital filter in software. Or, better, use a dedicated voltage detector as suggested \$\endgroup\$ – Lorenzo Marcantonio Mar 4 at 14:10
  • \$\begingroup\$ I agree with you the circuit is non-isolated hence no safety exist . However to deal with the issue , the second schematic is not mine , the first is mine and input impedance is 15 kohm (zener diode instead of capacitor), in the second schematic it's a 4k7 resistor ( you're right it's almost equal to lowZ testers) in parralel with a 10nf capacitor . The drop from 15k to 4.7k will be enough to deal with ghost voltage ? \$\endgroup\$ – nour mehdi Mar 4 at 19:47
2
\$\begingroup\$

I suggest a different approach, using an optoisolator. Run the AC to a 'dropper' circuit to the LED side, then detect on the phototransistor side. This will be safer for you and your ESP8266.

Here's the idea (simulate it here):

enter image description here

I've refined this a bit - made it more sensitive with a Darlington stage, increased the resistance, got rid of all the caps, and adjusted the p-p input voltage.

The reason I removed the series cap is the behavior when the switch closes: it can cause a large inrush if the closure happens away from zero-cross, which will blow up the diode. That doesn't happen with just resistive coupling.

That all said, there's another approach to consider: non-contact sensing, like those AC detector pens. Then you don't need to connect to the switch, just place a wire nearby the switched hot leg to pick up the energized wire. (This assumes the load is connected to neutral.) Then there's no safety issue.

Many examples exist, like the one in this Q that uses a Schmitt trigger IC: Why are non-contact voltage detectors sensitive to vibration?

\$\endgroup\$
4
  • \$\begingroup\$ For the purposes of simulation, add a 10nF cap across the switch. In reality i would expect a couple of nF due to cable capacitance. \$\endgroup\$ – Kartman Mar 4 at 4:53
  • \$\begingroup\$ hack, I'd be worried about the phase shift caused by that capacitor. Have you checked this circuit for its ability to sit close to the zero-cross? \$\endgroup\$ – jonk Mar 4 at 7:34
  • \$\begingroup\$ I changed it a bit based on that thought. The inrush at waveform peak was about 1A, enough to blow the diodes. Not kosher. \$\endgroup\$ – hacktastical Mar 4 at 9:16
  • \$\begingroup\$ The optocoupler approach is the first thing i found as a solution . however the form factor of the module make it difficult even impossible to modify the hardware since the module is installed behind the wall switch . I need another approach keeping up with the transistor and trying to eliminate the stray voltage parasitance . \$\endgroup\$ – nour mehdi Mar 4 at 11:45
1
\$\begingroup\$

After some research ,i solved the issue related to the ghost voltage . First , i made some research to find how to modelize the capacitive coupling of wires passing close by an empty wire . I found one model but unfortunately it was for one enegized wire close to one empty wire . It was not enough for me to calculate exactly the amount of capacitance that was generated , but it gave me an idea about the one wire case . The equation depend on many elements like wire length , wire spacing , space permitivity , and other elements . This website can help to calculate the wire pair capacitance , https://www.emisoftware.com/calculator/wire-pair-capacitance/

Based on the formula , for my case , i found a capacitance of about 310 pF , for the one wire case. I made an estimation of about 3 times this capacitance for the 3 energized 220V wire and ended by rounding to a capacitance of 1nF that should be close enough to reality.

Next step was to find how to modelize the capacitance in a real life circuit . I found that according to the one explanation provided by one lowZ testers company on their official website , that the fact of puting a high impedance multimeter and trying to measure the ghost voltage between empty wire and neutral , is equivalent to closing the loop and making a voltage divider, the voltage that we can read on this multimeter , is a part of the voltage triangle , along with the capacitor voltage(Ghost capacitance) and the energized voltage . This can be summarized with the folowing picture .enter image description here

According to the triangle we can easily calculate the resultant stray capacitance if we know the multimeter impedance .

Now that we know that a stray capacitance can be modelized like a capacitor inline with the 220V input, it was time to make software simulation to see the results .

I based my solution on the Low impedance multimeter approach , using an input impedance of about 3K. Following was the result of my simulation . enter image description here

In the picture , i choosed an impedance of 3.8K . I made this choice because of i got some restriction when i tried to modify hardware . I couldn't replace the onboard SMD , because i didn't have SMD tools , so i decided to use a normal resistor and put it in parallel with the existing one ,and then i found the closest resistor that i have was a 5.1K, wich gave me along the existing 15K onboard , a resultant resistance of 3.8K , and then i made calculation with this one .

UP to 1nF stray capacitance , the transistor is not activated , and the ouput at the other side of the transistor(in RED) stays a 3.3V . I made the soldering part and this was the result.enter image description here

After testing , the module is working perfectly , and the rocker switch is responding without being affected by ghost voltage .

For information , we could try to enhance the modification by increasing the 380K resistor to up to 1.2M resistor that could be useful to deal with ghost capacitance up to 3nF . I choosed to keep 380K resistor to make things simple and because it was enough for me .

The soldered resistor for sure is not safe for now , just for test purposes it was soldered like in the picture , next step is to replace the 15K SMD with a 3K SMD and the work is done .

\$\endgroup\$

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.