Enable i2c on raspberry pi Ubuntu

Solution 1:

Here is how I managed to install raspi-config on the Pi 3 B running Ubuntu 18.04 server for ARM64:

wget -4 https://archive.raspberrypi.org/debian/pool/main/r/raspi-config/raspi-config_20210604_all.deb -P /tmp
apt-get install libnewt0.52 whiptail parted triggerhappy lua5.1 alsa-utils -y
apt-get install -fy
dpkg -i /tmp/raspi-config_20210604_all.deb

After these commands, raspi-config (albeit seemingly an older version) was installed on the Raspberry Pi. It does give a warning that it's only meant to work on Raspbian, but it seems to have done the job for me. After installing raspi-config, I had to mount the boot partition:

sudo mount /dev/mmcblk0p1 /boot

And then use sudo raspi-config, following the prompts to enable i2c (in Advanced Settings->i2c). Then ls /dev/i2c* responds with /dev/i2c-1, indicating that i2c is enabled. I then managed to detect my i2C device using sudo i2cdetect -y 1. I found the instructions for installing raspi-config in a script here.