This is an old revision of the document!


Wiring Pi for Pure Data

Controlling the GPIO pins and an analog digital converter (MCP3008) in Pure Data on a Raspberry Pi.

Wiring for the Raspberry Pi was written by Gordon Henderson.
WiringPi for Pure Data was written by Miller Puckettte, Jaime Oliver La Rosa and Jeremiah Rose.
This is a workaround for installing the WiringPi object and using the analog digital converter MCP3008 for analog inputs in Pure Data on a Raspberry Pi 4 with Raspbian Buster.


Pure Data and Wiring Pi

Install Pure Data

In the terminal:

 $ sudo apt update
 $ sudo apt install puredata

Install Wiring

In the terminal:

 $ sudo apt-get install wiringpi

For the Raspberry Pi 4 one needs to update the WiringPi to version 2.52:

 $ cd /tmp
 $ wget https://project-downloads.drogon.net/wiringpi-latest.deb
 $ sudo dpkg -i wiringpi-latest.

http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/

Install the WiringPi for PD

Download: pd-wiringpi.zip
Unzip and copy the wiringPi_gpio and the wiringPi_mcp3008 folder in the PD external folder.
/home/pi/Documents/PD/externals
In Pure Data → Preferences → Path set the path to these two folders.


Pin Configuration

The Wiring library has its own pin labeling:
Wiring Pins.pdf
On Sparkfun one found a good pin labeling, too:
https://learn.sparkfun.com/tutorials/raspberry-gpio/all

For example:
pin 0 is GPIO 17
pin 1 is GPIO 18

Run WiringPi GPIO

The GPIO access needs administration rights, so one has to start Pure Data with these rights from the terminal:

 $ sudo pd


Open the wiringPi_gpio-help.pd file and have fun with the GPIOs!

WiringPi and the MCP 3008


For the hardware wiring of the 10 bit analog to digital converter MCP 3008 connect the pins of the MCP3008 like that:

 MCP3008       Raspberry Pi
 
  VDD           3.3V
  VREF          3.3V
  AGND          GND
  DGND          GND
  CLK           SCLK
  DOUT          MISO
  DIN           MOSI
  CS/SHDN       CE0


Before using the Wiring object enable the SPI interface in:

 $ sudo raspi-config

Open PD as administrator (sudo pd) and then open the wiring_mcp3008-help.pd file. After clicking on setup_wiringPi the analog inputs should work.