Home » Raspberry Pi Power Switch “PowerBlock”

Raspberry Pi Power Switch “PowerBlock”

PowerBlock

PowerBlock – a Raspberry Pi Power Switch

Overview

The PowerBlock is a Raspberry Pi Power Switch. It is an extension board for your Raspberry Pi™. It allows you to conveniently turn on and off the power to the Raspberry Pi with a toggle switch. Instead of just cutting the supply voltage with the risk of data loss the PowerBlock it communicates with the Pi and ensures a clean  shutdown  when the switch is turned to off.

PowerBlock attached to RPi Model B with toggle switch and status LED
PowerBlock attached to RPi Model B with toggle switch and status LED

Feature Overview

  • Micro USB connector for power supply
  • 2×6 pin header for mounting on the Pi
  • Pin header for arbitrary toggle switches
  • Pin header for optional status LED
  • USB-A break out pins for optional USB-A power out connector
  • Software daemon for clean shutdowns
  • Optional pin outs for arbitrary 5V power supply
  • Optional DC Barrel Jack
  • No soldering required

Any toggle switch can be connected to the PowerBlock. The power status of the Raspberry Pi can be indicated via an optional status LED.

The PowerBlock comes fully assembled with open-source drivers that are easy to install. If you are interested in getting the PowerBlock for your project, it can be ordered here.

Raspberry Pi Power Switch “PowerBlock” – Feature Details

The PowerBlock provides a Raspberry Pi power switch functionality. Why is it useful? The Raspberry Pi comes without a power switch. As soon as you plug the micro USB cable into the RPi, it turns on. If you want to shutdown the Raspberry Pi, you need to call a shutdown command to bring the system into a state in which you can safely remove the USB cable again. If you just pull out the micro USB cable the file system of the RPi might become corrupted and you risk loosing data.

Here, the PowerBlock comes into play. It is stacked onto the GPIO header of the Raspberry Pi and provides a micro USB connector itself, a connector for a toggle switch to control the power supply of the Raspberry Pi, and a connector for an LED to indicate whether the Raspberry Pi is off, booting, running, or shutting down. A micro controller on the PowerBlock board manages the power supply  and monitors the button state as well as the state of the Raspberry Pi. The driver ensures that a safe shutdown is initiated when you switch to “off”.  This also means that you do not need to plug and unplug the USB cable from the Raspberry anymore if you want to completely and safely turn it off.

Hardware Interface of the Raspberry Pi Power Switch “PowerBlock”

Here are a top and bottom view of the PowerBlock PCB:

The hardware interfaces of the PowerBlock are described in the following:

Compatible with Raspberry Pi Models A, B, and Zero

Compatible with Raspberry Pi Models A, B, and Zero

The dimensions of the PowerBlock PCB are chosen such that it exactly matches the two mounting holes on the opposite of the USB sockets of the Raspberry Pi models A+ and B+. The PowerBlock PCB comes with the same round corners as the Raspberry itself and give it a neat look. Regarding the GPIO usage the PowerBlock is attached to the first 2×6 pins of the Raspberry Pi GPIO header.This addition makes it possible to not only mount the PowerBlock to the Raspberry Pi model A and B, but also to the Raspberry Pi Zero. Here are some exemplary images for the various models:

2x6 pin female header as connector to the Raspberry Pi

2x6 pin female header as connector to the Raspberry Pi

Raspberry Pi Power Switch - PowerBlock Connector for RPi
PowerBlock Connector for RPi

The PowerBlock PCB is attached to the Raspberry with a 2×6 pin female header. This header makes use of pins 1 to 12 of the J8 header. This header is used for connecting the voltage and ground pins as well as the status pins between the RPi and the PowerBlock. The PCB is kept as small as possible so that you can easily access all other pins that are not used by the PowerBlock.

Micro USB Connector for the power supply

Micro USB Connector for the power supply

Raspberry Pi Power Switch - PowerBlock micro USB connector
PowerBlock micro USB connector

The PowerBlock has the same USB Micro connector as the Raspberry Pi. That means you can simply use your existing USB Micro cable for powering the RPi.

Pin Out for a Toggle Switch

Pin Out for a Toggle Switch

Raspberry Pi Power Switch - PowerBlock Pin Outs for Power Switch and Status LED
PowerBlock Pin Outs for Power Switch and Status LED

To control the power state of the Raspberry Pi the PowerBlock provides an interface for attaching a toggle switch. The on-board microcontroller monitors the state of that switch as well as the one of the Raspberry.

Pin Out for Status LED

Pin Out for Status LED

Raspberry Pi Power Switch - PowerBlock Pin Outs for Power Switch and Status LED
PowerBlock Pin Outs for Power Switch and Status LED

The current power state of the Raspberry Pi can be indicated with a 5V status LED that can be attached to the two pins that are provided by the PowerBlock. A 220 Ohms resistor limits the current of the status LED. You will find a load variety of possible LEDs that fit these values. You can find one here.

These possible states can be “off”, “booting”, “on”, and “shutdown”. The different states are indicated with easy-to-distinguish static and pulsing patterns.

Side note: The maximum allowed output current of the status LED pin is 40 mA.

Signal breakouts for input voltage, output voltage, and control signals

Signal breakouts for input voltage, output voltage, and control signals

