I'm building this circuit using an RPi Zero and this 12V solenoid.

I would like to be able to power the RPi and the solenoid from the same wall socket using a single power supply. For example, I've been using a 5V 2.5A switching power supply to power the RPi, but am open to other options.

How would I go about doing this? I'm open to using a rechargable battery pack to power the solenoid if it can be recharged via the power supply or RPi. Size is a consideration - smaller components are better. Any input is welcome!

  • \$\begingroup\$ Ideal would be a switching mains power supply with dual outputs. You could also consider a 12v one and a switching regulator to 5v for the pi, which may also help a bit with the non-trivial task from protecting the pi from the solenoid's inductive kick. You could even use two independent supplies, especially with an optoisolator in the path controlling the relay. This question is a bit broad for the mission of EESE, which is intended for things that can be concisely and specifically answered. \$\endgroup\$ Sep 19, 2019 at 15:04

2 Answers 2


Power the entire circuit from a 12V wall adaptor with enough oomph to run the solenoid, the Pi, and everything else.

Then run the Pi itself from a 5V regulator that runs off of your 12V rail.


You should research you problem more broadly rather than just asking others to do it all for you. You need to know:

  1. Voltage and power level for the solenoid
  2. Voltage tolerance and power level for the 'Pi W (which will depend largely on the connected peripherals)

Assuming a 'Pi W with no attached peripherals you can expect:

  1. Voltage must not go below 4.95V at the 'Pi input terminals, and I'd recommend no more than 5.2V
  2. Current in the range of 350-500mA. Read this excellent set of answers: https://raspberrypi.stackexchange.com/questions/341/whats-the-current-draw-and-supply-voltage-tolerance) This gives a maximum power required of about 2.6W

With your solenoid actuated (3W) and the 'Pi W (2.6W) your total power supply needs are about 5.6W @ 12V. Add a fudge factor and select any 12V wallwart that can supply at least 1A ….this gives you 12W of available output power.

Use any of the common LM2596, MP2307 or MP1584 based buck regulator modules available (I assume you don't want to build your regulator) to convert your 12V Wallwart output to 5V for the 'Pi W. Remember to adjust the output voltage of the regulator BEFORE you connect to the 'Pi W.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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