I have bought this relay:


In the '1 channel 12v relay' variety

I am going to be using it to power and unpower a 12v mag lock. Am I correct in saying that the mag lock needs 12v power from the wall as well as the relay, as the relay doesn't actually power the mag lock itself does It?

As the pi won't be able to give the relay 12v Surely?

If I need a 12v adapter for the relay how many amps will it need to be?

  • the listing says 5v or 12v, there is a CHANCE you could power the coil via the 3.3v of the pi, If you have to use a transistor to power the coil, the same adapter would work to power the coil and the mag lock as the coil takes very little current – Chad G May 2 '18 at 19:00
  • But I bought the 12v one? – AvidPontoon May 2 '18 at 19:02
  • Then you will need to use a transistor to drive the coil – Chad G May 2 '18 at 20:05
  • While the VCC of the relay is 12V, it may still be possible to drive the signal PIN with 3V3 - the input pin is opto-isolated so there should be no concerns – Jaromanda X May 3 '18 at 2:03

The device you linked has no meaningful documentation, so no one can definitively answer.

A 12V device seems unsuitable, and while you could probably interface it to the Pi with additional circuitry (to do this you would need a circuit of the module) you would need an additional power supply.

There are myriad devices which run from 5V and which can be directly controlled by the Pi 3.3V GPIO which would be more suitable.

Either way you will need to supply your lock with 12V, but to share a 12V supply with your load and module requires careful attention to voltage spikes. The whole point of a relay is to isolate the load from the control.


The pictures and text on the eBay page you have linked imply that the relay you have bought should work for your application. I say that because they do claim (at least) that the product is set up for use with Raspberry Pi and Arduino; the pictures show what appears to be peripheral circuitry that might be level shifters to take the 3.3v output at your GPIO pins, and drive the relay. If that's the case, you should be able to control your mag lock without a lot of fuss.

You are correct that the RPi won't supply the 12 v you need for the mag lock. You'll need to supply 12 VDC... it won't come directly from "the wall" as "wall outlets" provide 220v/50 Hz AC (or 120v/60 Hz in the US). However, a standard "wall wart" rated at 12 vdc that plugs into the "the wall" will supply the power you need (probably what you meant, just making sure). The current required from your "wall wart" will likely not be more than 1-2 amps, but you should be able to get that specification from your mag lock vendor.

The hookup between the RPi, your relay board and mag lock are shown in the diagram below. Let me know if you have questions, or if anything is unclear. One final suggestion: Since the specs on the relay are so "iffy", you may want to control an LED before you connect the mag lock. Relays can have an "inductive kick" when they're disconnected, and draw considerable inrush current when they're energized. Assuming your "relay board" is really that, the designer will have made provisions for these things. If after reviewing the documentation for the relay board, you're still nervous about that, re-post here, and we'll come up with a simple "protective circuit" to keep your RPi out of harm's way.


simulate this circuit – Schematic created using CircuitLab

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.