Today, I tried connecting my Raspberry Pi to an Arduino via I2C bus following roughly the guide from Oscar Liang.
According to the GPIO pinout, we have to connect pins 3 and 5 of Pi's GPIO port to Arduino's A4 and A5 pins.
First, the revision of the Raspberry Pi is important to determine which I2C port to use. Output of /proc/cpuinfo is
$ cat /proc/cpuinfo
Processor : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
Features : swp half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7
Hardware : BCM2708
Revision : 0002
Serial : xxx
That means, that according to this list ...
'0002' => 'Model B Revision 1.0',
'0003' => 'Model B Revision 1.0 + Fuses mod and D14 removed',
'0004' => 'Model B Revision 2.0 256MB', (Sony)
'0005' => 'Model B Revision 2.0 256MB', (Qisda)
'0006' => 'Model B Revision 2.0 256MB', (Egoman)
'0007' => 'Model A Revision 2.0 256MB', (Egoman)
'0008' => 'Model A Revision 2.0 256MB', (Sony)
'0009' => 'Model A Revision 2.0 256MB', (Qisda)
'000d' => 'Model B Revision 2.0 512MB', (Egoman)
'000e' => 'Model B Revision 2.0 512MB', (Sony)
'000f' => 'Model B Revision 2.0 512MB', (Qisda)
...I have a Model B Revision 1.0 and therefore according to this overview I have to use -y 0 in the i2c commands following.
After installing the i2c-tools
$ sudo apt-get install i2c-tools
we can try to find the I2C device Arduino:
$ /usr/sbin/i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- 04 -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Now write a 1 to Arduino with:
/usr/sbin/i2cset -y 0x00 0x04 1
On the Arduino I installed a Wire program from Arduino's examples.