Q: How to enable I2C function on Raspberry Pi?

A: You can enable the I2C function of Raspbery Pi.

The way to enable the I2C function is different on each OS.
Here are the examples for Raspberry Pi OS and Ubuntu OS as below.

■ For Raspberry Pi OS

You can enable the I2C function on GUI or CUI.
This information is confirmed on Raspberry Pi OS August 2020.

   1.When enabling with GUI

Select "Preference" ⇒ "Raspberry Pi Configuration".

Set "I2C" to "Enable" in "Interface", click OK, and then restart.

  2.When enabling with CUI

Please execute the following command.
sudo raspi-config

The setting screen of Raspberry Pi opens. Select "5. Interfacing Options" and select "I2C" in the displayed items.

Select "I2C" and press "YES". The menu screen will reappear, so select <Finish>.

Please restart your Raspberry Pi.

After restarting, execute the following command.
ls / dev / * i2c *

If the following is displayed after execution, I2C is enabled.
/dev / i2c-1

 

■ For Ubuntu OS

     Ubuntu 20.04.01 LTS Server Enabled by default.