Powering the Raspberry Pi

This is often the most asked question I receive.

“How do I power my Raspberry Pi in my car?”

The answer is several ways. Some have downsides and others are more complicated. All depends on component availability, budget and your skill level.

The easiest, and cheapest option is to simply wire in a 12v to USB power adapter and have it automatically power up your Pi each time the ignition is turned on. This however requires you to manually shut down your Pi or simply cut the power to it. This risks corrupting the flash drive the OS is stored on. During my testing, I used this method and had to re-flash the OS image several times due to corruption from power being cut.

(Above image is a Mauseberry Intelligent Illuminated Shut Down Switch available here.)

Another option is an intelligent switch. This is a hardware switch combined with a custom script that commands the Pi to shut down safely when the switch is turned off. This prevents corruption and data loss.

(Mauseberry Auto-sensing shutdown switch for automotive use, available here.)

The final option, and in my personal opinion the best, is using an auto-sensing shutdown switch. This is a switch that not only powers on the Pi with your key cycle, but can detect when the ignition is switched off, and continues to power on the Pi while running a lightweight custom script that commands the Pi to shutdown safely preventing corruption and data loss. This does away with the need to manually power on or off your device entirely, making it truly automated.

Wiring the power supply into your car:

To install the switch/power supply in your car there are just three wires that need to be hooked up: the long black, red, and yellow wires that are connected to the green jumper block on the PCB. The easiest place for most people to hook these wires up is in their dash / behind their stereo. Not all cars use the same color wiring combination, but the switch wires are to be connected as follows:

Black wire to ground.

Yellow wire to constant +12V/battery source.

Red wire to ignitition/accessory/switched +12V source.

Please make sure of the following:

Your ground connection should be a strong ground. Please don’t ground into a tiny wire.

The switches (both the 2amp and 3amp) are prone to getting warm if driven near max current rating. If you plan to draw a lot of current from your switch then please make sure you have adequate ventilation for your switch!

Connecting the switch to your Raspberry Pi 

On the circuit PCB you will notice the two leads are labeled “in” and “out.”

Connect a micro-USB cable from the circuit’s USB port to the power port of your Raspberry Pi (or, if you have a direct-plug circuit, directly to your Pi) and when you turn on your ignition the Pi should power on.

Using the Pi GPIO header diagram, connect the “out” lead to GPIO 23 and “in” lead to GPIO 24. If you prefer to use other pins (e.g. GPIO 5 and 6) simply edit the script as discussed later in the setup. Do not connect to a ground or power GPIO pin. GPIO 0 and 1 can sometimes cause issues as well.

It's only fair to share...Share on Facebook24Share on Google+0Tweet about this on TwitterShare on Reddit0Share on Tumblr0Share on LinkedIn0Print this page