PiFace Digital 2 (
GIT,
Python) IO controller is an add-on pi HAT that allows you to control external and internal LEDs, relays, etc. Add in a pi camera and it is basically your own personal mini pi robot.
PiFace Digital 2 includes eight inputs, eight outputs, eight LED’s, two relays and four switches and can be used for your Raspberry Pi projects. It is a simple plug on board to your GPIO pins, but does require some additional software and configuration changes. I have included the bare-bones to start accessing your PIFace controller.
Enable SPI
sudo raspi-config5 Interfacing Options Configure Connections to peripherals
P4 SPI Enable/Disable automatic loading of SPI kernel module
Would you like the SPI interface enabled?
<Yes>
(The standard apt-get install did not work as mentioned on the PIFace site, I had to use PIP to install it on my pi 3)
Install Required Python Libs
Ref: https://github.com/piface/pifacedigitalio/issues/35
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-pip
sudo apt-get install python3-pip
Python
sudo pip install pifacecommon
sudo pip install pifacedigitalio
Python3
sudo pip3 install pifacecommon
sudo pip3 install pifacedigitalio
Samples
https://pypi.org/project/pifacedigitalio/
At this point you should be able to create a simple on and off script.
pfon.py
import pifacedigitalio
pd = pifacedigitalio.PiFaceDigital()
pd.leds[4].turn_on()
pd.relays[0].turn_on()
pfoff.py
import pifacedigitalio
pd = pifacedigitalio.PiFaceDigital()
pd.leds[4].turn_off()
pd.relays[0].turn_off()
Run the first one to turn the LED 0 and Relay 0 On
python pfon.py
Run the second to turn them off
python pfoff.py