Well, I think the majority of the problem is the awful wiring mess. ![]()
Let me go find my "stock" answer ...
I frequently stress the absolute need to keep the wiring from one part to another together, power wire with ground return; control wire with its return (which return for many common relay modules, is not the ground). The idea is to avoid loops which permit inductive coupling; we are dealing with devices which are operating at VHF (30+ MHz) radio frequencies here, electromagnetic transmission is a very real matter.
You always need to keep the high (mains) voltage physically and clearly separate from the low voltage for safety, but it is also most important to avoid the switching impulses that can result from the arcing of relay contacts, from being coupled back into the microprocessor circuitry and causing code and hardware such as displays to malfunction and crash.
Coupling can be both electrostatic over the stray capacitance between one wire and another, and electromagnetic where a loop of wire in which the current transient occurs, inductively couples to another nearby loop of wire in the signal and control circuits. This is why it is important to keep both wires of any given circuit together so that the electric field from any one wire tends to be cancelled by the adjacent ground (and supply) return and they do not form any open loops which can produce or pick up a magnetic field.
