Skip to main content

4. I2C

4.1 Enabling I2C Interface​

Core3566 has two I2C channels: I2C-5 (pins 3 and 5) and I2C-3 (pins 27 and 28). I2C-3 is enabled by default, and to enable I2C-5, follow the steps below (refer to the PWM section):

  1. View I2C devices:

    inaro@linaro-alip:~$ ls /dev/i2c*
    /dev/i2c-0 /dev/i2c-1 /dev/i2c-3
  2. After configuring with the luckfox-config tool, restart the device and enter the following command in the terminal to check:

    ls /dev/i2c*
  3. The result will show that /dev/i2c-5 has been successfully enabled:

    linaro@linaro-alip:~$ ls /dev/i2c*
    /dev/i2c-0 /dev/i2c-1 /dev/i2c-3 /dev/i2c-5

4.2 Hardware Connection​

  • This example uses the Waveshare 1.5inch OLED Module. For detailed parameters and usage of the module, refer to the Waveshare official Wiki.

  • Note: The module is initially set to use 4-wire SPI communication, with BS connected to 0. If I2C communication is used, BS needs to be connected to 1 (1 and 0 do not represent the logic level, but rather the resistor soldering method).

  • Pin connection between Core3566 and 1.5inch OLED Module:

    1.5inch OLED ModuleCore3566 Board Physical Pin NumberFunction
    VCC5VPower Input
    GNDGNDGround
    DINI2C5_SDAI2C Data Input
    CLKI2C5_SCLI2C Clock Signal
    DC5VSet device address to 0X3D by pulling DC high
  • Wiring Diagram

4.3 i2c-tools​

  • Query I2C device addresses:

    i2cdetect -y -r -a 5
    linaro@linaro-alip:~$ sudo i2cdetect -y -r -a 5
    0 1 2 3 4 5 6 7 8 9 a b c d e f
    00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- 3d -- --
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    • Parameters: -y ignores interactive issues and executes directly, -r is the SMBus read byte command, -a is for all addresses, and 5 is for i2c-5.
  • Scan register data:

    sudo i2cdump -y 5 0x3d

4.4 Controlling with Python Program​

  • Download the example program and run it in the terminal:

    cd ~/OLED_1in5/
    sudo python3 OLED_1in5_i2c.py