I know I'll probably get some people saying this is unpossible, but this is what I've been dealing with for the past 2 days.
I am in the process of building an escape room. I have an arduino nano connected to a PIR sensor, 4 LEDs and a button. It is supposed to run the bulk of its script after the button is pushed. Works like a champ.
A few feet to the left I have a 12v magnetic lock. A foot below I have an RFID detector. 18" to the right, I have 3 8 channel relay boards.
At the moment, this PIR sensor system is only connected to my laptop. Completely electrically isolated from the rest of the room.
If I put an RFID card up against that sensor, a relay is triggered closed for 5 seconds. Immediately when that relay opens, it causes the completely disconnected Arduino nano to fire off its sequence as if the button had been pushed. I've ruled out loose wires and all sorts of jiggling. The only way I can get it to fire is to either
A. Push the button as intended
B. Have that disconnected relay close and reopen.
Can someone a lot smarter than me tell me what in the world is going on???
When a solenoid is switched off (either with a transistor or with a relay) a high voltage is produced.
Wiring nearby could pick that up, e.g a sensitive PIR sensor with unshielded wires.
Start with connecting a diode (e.g. a 1N4004) across (and close to) the solenoid.
Cathode towards 12volt, so the diode does not conduct during normal operation.
It might not fix the problem, but you need it anyway.
Leo..
Wawa:
When a solenoid is switched off (either with a transistor or with a relay) a high voltage is produced.
Wiring nearby could pick that up, e.g a sensitive PIR sensor with unshielded wires.
Start with connecting a diode (e.g. a 1N4004) across (and close to) the solenoid.
Cathode towards 12volt, so the diode does not conduct during normal operation.
It might not fix the problem, but you need it anyway.
Leo..
I will dig around and see if I can find any diodes. Thanks so much for that.
The wires to the button are maybe 6" wired with the internal pullup resistor.
Wawa:
Start with connecting a diode (e.g. a 1N4004) across (and close to) the solenoid.
I live in rural Alaska, so we don't exactly have Radio Shack. I do have some 1n4007. I'm guessing that would be sufficient. I'll give it a whirl when I head into work tomorrow morning. THANK YOU!
And try a stronger pullup on the button pin, 10k, 6.8k, 4.7k, stop at 3.3k or when interference subsides, whichever comes first. The stronger the pullup, the more power wasted.
The diode absolutely fixed it. The extra pullup may have been enough, but the diode was enough on its own. Thank you!
That blows my mind. I would have assumed that it could trigger something it was connected to, but something disconnected is just crazy. Again. Thank you for saving me on this one.
You pick up radio signals without a connection don't you? It is exactly the same thing. The solenoid is producing a large electromagnetic impulse. That is a transmitter. Your Arduino is picking up that pulse like a receiver. The pulse upsets the digital circuits.
By connecting a diode you short out the large voltage pulse produced by the collapsing magnetic field. This voltage pulse can be several hundred volts despite the coil only being driven by 12V.