First Published 9th September 2018, Last Updated 19th February 2019 by Tim Trott

How to setup PetRockBlog's PowerBlock on a Raspberry Pi and add a simple hardware power switch to turn the Pi on and off. We will also add a power LED which can be used to show the status when in an enclosure.

PowerBlock is a Power Switch for the Raspberry Pi A+/B+/2/3 and Zero/Zero W from PetRockBlog. The power switch functionality allows you to turn on and off the power to the Raspberry Pi with a toggle switch without the need to unplug any cables. If you simply unplug the micro USB cable whilst the Raspberry Pi is on, your file system might become corrupted and you may lose data. When shutting down it cleanly shuts down the RPi before it cuts the power.

As a bonus feature, the PowerBlock allows you to connect an external LED to an enclosure or case and LED which has several modes indicating the system status. When the Pi is booting up the LED will flash slowly, when it's booted up and ready the LED will be a steady light, and when shutting down it will flash rapidly.

Attaching a Power Switch

You will need to use a toggle switch, not a momentary button with the PowerBlock. If you attach a momentary switch (one that returns to its original position) the Raspberry Pi will power itself off as soon as its loaded.

The power switch of the PowerBlock leads to a tiny voltage drop, so you need to ensure that your power supply can provide voltage and current. My phone charger was having problems under load, but as soon as I connected up the official power supply all was good.

The easiest way to attach the power switch (and the LED) is to solder on a two pin header to the board. You can, of course, solder the switch directly to the board, but you are limiting your options for future reuse and extendability by doing this.

With the two pin header attached, you can then use a two pin female connector attached to the switch to connect the two together.

Raspberry Pi PowerBlock

Attaching a Status LED

Installation of the LED is optional, so feel free to skip this step if you don't require it.

As with the power switch, the best method for attaching the LED is to solder on a two pin header and connector.

Installing the PowerBlock to the Raspberry Pi

With those two headers soldered to the PowerBoard we can go ahead and connect everything up. This is as simple as connecting the PowerBlock to the Raspberry Pi using the GPIO connector, and sliding the switch and LED to the headers.

We can then connect the power cable to the PowerBlock (not the original power connector on the Raspberry Pi) and power on.

The PowerBlock has 5V output pins (+, -). These pins are also switched by the PowerBlock. Since the PowerBlock connects to the 5V output of the Raspberry Pi, you will need to connect accessories or fans to the PowerBlock instead, as long as they don't draw too much current. The maximum current the PowerBlock can handle is 3.7 A - including the current consumption of the Raspberry Pi. If you need more power you could use the output pins to switch a relay.

Raspberry Pi PowerBlock

Installing PowerBlock Drivers

The PowerBlock needs a few drivers in order to configure the soft shutdown and LED.

Firstly there are a few prerequisite packages you will need to install.

We respect your privacy, and will not make your email public. Hashed email address may be checked against Gravatar service to retrieve avatars. This site uses Akismet to reduce spam. Learn how your comment data is processed.

About the Author

Tim Trott

Tim Trott is a creative photographer, traveller, astronomer and software engineer with a passion for self-growth and a desire for personal challenge.

Hi, I'm Tim Trott. I'm a creative photographer, traveller, astronomer and software engineer with a passion for self-growth and a desire for personal challenge.

This is my website, a place for me to share my experiences, knowledge and photography. I love to help people by writing articles and tutorials about my hobbies that I'm most passionate about. I hope you enjoy reading my articles as much as I enjoy writing them.