Install the I2C tools on your Raspberry Pi: sudo apt-get install i2c-tools

Enable the I2C by editing the /boot/config.txt file: sudo nano /boot/config.txt

Add the following two lines:

dtparam=i2c1=on
dtparam=i2c_arm=on

Reboot the Raspberry Pi: sudo reboot

Test that I2C is set up: sudo i2cdetect -y 1