Posts Tagged ‘Tutorial’

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

March 28th, 2014 No comments

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:


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:

[code language=”python”]

import spidev
import time

# ADC Channel

# Open SPI, use Chip Select 0
spi = spidev.SpiDev(),0)

while True:

adc = spi.xfer2([1,(8+ADCCHAN)<<4,0]) data = ((adc[1]&3) << 8) + adc[2] print ('ADC CH1 =', data) [/code] 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 RS232 set-up

November 26th, 2013 No comments

By default the Raspbian uses the serial UART to access the shell console. To change this we need to make a few small changes to the cmdline.txt and inittab files

Make a backup of the two files we’ll be changing.

sudo cp /boot/cmdline.txt /boot/cmdline.bak
sudo cp /etc/inittab /etc/inittab.bak

In the LXterminal shell type the command:

sudo leafpad /boot/cmdline.txt

Find and remove “console=ttyAMA0,115200” and “kgdboc=ttyAMA0,115200” parameters.

The cmdline.txt will probably contain the default configuration line:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200
console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Find and remove “console=ttyAMA0,115200” and “kgdboc=ttyAMA0,115200” configuration parameters so it looks something like this:

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Make sure to save the file and quit the editor.

Finally edit the “/etc/inittab” file to disable the use of the “ttyAMA0” serial port. In LXterminal type this command:

sudo leafpad /etc/inittab

Near the bottom of the file, look for a configuration line that includes the “ttyAMA0” port address.

Type a hash (or pound) sign (“#”) in front of the line “ttyAMA0”.

Save the file and exit the editor. Once done to reboot your Pi.

Once the Pi is rebooted, you can use “ttyAMA0” to access the serial port.