RaspDuino Software Installation

In previous step (Raspberry Pi Software installation) we already downloaded the latest stable source code for RaspDuino project using git tools. The RaspDuino project consist in a RPi and an Arduino Uno R3 board connected using I2C, and some hardware attached to the Arduino Board and mechanisms to mangage these hardware from the RPi. The Arduino will be like a bridge that enables information to come from/to the physical world to/from the RPi.

Hardware includes:
  • A TM1638 based board that provides 8 buttons, 8 two-color leds and 8 7 segments digits.
  • A board that includes a Liquid Crystal Display and some navigation buttons.
  • An status led.

TM1638 Arduino Library Installation

In order to be able to compile the RaspDuino software we will need to install the TM1638 library into the Arduino IDE.

Download and install the TM1638 library.

cd ~
cd sketchbook
cd libraries/
wget http://tm1638-library.googlecode.com/files/TM1638%20Library%20v2.1.3.zip
unzip TM1638\ Library\ v2.1.3.zip 
rm TM1638\ Library\ v2.1.3.zip 

Compiling & uploading Arduino source code

arduino &
  • Select Files→SketchBook→gatArduinOSEKsample project and load it.
  • Verify
  • Upload
  • Once loaded, halt the RPi ('sudo halt usual command’).
  • Once RPi is halted, unplug power supply.
  • Attach RaspDuino connections board to the Arduino Uno R3.
  • Attach the LCD board to the RaspDuino connections board.
  • Power on the system.

As the I2C bus is not connected and no RPi RaspDuino software is being executed, the display will show RPiStat...UNKNOWN.
As the TM1638 board is not connected, the button state is shown as 11111111 (Arduino thinks 8 buttons are pressed).

Similar to this:

RPiStat..UNKNOWN
NONE   11111111

You can use the navigation buttons to see the message NONE to be changed to LEFT, RIGHT, UP, DOWN, and SELECT.
The remaining button will cause Arduino board to be resetted (it is the reset button).

I2C bus wiring

To connect I2C bus we are using this schema:

http://blog.oscarliang.net/raspberry-pi-arduino-connected-i2c/

  • Close Arduino IDE windows.
  • 'sudo halt’ the RPi.
  • Unplug the power supply.
  • Locate the cables coming from the RaspDuino connections board identified by I2C.
RPI               Arduino (Uno/Duemillanove)
--------------------------------------------
GPIO 0 (SDA) <--> Pin 4 (SDA)
GPIO 1 (SCL) <--> Pin 5 (SCL)
Ground       <--> Ground
Please take note that colors may vary.
In our case:
RaspDuino Connection Board Wire Color RaspDuino Connector Pin Arduino Pin RPi Pin RPi Connector Pin RPi Wire Color
Black 1 GND GND 1 Black
Blue 2 SCL A5 SCL GPIO 1 2 Yellow
Orange 3 SDA A4 SDA GPIO 0 3 Orange

I2C bus installation

Using information from: http://blog.oscarliang.net/raspberry-pi-arduino-connected-i2c/

sudo nano /etc/modprobe.d/raspi-blacklist.conf
# blacklist spi and i2c by default (many users don't need them)
blacklist spi-bcm2708
# RaspDuino enables i2c
#blacklist i2c-bcm2708
sudo nano /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.

snd-bcm2835
# RaspDuino added i2c module
i2c-dev
sudo apt-get install i2c-tools
...
sudo adduser pi i2c
...
sudo reboot

After rebooting:

$> ls -la /dev/i2c*
crw-rw---T 1 root i2c 89, 0 Jul 13 20:04 /dev/i2c-0
crw-rw---T 1 root i2c 89, 1 Jul 13 20:04 /dev/i2c-1
$> i2cdetect -y 1
i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- 04 -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- 

NOTE:investigate this UU.

Now we will send a command through I2C in order to know if the Arduino is listening to the RPi.

pi@raspduino ~ $ cd ~/sketchbook
pi@raspduino ~/sketchbook $ cd gatArduinOSEKsample/rpi_i2c_master/
pi@raspduino ~/sketchbook/gatArduinOSEKsample/rpi_i2c_master $ make
gcc i2cTest.c -o i2cTest
gcc i2cFork.c -o i2cFork
pi@raspduino ~/sketchbook/gatArduinOSEKsample/rpi_i2c_master $ ./turnonrpi.sh
I2C: Connecting
I2C: acquiring buss to 0x4
Sending rs0
Argument sent!
Received 111111110    
I2C: Connecting
I2C: acquiring buss to 0x4
Sending rs1
Argument sent!
Received 111111111    
I2C: Connecting
I2C: acquiring buss to 0x4
Sending rs2
Argument sent!
Received 111111112    

NOTE: the Makefile to compile i2cTest and i2cFork was introduced AFTER the release v0.1 of the RaspDuino software. If there is not a newer release the 'make’ command will fail. You can obtain same result if you execute:

gcc i2cTest.c -o i2cTest
gcc i2cFork.c -o i2cFork

We can see the UNKNOWN word in the LCD display to change first to INIT and then to READY.
Everything is ok!

TM1638 board installation:

TODO