Raspberry Pi Power Switch - PowerBlock Signal Break Outs
PowerBlock Signal Break Outs

The PowerBlock can also be used without directly attaching it to the GPIO header of the RPi: There are individual pin outs for the 5V input voltage, the 5V output voltage, as well as for the control signals S1, and S2. This gives you a maximum of freedom for your project.

In-Service Programmer (ISP) pin-out for ATtiny

In-Service Programmer (ISP) pin-out for ATtiny

Raspberry Pi Power Switch - PowerBlock in-service programmer interface
PowerBlock in-service programmer interface

The Power Switch logic is implemented with the help of an Atmel ATtiny85 microcontroller. If you want to you have the possibility to access the microcontroller with the ISP header. In this way you could reprogram the microcontroller with whatever functionality you like.

Optional DC Barrel Jack Adapter

Optional DC Barrel Jack Adapter

Raspberry Pi Power Switch - PowerBlock with optional DC barrel jack adapter
PowerBlock with optional DC barrel jack adapter

The PowerBlock is also prepared for connecting a DC barrel jack adapter. The hole dimensions for the barrel jack adapter are chosen such that most of DC barrel jack adapters should fit. The exact footprint of looks like this:

Raspberry Pi Power Switch - Barrel Jack Footprint PowerBlock
Barrel Jack Footprint PowerBlock (with mm measures)

One DC Barrel Jack that matches these dimensions can be found here.

Optional USB A Connector for switched power out

Optional USB A Connector for switched power out

PowerBlock with optional USB A connector
PowerBlock with optional USB A connector

If you want to provide a switched 5V voltage to another device, you can solder an optional USB A connector to the PowerBlock – it is prepared for that as well.

GPIO Pins used by the PowerBlock

GPIO Pins used by the PowerBlock

The pin out is as following:

5V IN, +,-: supply voltage
S1: pin 12
S2: pin 11
5V OUT +: pin 2 or pin 4
5V OUT -: pin 6 or pin 9

Getting Started with the Raspberry Pi Power Switch “PowerBlock” – Hardware Setup

Attaching a Power Supply

Attaching a Power Supply

PowerBlock with attached micro USB cable
PowerBlock with attached micro USB cable

You need to connect your micro USB cable only to the PowerBlock – and not to the Raspberry Pi directly. Alternatively to the micro USB connector you could also use the 5V and GND input pins for power supply.

Attaching a Power Switch

Attaching a Power Switch

PowerBlock with Attached Power Switch
PowerBlock with Attached Power Switch

To turn the Raspberry Pi on and off with the PowerBlock you need to attach a toggle switch to the two button pins on the PowerBlock. How does the PowerBlock work then? Technically speaking, the microcontroller on the PowerBlock looks, if the two pins of the switch are connected or not. If they are connected, a GPIO pin of the microcontroller on the PowerBlock is pulled to GND and interpreted accordingly.

  • It is important that you use a toggle switch and not a momentary button with the PowerBlock. Otherwise the Raspberry Pi will be turned off again right after booting.
  • If you do not want to use the power switch functionality you can disable this in the configuration file /etc/PowerBlockconfig.cfg by setting “powerswitch”: false.
  • The power switch circuitry of the PowerBlock leads to a tiny voltage drop and we made the experience that a good quality power supply and a good quality USB cable are mandatory for a working setup. If unsure, we can recommend the official Raspberry Pi Power Supply.

Attaching a Status LED

Attaching a Status LED

PowerBlock with Attached Status LED
PowerBlock with Attached Status LED

The PowerBlock has pin outs for an optional status LED that indicates the power state of the Raspberry Pi. You can directly attach an LED to the pins that are marked with “LED”. You need to pay attention to the polarity of the LED: The LED pins are marked with “+” and “-” for that.

The LED will blink in four different patterns that depend on the power state of the Raspberry Pi:

  1. Off: The LED is simply off.
  2. Booting: The LED slowly fades in and out.
  3. On: The LED constantly stays on.
  4. Shutting down: The LED fades in and out twice as fast as during boot up.

Getting Started with the Raspberry Pi Power Switch “PowerBlock” – Software Installation

You need to install the PowerBlock driver to enable the power switch functions. You find detailed instructions for the driver installation here.

Links

Videos

Posts about the PowerBlock

Tutorial: PowerBlock with OSMC - Introduction This is a post as part of a tutorial series about getting to start with the PowerBlock with various ... Read More
Tutorial: PowerBlock with RetroPie - This is a post as part of a tutorial series about getting to start with the PowerBlock with various images ... Read More
Tutorial: PowerBlock with Raspbian Tutorial: PowerBlock with Raspbian - This is a post as part of a tutorial series about getting to start with the PowerBlock with various images ... Read More
Quick Install Script for the PowerBlock Quick Installation Script for the PowerBlock - Making the PowerBlock ready to go becomes even easier! The installation of the PowerBlock driver is now a one-liner. We ... Read More
PowerBlock Top View New Revision of the PowerBlock: Increased Flexibility - The PowerBlock is a small support shield for the Raspberry Pi that provides a power switch functionality. Recently, we have ... Read More
PowerBlock: A Power Switch for the Raspberry Pi - The PowerBlock is an add-on board for the Raspberry Pi (version 1, 2, and 3) models A+ and B+. It ... Read More
%d bloggers like this: