The latest version of raspi-config allows you to enable the SPI drivers without having to edit raspi-blacklist.conf file yourself.
In LXTerminal start raspi-config by type:
raspi-config
Select the advance menu option and chose enable SPI devices. Exit the menu and reboot your Pi.
We’ll program our example in Python, so we’ll start by downloading the SPIdev driver library.
We can use Python Installer to get install it:
sudo pip install spidev
A quick python example is shown below:
#!/usr/bin/python import spidev import time # ADC Channel ADCCHAN = 1 # Open SPI, use Chip Select 0 spi = spidev.SpiDev() spi.open(0,0) while True: adc = spi.xfer2([1,(8+ADCCHAN)<<4,0]) data = ((adc[1]&3) << 8) + adc[2] print ('ADC CH1 =', data)
The MiniPIIO Uses a Microchip MCP3004 (or MCP3204) which are from the same ADC familily as the MCP3008
You can find the MiniPIIO AIN4 at our Tindie store: