Draft instructions for getting started with PiFace Digital (full instructions to follow)

Full documentation will be published in the next couple of days, but in the mean time, for those who have been lucky enough to receive the first interfaces, here’s a brief summary

Getting started with PiFace Digital

PiFace Digital is one of the quickest and easiest way to connect your Raspberry Pi to the real world. Follow this guide and you’re Raspberry Pi will be reacting to switches and controlling motors and lights in less than ten minutes! 

  • PiFace Digital features at a glance:
  • 2 changeover relays
  • 4 switches
  • 8 digital inputs
  • 8 open-collector outputs
  • 8 LED indicators
  • Easy to program in Python, Scratch and C
  • Graphical emulator and simulator 

Always disconnect the power before connecting anything to your Raspberry Pi or PiFace Digital.

Fitting the board

PiFace Digital sits neatly above the Raspberry Pi and connects using the expansion connector. Take care to ensure all expansion pins are lined up with the holes on the PiFace socket. Check the alignment for left and right and front and back and never force the boards together if they don’t slide smoothly.

Installing Software

The fastest way to get started is to download a prepared operating system image and copy it to an SD card. Images are available from http://pi.cs.man.ac.uk/download.

Alternatively, you can install the necessary libraries to your own Raspbian image with the instructions below.

Installing the software yourself in Raspbian

PiFace Digital communicates to the Raspberry Pi using the SPI interface. The SPI interface driver is included in the later Raspbian distributions but is not enabled by default. You can always enable the SPI driver, or you can load it by hand when required.

Always enabling SPI

To always enable the SPI driver:

  •  After logging in, edit /etc/modprobe.d/raspi-blacklist.conf

sudo nano etc/modprobe.d/raspi-blacklist.conf

  •  Insert a # at the start of the line containing blacklist spi-bcm2708 

