KB: Enable SPI for PiFace Digital boards on a Raspbery Pi
If you plan to use a PiFace Digital board on a Raspberry Pi, the SPI needs to be enabled first.
Enabling SPI support does take a few steps, but it's not difficult.
- Shutdown the Raspberry PI and disconnect all items (power, USB ports, audio, video, etc).
- Remove the PiFace Digital board.
- Turn RPi (Raspberry Pi)
- Open a command prompt.
- [filebg]sudo raspi-config[/filebg]
- This starts the Raspberry Pi configuration console.
- Select "Advanced Options" and press "Enter".
- Arrow down to "SPI - Enable/disable automatic loading of SPI kernel module (needed for PiFace)" and press "Enter".
- Highlight "Yes" and press "Enter" on "OK".
- Tab to "Finish" and press "Enter".
- Shutdown RPi and disconnect everything.
- Connect PiFace Digital board, connect everything back to RPi and power on.
- Open a consol window: [filebg]sudo nano /etc/modprobe.d/raspi-blacklist.conf[/filebg]
- Make sure that there is a hash (#) at the start of the line "blacklist spi-bcm2708" in the file and save the file and exit. If the file doesn't exist or is blank, then you are done.
If you did not use Yombo's PiBakery process for installing the Yombo Gateway, you need to perform these additional steps. If you are unsure, you can perform these steps as it won't harm anything:
- Open a console window
- [filebg]sudo apt-get update[/filebg]
- [filebg]sudo apt-get install python3-pifacedigitalio python-pifacedigitalio -y[/filebg
- Reboot your system.
Your system should be ready to go.
Tour of a Digital 2
There are a few jumpers and connections available on the PiFace Digital 2. Lets walk through them.
IO connection terminals
From the bottom right corner and working counter clockwise:
- (O-0) The first 3 connection terminals are for the first relay which is controlled by output 0 (zero). The first terminal is connected to the Normally Open (NO) terminal of the relay, the second is connected to the Common (C) terminal, and the third to the Normally Closed (NC) terminal.
- (O-1) The next 3 connection terminals for the second relay are identical to the above.
- Next are two ground connections, followed by a 5V connection.
Moving to the top right edge of the card:
- In the orange connection block, on the right is a 5V connection followed by the 8 terminals that are connected to the open collector outputs. They are controlled by outputs 0 through 7 in that order. The surface mounted LEDs just below show the status of the output controls. Note: Output 0 and 1 and connected to relay 0 and 1. You can disable relay control by removing JP5 and JP6 (respectively). This is useful if you decide to use an external relay board that can handle more power.
- In the green blocks are the input terminal connections. Starting from right to left, is input 0 through to input 7, then lastly a connection for ground. Directly below are 4 push button switches. Input 0 through 3 are controlled by the status of the switches as well as the signal levels of the input terminals. For example, either Switch-0 must be activated or the signal level at input terminal 0 must be high or both must be active for input 0 to be interpreted as '1'.
JP1 and JP2: Control board addressing when using multiple boards with a PiRack.
JP3 connects to 5V rail on Raspberry Pi. With it, Raspberry Pi can be powered from the 5V connection on the PiFace, or the PiFace can be powered from the Raspberry Pi. If you wish to power the PiFace independent of the Raspberry Pi, remove this jumper. JP4 connects the snubber diodes from the ULN2803A to 5V (snubber diodes protect the driving transistors from the high voltages that occur when a coil - e.g. a relay - turns off). However, if the open-collectors are connected to > 5V, these must be disconnected (else the diodes will conduct between the outputs and 5V). JP5 and JP6 control the relays based on the status of output 0 (zero) and 1 (one), see above. JP7 can be used to disconnect the power to all onboard outputs (i.e. disable the replays and LEDs).