I want to connect and control a 12V door lock solenoid and am a bit unsure about the circuit. So far I've bought following components in:

  • Raspberry Pi 3 Model B
  • 4x18650 Battery Holder
  • 4x18650 (3.7V) Batteries as External Power Supply
  • 1 channel 5V relay module
  • 12V door lock solenoid

Is this sufficient? Or am I missing something? Im quite new and still learning in this field.

Please help out

  • Welcome to Raspberry Pi! Please take the tour and visit the helpcenter to see how things work here. Do you happen to know make & model of the relay module (it is possible that it will not work with the Pi as its GPIO pins are 3.3 V not 5 V). – Ghanima Sep 30 '18 at 18:43
  • Yes @ghanima, its this one: elextra.dk/details/H40642/… – Mati Malik Sep 30 '18 at 20:04

You are missing a +5V switching regulator for the supply of the Raspberry Pi from your battery pack. The +12V may be unregulated, directly from the battery pack, though. The solenoid will work with anything from 10V to 16V.

But most important, you don't need a relay module for a door lock solenoid. These typically take 250mA@12V, which you can easily control with a darlington NPN transistor.


simulate this circuit – Schematic created using CircuitLab

Don't miss the diode. It's needed to protect the transistor from the turn-off voltage spike the solenoid produces. The diode shorts that spike.

The ground is shared for +5V and +12V. The GPIO will never "see" those +12V, in case you wonder.

  • I do have a transistor just in case: N-MOSFET Transistor 100V 28A. Will this do the job along with a diode? – Mati Malik Oct 1 '18 at 16:50
  • Yes? No? Without knowing the actual part number, this is impossible to say. – Janka Oct 1 '18 at 18:42

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.