How can I talk to digital sensors over the I²C interface?
Which pins on the Raspberry Pi's GPIO can I use?
What I²C libraries are available?
There's a lot of information about RPi's GPIO here: http://elinux.org/Rpi_Low-level_peripherals
According to it, you can program any GPIO pins for I²C, but:
Pin 3 (SDA0) and Pin 5 (SCL0) are preset to be used as an I²C interface. So there are 1.8 kilohm pulls up resistors on the board for these pins.
That wiki page also has some low-level GPIO code examples for various languages that should get you started. If you need a refresher on what I²C actually is, here's one which also takes the RPi into account.
Lots of discussions going on about this. Here's what my reading and messing around with shows me:
As mentioned by Tapio, the hardware is well documented at http://elinux.org/Rpi_Low-level_peripherals
There is a i2c-dev header in the Linux userspace (
#include <linux/i2c-dev.h>). Furthermore you need a character decive to read from. This can be done by loading the correct modules.
i2c_bcm2708 for the low level driver and
i2c-dev for generating the character decives for the busses. Apply ...
sudo modprobe -r i2c_bcm2708 sudo modprobe i2c_bcm2708 baudrate=<your preferred baudrate>
for loading them on the fly. Apply ...
sudo sh -c 'echo "i2c-dev" >> /etc/modules' sudo sh -c 'echo "options i2c_bcm2708 baudrate=<your preferred baudrate>\n" > /etc/modprobe.d/custom.conf
/etc/modprobe.d/raspi-blacklist.conf to make
/dev/i2c-1 show up permanently.
From now on you can follow the hints on how to use I²C del maestro himself.
I prefer this method over others, because it is platformagnostic. Your can use
linux/i2c-dev.h with other devices too, as long as there exists a low level I²C driver.
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?