Review of PiFace Digital

Table of contents

RoadTest: PiFace Digital

Author: howroyd

Creation date:

Evaluation Type: Independent Products

Did you receive all parts the manufacturer stated would be included in the package?: True

What other parts do you consider comparable to this product?: Gertboard Make one myself!

What were the biggest problems encountered?: No problems at all. The jumpers can be a bit confusing but it's ok. My only gripe would be that there is no documentation with respect to absolute limits on the pins. In particular the open collector outputs and the relays.

Detailed Review:

Hydrogen Fuel Cell Controller for an Unmanned Aircraft


The Horizon H-100 hydrogen fuel cell is an off the shelf device and controller which takes a 13v input (to power the controller) and hydrogen gas, and outputs around 120W of power.  As part of a PhD research project at Loughborough University, UK, the author Simon Howroyd, needs to redesign the controller in order to improve performance and increase compatibility with a Unmanned Aerial Vehicle (UAV).

The aim of the project is to design, fly and optimise a long endurance UAV for civilian applications such as media filming for wildlife documentaries.

The raspberryPi (RPi) is already being used by Simon as a datalogger and an onboard serial to WiFi bridge for the autopilot. This means the RPi already has an awareness of the aircrafts state (speed, height, waypoints, etc). With this knowledge the RPi is an ideal basis for a powertrain controller to provide a complete system in one package.

In order to replace the Horizon fuel cell controller, the RPi needs to at least be able to mimic the performance of the Horizon controller.  Amongst other things, the controller needs to plug into the fuel cell and control the hydrogen inlet valve, the purge valve and the fan, which are all on/off 12v devices.  The PiFace provides the ability to switch these devices on command from the RPi.  The PiFace also has buttons so the system can be reactive to physical interaction (pushing a button) rather than needing to log in and send it commands using a keyboard, making the system much more user friendly.

Integrating the PiFace


The two images show the before & after shots of the fuel cell setup. The left hand shows the original Horizon controller, and the right hand shows the system using the RPi with PiFace as the controller.

Obviously with the system being a prototype the is a mass of wires whilst the modular components are finalised.  This will be condensed down when confirmed making the setup look a little more aesthetic!

The PiFace in this setup is being used for the first three inbuilt input buttons (sprung push to make), and the first three output switched (two relays and one open collector transistor). The way the PiFace is designed means the output switches (transistors) are LOW SIDE switches. The relays can be either. What this means is that the device you are switching will be between the power rail (in my case 12v from a battery) and the PiFace output, meaning the PiFace is providing a GROUND connection. You may be used to the other way around where a switch provides POWER rather than a ground plane. What does this mean in practice? Well, apart from thinking for a moment longer to get the wires right, it means that the measly 5v that the PiFace runs at isn't the maximum rating of the pins, and the few milliamps of current isn't your maximum, for example an Arduino, or even the RPi GPIO. Because you have a separate power source (although the PiFace can still provide the power using a jumper pin) you can control higher power, higher voltage devices. In my case the fan, a computer fan, draws more current than a GPIO can provide and runs at 12v anyway. No a problem with the PiFace.

Using the PiFace

The PiFace was liaised with in Python.  This was new to me, since I usually code for embedded controllers in C, C# and C++, which can be used for the PiFace.  Python has one key advantage in that you don't need to constantly compile your code before running it, it just works straight off. For simple projects where you don't mind people seeing your code this makes python ideal. It is still object oriented so you get all the benefits of C++ to that end.

The PiFace library is simple to install:


sudo bash install.txt

Once this is done, all you need is to include the library at the top of your python script, and initialise it:

import piface.pfio as pfio


Then you are free to read a pin (inputs), and write to a pin (outputs):

input1   = 0 # Pin number of the first input

output1 = 0 # Pin number of the first output (relay)


while True:

     if pfio.digital_read(input1):


# end

That is it for a "if you press button 1, then turn on output 1" programme!

Very, very simple!

Obviously this code gets more complicated when using it as an autonomous controller. If you're interested my code is on github here.

Final Thoughts

You may gather from the tone that I am impressed with the PiFace and would recommend it if your project needs higher power switching than a GPIO can handle. I would, however, like to see some analogue capabilities on the board. I know it's meant as a digital IO, but it is really a controller. More often than not to control something you need a sensor, and most sensors are analogue still. There is easily room for a couple of ADC chips and inputs, maybe even a PWM output? Why no also have an I2C header on there too? This way every bit of the market would be hit? Or am I just being greedy because that is what I want, feel free to criticise! I will justify myself on the I2C port though, and it's simply because the PiFace is ideal to developers, who want lots of stuff plugged in. The PiFace plugs straight into the header on the RPi but the header does NOT pass through. This means you can't stack on top of the PiFace (somewhat contradictory to the documentation which says you can...hence why there are addressing jumpers!). You'll notice in my setup I've soldered on a passthrough header so I can stack, but this is cheating!


Simple to install, simple to plug in, more benefits that using a GPIO.


No documentation of pin ratings, no analogue inputs for sensors (ADCs), not stackable.

The Author

Any queries or questions, please do contact me. For further interest in my project please do check out the links below:


  • Ammendum:

    input1   = 0 # Pin number of the first input

    output1 = 0 # Pin number of the first output (relay)


    while True:

         buttonState = pfio.digital_read(input1)


    # end