RFID-Uno-relay-solenoid lock - Uno freezes when lock is powered up


Last week or so I have been going grey trying to figure out why my Uno has started to freeze, I was wondering if here is somebody who could help to get to the roots of this mystery.

Chronological sequence of events:

  1. I had the simple (ver1) version of my setup working perfectly for past 5 months. I call the simple solution: RFID reader, Uno and a relay module everything connected to the same 12V power supply.

  2. Then I had a failure – one cable had been damaged between the Uno and RFID reader. I changed the cable to resume the operation, but now the troubles started.

  3. Everything works when magnet lock is not wired up to relay - relay switches each time I put the RFID card to RFID reader. But when I wire up the magnet to the relay it works 1 to 10 times, and then I need to reset the Uno and it will work again 1 to 10 times, then needs again reset.

  4. During troubleshooting I have swapped out all components: Uno, relay, RFID reader, cable, magnet solenoid lock, tested also with standard 50kg magnet lock. Still it only works couple times when magnet is connected to relay.

  5. Then I decided to have separate power supply for each user (see ver2): independent 12V power for magnet, independent 5V supply for relay and independent 12V supply for Uno. Even after this I get the same behavior – it works well when nothing is connected to relay; but freezes after couple times when magnet is connected to relay.

Any ideas what could I try next?

try flyback diode (1N400X) connected across the magnetic coil in reverse bias and see if the issue persists, sounds like a nasty back emf is haunting your circuit

maybe put some bypass capacitors between all your power supply wires and ground sonething like 0.1ufd should do.

Adding the flyback diode (I used 1N4001) in parallel with my solenoid magnet did the job.

I faced same problem