Through the meetup I organise, RaspberryPint, I received a Raspberry Pi Interface Board and an I2C Port Expander Kit from Quick2Wire. These kits are self-assembly and enable lots of cool possibilities for control of the real world and protect the Raspberry Pi in case of wrong connections which could otherwise burn out your Pi - eek.
I have written a series of blog posts about assembling and using these Quick2Wire kits. This is Part 2: Quick2Wire I2C Port Expander Kit assembly
Part 1: Assembling Quick2Wire's Raspberry Pi Interface Board
Part 2: Assembling Quick2Wire's I2C Port Expander Kit
Part 3: My first project with my expanded Pi (yet to be written)
First I followed the straight-forward Assembly Instructions. which combined the components shown below into the finished port expander.
Then made some configuration changes to my Raspberry Pi. Out of the box the Raspberry Pi does not enable spi and i2c interfaces, these must be enabled by removing them from the blacklist and specifying a driver on your Raspberry Pi as follows:
Power up and log in to your Raspberry Pi
Add a # to the two lines beginning with blacklist so you end up with
Save (ctrl-o, return) and exit (ctrl-x). Now add an I2C driver to your config...
$ sudo nano /etc/modules
add i2c-dev at the bottom of the file so you end up with:
Check the i2c device drivers are working with ls -la /dev/i2c-0 and i2c-1. These commands should result in an error because a reboot is required to make your changes active. Reboot you RPi with sudo reboot and try again, you should see something like this:
Next install i2ctools
$ sudo apt-get update
$ sudo apt-get install i2c-tools
$ sudo i2cdetect -y 0
Next an example project using these extra interfaces provided by the Quick2Wire boards - Part 3 yet to be written
Back to Part 1: Assembling Quick2Wire's Raspberry Pi Interface Board
I have written a series of blog posts about assembling and using these Quick2Wire kits. This is Part 2: Quick2Wire I2C Port Expander Kit assembly
Part 1: Assembling Quick2Wire's Raspberry Pi Interface Board
Part 2: Assembling Quick2Wire's I2C Port Expander Kit
Part 3: My first project with my expanded Pi (yet to be written)
First I followed the straight-forward Assembly Instructions. which combined the components shown below into the finished port expander.
Then made some configuration changes to my Raspberry Pi. Out of the box the Raspberry Pi does not enable spi and i2c interfaces, these must be enabled by removing them from the blacklist and specifying a driver on your Raspberry Pi as follows:
Power up and log in to your Raspberry Pi
$ sudo nano /etc/modprobe.d/raspi-blacklist.conf
Add a # to the two lines beginning with blacklist so you end up with
# blacklist spi and i2c by default (many users don't need them) #blacklist spi-bcm2708 #blacklist i2c-bcm2708
Save (ctrl-o, return) and exit (ctrl-x). Now add an I2C driver to your config...
$ sudo nano /etc/modules
add i2c-dev at the bottom of the file so you end up with:
# /etc/modules: kernel modules to load at boot time. # # This file contains the names of kernel modules that should be loades # at boot time, one per line. Lines beginning with "#" are ignored # Parameters can be specified after the module name. snd=bcm2835 i2c-dev
Check the i2c device drivers are working with ls -la /dev/i2c-0 and i2c-1. These commands should result in an error because a reboot is required to make your changes active. Reboot you RPi with sudo reboot and try again, you should see something like this:
Next install i2ctools
$ sudo apt-get update
$ sudo apt-get install i2c-tools
$ sudo i2cdetect -y 0
Connect the I2C Port Expander board to the I2C1 connector on the Interface Board and re-run the command for interface 1. You should see a difference as shown below which is the expander board showing up on the i2c bus at address 20.
This address can be changed up to 27 using the DIP switch on the expander board - give it a go you don't need to shutdown or reboot the RPi to see it change.
To stop having to run commands as root using sudo, do the following and reboot:
sudo adduser pi i2c
The I2C expander board has 16 additional GPIO ports and you can daisy chain up to 8 expander boards (giving each a different address using the DIP switches) to provide 128 inputs/outputs!
Next an example project using these extra interfaces provided by the Quick2Wire boards - Part 3 yet to be written
Back to Part 1: Assembling Quick2Wire's Raspberry Pi Interface Board
No comments:
Post a Comment