Retracing my steps getting analog inputs into Pure data Raspberry Pi .
1. Install Patchbox OS
Install Blokas Patchbox OS on the Raspberry Pi.
After booting:
• Connect and configure your sound card.
• Start JACK and confirm audio is working.
Note:
JACK initially didn’t work until the sound card was added. I used a Focusrite scarlett
2. Enable SPI on the Raspberry Pi
The MCP3008 uses SPI, so this must be enabled.
Open the configuration tool:
sudo raspi-config
Go to:
Interface Options → SPI → Enable
Reboot if prompted.
3. Wire the MCP3008
Wire the Adafruit MCP3008 ADC to the Raspberry Pi via SPI.
This guide is excellent:
https://learn.adafruit.com/mcp3008-spi-adc/python-circuitpython
Follow the wiring diagram for Raspberry Pi SPI.
4. Create a Python Virtual Environment
Newer Raspberry Pi systems restrict system-wide pip installs, so use a virtual environment.
Create a project folder:
mkdir mcp_project
cd mcp_project
Create the environment:
python3 -m venv env
Activate it:
source env/bin/activate
Guide reference:
https://www.raspberrypi.com/news/using-python-with-virtual-environments-the-magpi-148
5. Install Required Python Libraries
Install the MCP libraries and OSC library:
pip install adafruit-circuitpython-mcp3xxx
pip install python-osc
OSC library reference:
https://pypi.org/project/python-osc
6. Run the Python Script
Run your Python script that:
• Reads values from the MCP3008
• Sends them as OSC messages
Example:
python mcp_to_osc.py
7. Stop the Python Script
To stop the script:
Ctrl + Z
(or Ctrl + C depending on how the script is running)
8. Receive OSC in Pure Data
In Pure Data:
• Create an OSC receive object
• Set the correct port
• Check the debug window
Important lesson learned:
If OSC appears not to work, double-check the PD debug window settings.
Key Lessons
• JACK may require adding the sound card first.
• SPI must be enabled for the MCP3008.
• Use a Python virtual environment on newer Raspberry Pi systems.
• If OSC isn’t arriving in PD, check the debug window configuration.
If you want, I can also make a small MCP3008 → OSC Python template script that is very clean and minimal (perfect for sensors → Pure Data setups). It saves a lot of time when starting new projects.
Leave a Reply