Electronic – switch on a long wire end causing microcontroller to shutdown

microcontrollerpicrelayswitcheswiring

i've a push button connected to micro-controller using a 100m 18ga wire that cause the micro-controller to shutdown after few times of working properly

the circuit is fully functional with a short wire, i use 5v, both CN2/3 has lamp/bell load and sw1 wire is the 100m wire

enter image description here

Best Answer

At 100 meters of 18awg cable, i think it the wire starts to have enough inductance to have the system start experiencing inductive kick backs when the switch opens up. A small capacitor across the SW1 can be an effective snubber. Also add some decoupling capacitors across V+ and V- of your MCU.