Some configuration of the PI needed to run these scripts :-

1) sudo raspi-config

Advanced / I2C / Yes to enable support 
             and Yes to load the module at boot.

2) Check /etc/modules contains

    i2c-bcm2708 
    i2c-dev

    and if not, add them

3) Edit /boot/config.txt and add

dtparam=i2c1=on
dtparam=i2c_arm=on

4) Get i2cdetect tool and python support

sudo apt-get install i2c-tools sudo apt-get install python-smbus
sudo adduser pi i2c

And reboot

5) Install wiringpi :- from http://wiringpi.com/download-and-install/

To install wiringpi as user pi into /usr/local/bin and /usr/local/lib do :-

sudo apt-get install git-core
cd /usr/local/src
git clone git://git.drogon.net/wiringPi
./build

To update to latest version in the future, do :-

cd /usr/local/src/wiringPi
git pull origin
./build

To test it is working

gpio -v
gpio readall

See "Wiring Pi" site for full documentation, and info on extensions for mcp23008, pcf8591

Quick examples :-

mcp23008 module (8 bit i/o at pin 100+)

To use these, first run "gpio load i2c"

gpio -x mcp230008:base:devId where base is the base pin number and devId is the devices I2C bus ID. 

The number of pins is known by the expansion module and it's 16 for the mcp23017 and 8 for the mcp23008.

The mcp23017 and mcp23008 only support mode (in, out, up, tri), read and write commands.

Examples:

gpio -x mcp23008:100:0:0 mode 100 out # Sets first pin (base+0) as output
gpio -x mcp23008:100:0:0 mode 101 in # Sets second pin (base+1) as input
gpio -x mcp23008:100:0:0 mode 101 up # Enables pullup on (base+1)
gpio -x mcp23008:100:0:0 read 101 # and reads it

For actual GPIO chip on PInebox, use gpio -x mcp23008:100:0x27:0

pcf8591 module (ADC at pin 110+)

The PCF8591 has a 4-channel, 8-bit analog input port and a single channel analog output port. 
The analog output uses base pin number 0, the same as analog input 0.

Examples:

gpio -x pcf8591:110:0:0 aread 110 # Read first ADC (base+0)
gpio -x pcf8591:110:0:0 aread 111 # Read second ADC (base+1)
gpio -x pcf8591:110:0:0 awrite 110 127 # Set DAC (base+0) to half voltage

For actual ADC chip on PInebox, use gpio -x pcf8591:110:0x4f:0 aread 110 and gpio -x pcf8591:110:0x4f:0 awrite 110 180 
