I am connecting 12V electric magnetic lock to a SPDT relay which is controlled via a microcontroller (MCU) GPIO output pin. Whenever the output pin is pulled low, then the relay is turned off else it is turned high when the output pin is pulled high.
Initially, I tried without using any electric magnetic load but with just relay and everything works fine with the relay turning on and off as desired.
However, when i connect it together with the electric magnetic load then the GPIO output wont pull low from high state. I checked on the MCU GPIO pin and it seems to pull high which is the previous state instead of the expected low signal. For the relay seems to have slight contact and then it switched back to high in split seconds. It would practically have no switching at all.
My circuit for connecting the relay is using NPN transistor to drive it high and low where the electric lock is supplied via 12V into the common point of relay.
12V is driving through power supply which 5V is regulated via regulator to the microcontroller. All comes from single dc power source.
My question would be why once the magnetic load is connected then the MCU GPIO cannot be pulled low. I have provided the schematic as follow.
Do provide some advice :)