Not long ago I purchased a Pixy camera for use with the SGVHAK Air Hockey Project. This camera can be a stand alone object detection device. It can identify objects by color, sending back their location and size at 50 fps. This information can be sent to micro controllers and other devices over SPI, I2C and UART. The kit comes with a cable that plugs into the Arduino ICSP port. I wanted to hook the Pixy to my Raspberry Pi since my strategy code for the air hockey player is written in Python. Since this port is essentially a SPI connector and since the Raspberry Pi has SPI, I decided to get the Pixy and Raspberry Pi talking.

My solution was to adapt the Arduino Pixy SPI code from Charmed Labs. I converted their code into C++ that would compile under gcc. I also modified the SPI library calls to use the SPI interface from the WiringPi library. This library is purposefully similar to Arduino's libraries. Once I had that working, I next built a Python solution using a translated copy of the C++ code. This uses the WiringPi Python bindings known as WiringPi2-Python. I had to fix their SWIG generation because the wiringPiSPIDataRW interface was not built in a way that would actually return the response from the SPI bus. I have my work available in a Github repository.

I have a T-Cobbler Breakout Kit from eBay that pulls the Raspberry Pi GPIO pins out onto a breadboard, with labels. I was initially just using jumper wires from the 6 pin ICSP connector to the breakout board. To make connecting and disconnecting easier I made an adapter using breakaway pin headers. I simply cut a 3 by 4 piece of perfboard and soldered the 4 sets of 3 pins, the two outside ones downward and the 2 inside rows upward connected by solder bridges. This lets me use the two non connected sides of the breadboard. See the pictures below:

GPIO breakout connector
Camera connected to breakout board

I also got the PixyMon software compiled on the Raspberry Pi. I followed the instructions in the host/linux/README.linux file. My only change was to remove the -mno-ms-bitfields flag from the Makefile after running qmake as the version of gcc on the Pi does not support it.