#blacklist spi-bcm2708


    Alternatively, to load the SPI driver by hand (will not be loaded on reboot):

    ·      Type in a terminal:

    sudo modprobe spi-bcm2708

    Next, you we need to install the PiFace Digital libraries and change the permissions of the SPI interface. The following script automates this into one command.

    To install and setup the software, ensure your Pi can access the Internet and type:

    sudo apt-get update

    wget -O – http://pi.cs.man.ac.uk/download/install.txt | bash

    The software will complete installing in a few minutes.

    Reboot your Pi by typing:

    sudo reboot


    After installing the software and restarting, login and startx.

    Start the PiFace emulator by typing in a terminal:



    1.     To manually control the outputs, in the PiFace Emulator window, click Override Enable.

    2.     Toggle Output Pin 1 on by clicking on it. The PiFace interface will click as the relay turns on and the corresponding LED will illuminate. Notice the graphic onscreen updates to show the LED being on, the contacts have changed over on the relay and the first output pin is on.

    The LEDs are in parallel with the outputs terminal connectors and indicate when the output is enabled.


    1.     We want to observe the inputs so click Keep inputs updated checkbox so the emulator reads the buttons and updates the screen. The interval sets how often the inputs are read, for most cases, it is fine to leave it on 500ms.

    2.     Press one of the buttons on the bottom left of PiFace. Notice how the onscreen representation changes to indicate the switch has been pressed.

    First steps with Python

    To use Piface with Python import the piface.pfio module:

    import piface.pfio

    Before use, the board must be initialised with a call to init() .

    There are three main functions to control the interface

    ·      digital_read(pin_number)

    o   returns 1 or 0 depending on the state of the input numbered pin_number

    ·      digital_write(pin_number, state)

    o   sets the output numbered pin_number to state 0 or 1. State 1 turns the LED on and enables to open collector to sink current

    ·      digital_write_pullup(pin_number, state)

    o   sets a 10k pullup on input numbered pin_number to be state 0 or 1. State 1 is pullup enabled



    47 thoughts on “Draft instructions for getting started with PiFace Digital (full instructions to follow)

    1. I’ve had serious trouble getting this to work tonight with Wheezy. After a couple of re-images I eventually found on google that the blacklist command is not appropriate for Wheezy and had to add to etc/modules instead. The install.txt file also appeared to do nothing. I opened the file manually and keyed each command and this eventually seems to have installed. now trying to work out how to get Scratch working……..

    2. The directions worked fine for me, except for the emulator, since I’m telnet’d in to the board instead of connecting it to a display. Within a minute or two after installation, I was able to toggle the LED1 and hear the relay click. And now to learn Python!

    3. Following up, the wget http… | bash didn’t work for me, instead it just downloaded the file to my local folder. I simply enabled execute permission (chmod 744) and then executed it (typing "./install.txt" without quotes) and the install ran great. And the toggling I did in Python using "piface.pfio.digital_write(1, 1)" and …(1, 0). Not sure if that is proper form or not, but it worked.

    4. Please help, I’m at my wits end with this thing!Love the Pi Face but am having real difficulty getting this thing to work.Plan A:Re-image my SD card with the Pi Face image. Expected all to work "out of the box". No such luck. Couple of error messages after login at pi prompt. Startx fine into GUI. First thing I notice is I have no task bar at the bottom. Double click Scratch – nothing happens (even after waiting). Re-format card (Sandisk 4GB card) and re-image again. Same thing happensPlan B:Back to the the Wheezy image from the main Pi site and apply the updates as above.1. Had to manually enable SPI as per my post above2. wget only downloaded index.txt, did not execute, so manually executed each command3. Success, I can now connect to the PiFace using the emulator and all is wellBUTScratch now needs some work to get the Scratch Handler working.4. Shift Click Share menu….. nothing5. An hour on Google I eventually find that the Mesh menu needs enable via Shift Click R, then editing the menu options to false instead of True. Success, I have a mesh menu. BUT.. try to save the image, Scratch crashes. Game over, I’m back to sqaure one with it allI desparately want to get Scratch up and running for the weekend. My kids are addicted to Scratch, and were overly excited when I presented them with a Pi Face and talked of the possibilities. I currently have 2 very disappointed children and would like a peaceful weekend please!!!!

    5. Could not get the line wget …. install.txt to run ( I was running in in a terminal window)I ended up typing all the lines in install.txt into the command prompt that ran ok.One thing to not the PiFace emulator thinks the interface is connected even if it is not – and lets you set the relays / outputs. There is something wrong with the detection logic.Also the image on the download website does not have the software to connect via WiFi as the image supplied by Maplin has so will not work without a cable connection.

    6. tried the alternative image tonight (dev image from Piface team) and hey presto, we have a nicely functioning Pi, with scratch up and running :-)Relay board also now wired in and firing on all 4 cylinders – home automation here we come πŸ™‚

    7. Thanks for all you’re feedback, we’ll use it to finalise the documentation. Also, remember to let us know what you’re making with PiFace!

    8. Spotted and corrected one of the problems, the wget should have a -O – to say send the output to stdout out (which is piped to bash by |)When setting up scratch, first start scratch by typing sudo scratch, then follow the instructions as detailed by stanley. Now scratch won’t crash when you save it. Once you’ve saved it you don’t need to use sudo for it in future

    9. thanks piface. A few teething troubles, but now it’s running I’m loving it! 8 Relay board now bolted on to Piface, lego technics wired up, just need the kids to wake up now and the fun begins!

    10. Please – when you finalize the docs can we please have an accurate pin mapping from Pi => piface inputs/outputs? 1-wire support requires pin 4 (the seventh physical pin) on a Pi. I am currently unable to figure out which piface input pin this is. If it even is mapped(?).

    11. I’m not having any luck with my piface. I did the install and it seemed to go ok (although it’ hard to tell). When I get to "Testing" piface/scripts/piface-emulatorsays "Could not connect to the SPI module (check privileges). …piface/scripts/spivisualiser says…spi.error: can’t open device: /dev/spidev0.0Not surprising since /dev/spi* is not there. Any suggestions?

    12. that’s really odd, if the module is loaded then /dev/spidev0.0 should be there. When you do the modprobe what does dmesg say? Are there any errors loading the module?

    13. pi@raspberrypi ~/piface/scripts $ sudo modprobe spi_bcm2708pi@raspberrypi ~/piface/scripts $ dmesg | tail[ 3272.762423] bcm2708_spi bcm2708_spi.0: chipselect 0 already in use[ 3272.762460] bcm2708_spi bcm2708_spi.0: can’t create new device for spidev[ 3272.762508] bcm2708_spi bcm2708_spi.0: chipselect 1 already in use[ 3272.762530] bcm2708_spi bcm2708_spi.0: can’t create new device for spidev[ 3272.762554] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80)

    14. Ok, so the good news is that’s the problem, less good news is that without seeing the code running on your Pi I don’t know exactly what’s causing it. — there’s something trying to use the IO lines that the SPI interface uses. What other programs have you got or had running that use the IO, try not running them?

    15. Sorry, that might have been a red herring. On reboot I get the following:pi@raspberrypi ~ $ dmesg | grep spi[ 8.941713] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80)pi@raspberrypi ~ $ lsmodModule Size Used bysnd_bcm2835 21485 0 snd_pcm 82208 1 snd_bcm2835snd_seq 59808 0 snd_timer 21905 2 snd_seq,snd_pcmsnd_seq_device 6920 1 snd_seqsnd 57668 5 snd_seq_device,snd_timer,snd_seq,snd_pcm,snd_bcm2835snd_page_alloc 5383 1 snd_pcmevdev 8922 3 spi_bcm2708 4815 0 pi@raspberrypi ~ $ ls /dev/spi*ls: cannot access /dev/spi*: No such file or directoryThis is an out of the box Pi and PiFace. The distro is as provided from element 14 (http://canada.newark.com/samsung/raspberry-pi-prog-4gb-sdcard/debian-linux-preprogramed-4gb-sdcard/dp/96T7436). The only thing running is the X session.

    16. @Dennis That’s really odd — I’ve not seen that distro, I’ll try and order one to test, but obviously it will be a couple of days before it will arrive. I’ll ask around if anyone has one in the meantime.

    17. Not much success there I’m afraid. Response was unknown host archive.raspian.org.Just at add a bit of background, this is a Pi, using wheezy supplied with delivery.

    18. @piface Thanks for your help. I’m pretty sure the distro is Debian or, more likely, Raspbian. Is there a way to see for sure?pi@raspberrypi /etc $ more debian_version wheezy/sidI’ll try to get a fresh SD and flash it with a clean Raspbian and see if that works.

    19. Piface seems like a very nice addon for my Raspberry Pi. Will help me putting together projects as demonstration for my students (I am a computer science teacher in the netherlands).I am quite new to this whole microprocessor and electronics subject, so still learning. My following question will most likely be a stupid one.I have got my raspberry Pi in a Pibow case and I got a ribbon cable available. Can I use this cable to connect to the PiFace instead of getting my Raspberry Pi out of the case and putting the Piface on top of it (as intended)?

    20. @Klaas van Opstal Glad to hear you’re getting into teaching microprocessors — we hope to have some demostrations and resources very soon.Being honest it hadn’t occured to us that you could use a ribbon cable with a Pibow case — as long as the cable is pin equivalent i.e. pin one on the pi goes to pin one of the piface, pin two to two etc. it should be fine.

    21. @Dennis, let us know how you get on.doing uname -a gives info on the kernel that you are running that can be useful to compare versions

    22. OK. earlier problems are now resolved, but a new one arises.I have run the emulator and the Piface responds as expected.But when I try to initialise the interface in Python, having imported piface.pfio then piface.pfio.init() returns the message File /usr/loca/lib/python2.7/dist-packages/piface/pfio.pyline 151, in initpiface.pfio.InitEroor can’t open device /dev/spidev0.0i have checked and the device exists in the /dev/ folder

    23. Ok, a clean raspbian (2013-02-09-wheezy-raspbian) and it works fine. I’m not sure what’s on the other distro that’s mixing it up.

    24. Sorry, I don’t seem to have had a response to the earlier message.When I try to initialise the interface in Python, having imported piface.pfio I get an error message>>> import piface.pfio>>> piface.pfio.init()Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/piface/pfio.py", line 151, in init raise InitError(error)piface.pfio.InitError: can’t open device: /dev/spidev0.0>>> quit()]0;pi@raspberrypi: ~pi@raspberrypi ~ $ exitexitThis leaves me rather lost I’m afraid.I have checked that /dev/spideo0.0 exists and it does but so does a later version spidev0.1Where do I go from here?

    25. @Ed do you have the correct permission on /dev/spidev0.0 ?can you do ls -la on /dev/spi* and also groups to see which groups you are in?

    26. yes. there is no problem there. Do you have any other ideas?Script started on Tue 19 Feb 2013 11:43:33 GMT]0;pi@raspberrypi: ~pi@raspberrypi ~ $ ls -la /dev/spi*crw——- 1 root root 153, 0 Jan 1 1970 /dev/spidev0.0crw——- 1 root root 153, 1 Jan 1 1970 /dev/spidev0.1]0;pi@raspberrypi: ~pi@raspberrypi ~ $ groupspi adm dialout cdrom sudo audio video plugdev games users netdev input]0;pi@raspberrypi: ~pi@raspberrypi ~ $ exitexit

    27. Could be a permissions issue. Assuming you’ve cloned the git repo, can you trysudo piface/scripts/spidev-setupand then a restart. This will add you to the spi group and give /dev/spi* devices access by all members of that group

    28. This may seem like a basic question, but I am relatively new to the world of the Raspberry PI/PI Face. I am looking to connect a temperature probe, for example a DS18B20, to the PI Face and read temperature date from it. The documentation I have found online gives a lot of good examples for connecting switches to the PI Face inputs, but nothing so far as other types of inputs. Any help would be greatly appreciated!

    29. any idea when full piface details will be available as for example : how do you know what the pin numbers relate to ?

    30. So far so good. I followed the instructions and Piface works beautifully. Now I’m stuck because I want to use espeak but can find no really useful documentation on using it in Python. So can anyome help me to meet a deadline and tell me how to get my Python program to convert the text string "happy Birthday, Fred" to spoken output ? Thanks in anticipation.

    31. Hi, thanks for your hard work, my piface is great and easy to use. Firstly have you considered a forum where people can ask questions/help each other – apologies if this exists, but i havent found it yet!Secondly, i have an electronics Q. (its been a long time since i did AS lecys)I appreciate the 8x open collector outputs, but i want to hook these up to a 8x relay board for >20v controls. The relay board I have is expecting a +5v signal to energise (open).If memory serves, i should be able to add a small load (LED&Resister) on the PiFace outputs, so when the pf output is true will cause the LED to light. If i have my relay in parallel between the + and gnd, when the PF output goes to 0, the remaining route with a greater resistance will be via the relay causing it to open. SO…. PF output = true, then my LED lights, relay stays closedPF output = false, LED goes out, and relay opensdoes this make sense, have i forgotten everything i learnt at school? πŸ™‚

    32. who can point me to hardware information on the pi-face?
      There is plenty of soft stuff, but no schematics or other information (that I can find) on physicallly interfacing to the board.

    33. I’m in the same position as Paul, everything about PiFace is geared towards people who have the electronics background but are linux noobs. I’m more than happy with the linux side but am an electronics noob. How about writing some simple instructions on setting up a single sensor and controlling one output device?

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out /  Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out /  Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out /  Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out /  Change )


    Connecting to %s