Posted on 19 Comments

PiFace on the Raspberry Pi – Problem Solved!

UPDATE – 19-8-2022

The board producers have updated their code, and the instructions on their Github site now work perfectly. Here’s the link: PiFace installation: PiFace github
You can also use this excellent board on the Pi 4B, but you will need to file away a notch on the PiFace PCB so it clears the larger Ethernet port on the Pi 4. There are no PCB tracks in the area that needs to be removed, so it’s quite safe. The notch has to extend the full width of the word element 14 on the PCB and be deep enough to touch the top of the lowercase letters in that word.


I recently wasted many hours trying to get the PiFace board to work with Python. I eventually discovered the root cause of the problem, so have documented it here, both for my own reference, and for anyone else who might be pulling their hair out!!

About PiFace

The PiFace Digital-2  expansion board for the Raspberry Pi is a very well built add-on that features 2 decent capacity relays, 8 inputs and 8 outputs, all of which are accessed via screw terminals around the edge of the board. The PiFace boards have been around for a long time and are (supposed to be) easy to use.

The Problem:

A recent change in the Raspbian distribution set the default SPI (Serial Peripheral Interface) speed to a value (125MHz) that the PiFace board doesn’t support. Unfortunately, the Python initialisation code for PiFace didn’t include a command to initialise the SPI speed. The net result is that the PiFace board won’t initialise under Python and you will see an error along the lines … ‘PiFace board cannot be found’. Just to make matters worse, the PiFace Common library was updated to fix the SPI speed problem, but there is an issue with the ‘corrected’ version held in the repositories. This claims to be version 4.2.1 which is the correct version number for the SPI speed fix. However, a look at the file (/urs/local/lib/python2.7/dist-packages/pifacecommon) reveals that the line (speed_hz=ctypes.c_uint32(100000)) is still missing from the SPI transfer struct! I’m sure this will get fixed in due course, but for now, I suggest you use the following solution.

The Solution

The simple answer is to download and install the correct version of pifacecommon direct from the Piface GitHub site. Here’s how:

Start a terminal session in the pi directory (cd ~) and enter the following commands:

git clone

cd pifacecommon

python build

sudo python install

That’s it!

Accessing PiFace with Python

To complete installation of the Python libraries you need to install the pifacedigitalio library as follows:

sudo pip install pifacedigitalio

With the library installation complete, access is easy. Here’s a basic example taken from the GitHub readme.

import pifacedigitalio as p # import the library and give it the alias or nickname p

p.init()  # initialise the Piface board

p.digital_write(0,1) # make pin 0 high, NB: o/p pins number 0-7

p.digital_read(7) # read input pin 7, NB: i/p pins number 0-7

Happy programming,

Mike – G4WNC

19 thoughts on “PiFace on the Raspberry Pi – Problem Solved!

  1. thanks very very much … you are a saint !!!

    1. My pleasure 🙂

  2. “import command not found “following importpifacedigitalio as p# any clues thanks m0hzp

    1. Hi David,

      The import command is a standard command in Python so it’s almost certainly a typo. Can you paste or email your your Python script so I can take a look.


      Mike – G4WNC

  3. Thanks a lot !!!
    I started a robot app for the next comming rasperry pi jam …
    thanks for my time !!!

  4. Hi Mike,
    After update to Buster, the PiFace2 have issues again with the SPI bus. Have you a solution?
    Again the “I can’t see /dev/spidev0.0” message error…

    1. Hi Chris,

      I think the PiFace team have corrected the problem. I recently used my PiFace with a Pi-4 and Buster and it worked with the following install process:

      sudo pip3 install pifacedigitalio
      sudo pip3 install pifacecommon


  5. Mike, I have been trying to get my Piface Digital 1 working with my Raspberry Pi 1 B and Raspian Buster Feb 2020 version without success. I have read a number of people saying they have had problems when Buster was updated. I wonder if you have tried your Piface Digital 2 with the Feb 2020 version of Raspian Buster. Chris

    1. I have just tested my Piface Digital 2 (redundant since I last tried it with no success) with the very latest version of Raspbian. First I did the install as per Mike’s comment of the 31st July 2019 and then turned relay 0 on using the Python example given at the bottom of the original post. So thanks Mike.

      1. Hi Gordon,

        Glad to hear it worked for you. Mike

  6. Many thanks. Works fine with my PiFace Digital 1, Raspberry Pi 3, Raspberry Pi OS (kernel: v4.19). I just had to replace “python” by “python3.7” as used by Thonny Python IDE.

    1. Thanks Loulli,

      Glad to hear its working for you. Everyone needs to switch to python 3 and it’s a simple change.

  7. Hello Mike. Anibal here. With an (old) Piface and its old partner Raspberry Pi B+ (have a 4B too) everywhere have raspbian buster working fine. Should like to know if my piface is still alive so I tried for now with your directions THANK YOU VERY MUCH for them and for this page. In brief: wrote your instructions in a file and running got a “No module named pifacedigitalio”. A new run of sudo pip3 install pifacedigitalio yields a “Requirement already satisfied: pifacedigitalio in /usr/local/lib/python3.7/dist-packages (3.0.5) so I assume either a link or a different invocation for the library is advisable, though I don’t know which it should be. I tried python first though I use C and other languages ’cause I need a quick way to figure out if my piface can run or it’s already dead.
    Thanks for your help.
    Anibal (available on

  8. Hi mike
    Thank you for this post. Very useful. I have a piface digital 2.
    I have purchased a Pi 4 and downloaded the latest OSI have followed all your instructions and installed python 3.7.3 as well
    When I use Thorny it shows python 3.7.3 as the version I am using.
    I am getting an error on line 2 which is the p.init()
    The error given is
    Traceback (most recent call last):
    File “/home/pi/”, line 2, in
    p.init() # initialise the Piface board
    File “/usr/local/lib/python3.7/dist-packages/pifacedigitalio/”, line 166, in init
    raise failed_boards[0]
    File “/usr/local/lib/python3.7/dist-packages/pifacedigitalio/”, line 162, in init
    File “/usr/local/lib/python3.7/dist-packages/pifacedigitalio/”, line 82, in __init__
    File “/usr/local/lib/python3.7/dist-packages/pifacedigitalio/”, line 107, in init_board
    h=self.hardware_addr, b=self.bus, c=self.chip_select))
    pifacedigitalio.core.NoPiFaceDigitalDetectedError: No PiFace Digital board detected (hardware_addr=0, bus=0, chip_select=0).

    I am guessing this is something to do with the SPI speed. (SPI is enabled).
    Might I ask you if you now what might be causing this and how to correct it please? I think it might be an SPI speed mismatch between the pi and the piface.
    Thanks in advance

  9. Hi Mike I have struggled to get my pifaced2 to work after updates. I will try your solution as from above it appears to be very successful. As I am a real beginner I hope you will excuse me if I appear to ask a couple of silly questions. Firstly are the updates now in place and what would I need to do to installpifaced2 package and secondaly at what point do I fit the pifaced2 board in the installation.thirdly does the emulator work

    1. Hi Bill, What model Pi are you using? I’ve got a PiFace2 here so will set one up to make sure it works ok and let you know the details.


      Mike – G4WNC

      1. Hi again Bill,

        I decided to go ahead and try running the Piface Digital 2 on a Pi4B. I used the manufacturer’s instructions and they worked perfectly so they must have corrected the problems that blighted the original release. I suggest you follow their instructions, here’s the link: PiFace Digital 2 installation



        1. Thanks Mike
          I will try instructions as advised

        2. Hi Mike
          I am working headless and github will not allow me to access packages over internet even though I setup an account with username and password. Still at first base. I tried the installation from the piface site and although it appeared to work I cannot find piface directory.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.