How to avoid voltage spikes

Hi guys,

I have a circuit where I use an Arduino Nano to read NFC cards and control an electronic door lock through a relay. I am using a 12V power supply that is used to power both the logic part and the solenoid (see attached schematics). There are also some leds and a buzzer, but I dont think that matters regarding my issue.

The problem is that after on card being read and door unluck, the system doesnt work a second time. I am suspecting the wiring is not correct in aspect of having differences of voltage across the circuit, and I should add something like a capacitor or a diode.... (i`m pretty clueless).

Measuring the voltage across the RC522 card reader 3.3v and GND pins, after the door lock I can see a spike in voltage from 3.3V to aprox 4.2V and I am wondering if this could cause failure in subsequent card reads.

Also, please note that if I remove the door lock, this works ok and procedure can be triggered multiple times.

Thanks for any advice

I built an RFID reader with relay (equipped with wifi) for my friends bar to upgrade a non-wifi version. I tested it multiple times with the relay package - all tests worked perfectly. I delivered it. A few months later, he finally decided to upgrade and, for a reason I cannot recall, did not use the relay I supplied. Similarly, it work only once. After convincing him to use the relay I supplied (equipped with fly-back diode), it worked as expected.

No circuit diagram yet.
Did you use a back-emf diode across the solenoid.
The high kickback voltage when the solenoid turns off could lockup or restart the Arduino.

Note that 12volt is borderline for a Nano.
It's tiny 5volt regulator can't power much else at that voltage.
Leo..