Use I2C on raspberry pi with archlinux-arm

For Raspbian there is raspi-config to enable i2c on a raspberry pi. On a system without raspi-config (or if you want to enable i2c on the image before boot) the changes are pretty simple.

The two things raspi-config is changing are:

  • Adding one line to /boot/config.txt:

dtparam=i2c_arm=on
  • Adding one line to /etc/modules-load.d/raspberrypi.conf:

i2c-dev

To get the config and module loaded a reboot of the raspberry pi is necessary.

Then you will problably want to install i2c-tools. For example on archlinux-arm:

pacman -S i2c-tools

And search for i2c sensors plugged in:

i2cdetect -y 1

This could look like this:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 77

The sensors shown here are: ADS1015 (0x48), BME280 (0x76), and BMP180 (0x77).