Knowledge Base

The AB Electronics UK Knowledge Base provides support solutions, tutorials and troubleshooting guides.

Knowledge Base

I2C and SMBus on the Tinker Board

Configuring I2C and SMBus with Python on the Asus Tinker Board

The Asus Tinker Board contains two I²C buses on the 40-pin GPIO header named I2C1 and I2C4, as shown in the image below. I2C1 uses pin 3 for SDA and 5 for SCL. I2C4 uses pin 27 for SDA and 28 for SCL.

I2C layout

This page details how to set up I²C support for the I2C1 bus, which is used by most Raspberry Pi compatible hats and expansion boards, including those from AB Electronics UK.

Step 1: Download the latest TinkerOS Debian image for your Tinker Board and burn it to your SD Card following the instructions on http://elinux.org/RPi_Easy_SD_Card_Setup

Step 2: Next, you need to update your Tinker Board to ensure all the latest packages are installed:

sudo apt-get update
sudo apt-get upgrade

Step 3 a: Once you have updated your Tinker Board, run the following command to install the Python smbus and dev libraries and the i2c-tools packages:

sudo apt-get install python3-smbus python3-dev i2c-tools

Step 4: Edit the /boot/config.txt file using nano or your preferred text editor:

sudo nano /boot/config.txt

Uncomment the line "intf:i2c1=on" as shown in the screenshot below, and save the file. To use the I2C4 bus, uncomment the "intf:i2c4=on" line changing "off" to "on".

Enabling I2C

Step 5: To avoid needing to run the I²C tools at root, add the 'linaro' user to the "i2c" group:

sudo adduser linaro i2c

Step 6: Next, reboot the Tinker Board:

sudo reboot

When your Tinker Board has rebooted, you will now have I²C and SMBus Python support.

You can find available I²C devices using the following command.

sudo i2cdetect -y 1

A grid of I²C addresses will be displayed with available devices shown by their address number.

I2C Detect

To learn more about I²C and how to use it, read our tutorial series Introducing I2C.


Was this article helpful? Yes No

Please tell us how we can improve this article:

Submit
Created 11/02/2017 | Last Updated: 25/10/2023