This is an old revision of the document!
This document mainly introduces the usage of I2C bus on 40-Pin Header.
I2C A
Sensor SCL ↔ I2C_SCK_A (PIN 22)
Sensor SDA ↔ I2C_SDA_A (PIN 23)
Sensor GND ↔ GND
Sensor VCC ↔ 5V or 3.3V //depends on your sensor
I2C B
Sensor SCL ↔ I2C_SCK_B (PIN 25)
Sensor SDA ↔ I2C_SDA_B (PIN 26)
Sensor GND ↔ GND
Sensor VCC ↔ 5V or 3.3V //depends on your sensor
I2C 3
Sensor SCL ↔ I2C0_SCK (PIN 22)
Sensor SDA ↔ I2C0_SDA (PIN 23)
Sensor GND ↔ GND
Sensor VCC ↔ 5V or 3.3V //depends on your sensor
I2C 4
Sensor SCL ↔ I2C1_SCK (PIN 25)
Sensor SDA ↔ I2C1_SDA (PIN 26)
Sensor GND ↔ GND
Sensor VCC ↔ 5V or 3.3V //depends on your sensor
| I2C | PIN & GPIO Number | DT Overlays Node | Bus Number | Device Node |
|---|---|---|---|---|
| I2CM 3 | SCL - PIN22 - GPIOA_15 (#475) SDA - PIN23 - GPIOA_14 (#474) | i2c3 | 3 | /dev/i2c-3 |
| I2C AO | SCL - PIN25 - GPIOAO_2 (#498) SDA - PIN26 - GPIOAO_3 (#499) | - | 4 | /dev/i2c-4 |
| I2C | PIN & GPIO Number | DT Overlays Node | Bus Number | Device Node |
|---|---|---|---|---|
| I2CM A | SCL - PIN25 - GPIOT_20 (#466) SDA - PIN26 - GPIOT_21 (#467) | i2cm_a | 0 | /dev/i2c-0 |
| I2CM F | SCL - PIN22 - GPIOY_17 (#501) SDA - PIN23 - GPIOY_18 (#502) | i2cm_f | 5 | /dev/i2c-5 |
In order to use the I2C, you need to enable the I2C function via Device Tree Overlay.
Edit /boot/env.txt to add the i2c node to overlays node.
Take VIM3 as an example to enable i2c3:
overlays=uart4 pwm_ao_a pwm_f i2c3
After reboot, you will see the I2C device node.
$ ls /dev/i2c-3
/dev/i2c-3
Edit /boot/dtb/amlogic/kvim4.dtb.overlay.env to add i2c node to fdt_overlays node.
e.g. Enable I2CM A, you need to add i2cm_a to node fdt_overlays.
fdt_overlays=i2cm_a
After reboot, you will see the I2C device node.
$ ls /dev/i2c-0
/dev/i2c-0
If you want to use normal GPIO instead of I2C, you can remove the I2C node in device tree overlays configration file.