A quick tutorial to using MiniPiio AIN4 4-ch Analog Board

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:

MiniPiio_Expander2_DIO16_AIN4_small

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: