# Power line induced noise risk

I want to sense a switch being closed or opened in a scenario as given below:

The switch is about 50 feet away from the MCU. Round trip becomes 100 feet. Also, the wires are not twisted pair and they are laid along with 220 VAC lines which will be powering all sorts of household appliances ranging from a mobile phone charger to an air conditioner. There will be multiple phases since it's a 3 phase 4 wire house wiring.

Will this circuit work? Is there some minor and inexpensive modifications that will make the circuit work?

MCU is using non isolated power supply and I can use neutral or 220 VAC live line as my GND reference. Will that help?

• I suggest you check the inputs with a scope, while there is current running through the mains cables. For a start Jul 20, 2017 at 12:59
• I did a lamp dimmer with PIC several years ago and I didn't had problems, except I had to add some chokes at PSU because washmachine, hair fan, ...caused PIC to reset. I'll check if I still have the schematics. Jul 20, 2017 at 13:03

In a prior answer (regarding a burglar alarm) with wall wiring, I computed the trash/spikes coupled into sense wires, from microwave oven diodes.

The assumped 1Amp (2,000 volts at 1amp for 2,000 watts) switching in 100 nanoseconds, coupling into 10 meters of wire (your loop) located 1cm away, with that loop having area of 1 meters by 1cm, produced 20 volts in the sense loop.

To reject such spikes, I'd place a R+C into your circuit, located right at the MCU. Let R be 10% of the pullup (or 5%, if you want better noise margin). Let the cap be 0.1uF (very short leads, or SMT preferred) in parallel with 100uF.

• I second that. Also the 100nF cap should have very low inductance, then it will also protect against ESD and other events that will zap that micro. With a 50' wire on an input, latchup or death by ESD is pretty much guaranteed. Cap should be connected to the lowest inductance GND available (ie, a plane). Also, ferrite core around the cable can protect against common mode trash. Jul 20, 2017 at 14:07
• Should I place the RC snubber (is snubber right term) on GPIO as well as GND line? Or only GPIO? Jul 20, 2017 at 14:38

OK. Here it is.

To the cheapo PSU had to be placed a 100uH choke to suppress the noise from domestic appliances. Note that line voltage goes to Vcc of the MCU. The inputs have pull-down resistors and the input signal comes from the button switch. Two buttons were located on PCB for settings, while the third button was actually a multiple parallel switch buttons located in house wiring (4 switch buttons in parallel). Also there was no go and return path wire, the wires came from existing wiring - the live signal 220VAC.

I never had any issue regarding input switch signals, but I would probably add capacitors in parallel with pull-down resistors or even a TVS.

EDIT:

The three buttons S1-S3 are on PCB, the input signal from on/of switch goes to the connector X1, pin 4. Have forgot the value of R8. It is base on the app. note : link

EDIT2:

I would make a little upgrade for the input:

simulate this circuit – Schematic created using CircuitLab