Welcome to DOFBOT Pro repository
7.I2C communication
I2C communication
The I2C pins of the motherboard are shown in the figure, where physical pins 3 and 5 are I2C pins. You need to enable the I2C service before using it.

First install I2Ctool, enter in the terminal:
sudo apt-get updatesudo apt-get install -y i2c-tools
Check the installation status, enter in the terminal:
xxxxxxxxxxapt-cache policy i2c-tools
The output is as follows, which means the installation is successful
xxxxxxxxxxi2c-tools:Installed: 4.0-2Candidate: 4.0-2Version list:*** 4.0-2 500500 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 Packages100 /var/lib/dpkg/status
Scan all i2c devices on a bus and print out the device i2c bus address, for example here If a device with address 0x0f is mounted on the I2C pin, the corresponding device I2C address will be displayed
xxxxxxxxxxsudo i2cdetect -y -r -a 1

If you are using the Jetson Orin NX or Jetson Orin Nano motherboard, you need to change the device number from 1 to 7.
xxxxxxxxxxsudo i2cdetect -y -r -a 7

smbus is a python library. If smbus is not installed, enter the terminal:
xxxxxxxxxxsudo apt-get updatesudo apt-get install -y python3-smbus
The Smbus protocol has many related library functions that can be used for I2C communication

Wiring situation:
Pin 3 (SDA) → oled module SDA
Pin 5 (SCL) → oled module SCL
Pin 1 (3.3V) → oled module VCC
Pin 6 (GND) → oled module GND
The OLED module has been connected to the wire sequence, just install it in the GPIO direction.

Import Adafruit_SSD1306 library This is the oled library. If you use your own image, you need to download this library
xxxxxxxxxxpip install Adafruit_SSD1306

Initialize oled:

Then read some basic information functions of nano. If you are interested, you can go to this py file to learn more about it, which is to obtain local IP, TF card space occupancy, memory occupancy, system time and other information.
Terminal input:
xxxxxxxxxxsudo python3 ~/software/oled_yahboom/yahboom_oled.py
Note: The system defaults to enabling the OLED screen service. Running the program again will cause repeated screen refreshes. Please run the following command to stop the OLED screen service.
xxxxxxxxxxsudo systemctl stop yahboom_oled.service
Experimental phenomenon:
