# How to enable I2C on rpi3?

I’ve got an air quality sensor I would like to attach to the rpi3 running OSMC, however it looks like I2C is not enabled by default.

``````osmc@pi3:~\$ i2cdetect -y 1
Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory
``````

When running raspi-config it states to use MyOSMC, however I don’t see any I2C options in the GUI, I only see a checkbox for SPI.

How can I enable I2C?

Thanks

Hi,

`dtparam=i2c_arm=on`

to:

`/boot/config.txt`

And reboot, you should be good.

Thanks Tom.

The My OSMC add-on has a config editor in the RPi section that allows entering other options in the GUI.

1 Like

Seems to work, thanks!

``````osmc@pi3:~\$ sudo i2cdetect -y 1
0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --``````

My sdcard broke and I had to use a backup from july 2019. I tried your suggestion again but without any luck this time…

``````osmc@SkyPi3:~\$ cat /boot/config.txt
gpu_mem_1024=256
hdmi_ignore_cec_init=1
disable_overscan=1
start_x=1
disable_splash=1
gpu_mem_256=112
sdtv_aspect=1
gpu_mem_512=144
dtparam=i2c_arm=on
dtoverlay=gpio-ir,gpio_pin=18

osmc@SkyPi3:~\$ sudo i2cdetect -y 1
Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory
``````

I think I remember at some point I also tried changing the gpio pin functionality to i2c with a command but I can’t remember what that command was exactly. Any idea why it’s not working?

Have you rebooted after editing that config.txt

Yes of course

Apparently i2c-dev module is not loaded at boot time, after running

`sudo modprobe i2c-dev`

It works. Weird!

I just thought I’d share that this guidance on i2c solved my issue with the ArgonOne case fan not working properly. Basically the argon one service was failing to start because i2c wasn’t enabled on OSMC. I’ve got it running but suspect the next update may break my config.

Nev

The config.txt file in OSMC is not considered a safe file to edit as system updates to it will remove user customizations. Edits should now be placed in config-user.txt which will not be touched with updates.

Great top tip. Thanks very much!

1 Like