Install driver library

1. Introduction

After installing the CubeRaspberry driver library, you can call the corresponding API function to control the RGB lights and fan peripherals.

You can also follow the steps below to update the driver library!

Please refer to the following steps to install the driver library. Here, we take the installation of version V1.0.2 as an example.

Note: The CubeRaspberry chassis will automatically turn on the RGB lighting effect and fan when it is powered on.

2. Install dependent libraries

1. smbus library

The installation of the CubeRaspberry driver library requires the import of the time library and the smbus library. The time library comes with Python and does not need to be installed by yourself. You can install the smbus library by entering the following command in the terminal.

Python smbus library functions are used to access serial I2C devices. Smbus library functions can be used to read and write I2C device information.

2. Adafruit_SSD1306 library

Since OLED display also requires related dependent libraries, we can install the required dependent libraries at the same time. Enter the following command in the terminal to install the Adafruit_SSD1306 library.

The python Adafruit_SSD1306 library is used to control the data display of our OLED display.

Note: If the OLED display tutorial prompts that the PIL library is missing, you can take the following solution.

3. Python driver library file

This course material provides the latest version of the CubeRaspberry Python driver library, named CubeRaspberryLib_V1.0.2

image-20230714180310668

4. Transfer files to the motherboard system

The following is a brief introduction to several methods of transferring files. You can choose the method you are familiar with for specific operations.

Choose one of the methods to transfer the CubeRaspberryLib_V1.0.2.zip file to the motherboard system.

5. Driver library installation

Open the terminal in the folder directory where the compressed package is located and enter the following command:

The purpose of this command is to decompress and enter the setup.py directory to run the installation command. You don’t have to worry about whether the version number is consistent.

image-20230714181607653 image-20240714181607653

If you see the installation version number at the end, it means the installation is successful. This command will overwrite the previously installed CubeRaspberryLib driver library.

You can also use the following command to confirm whether the library is installed successfully

The installation is successful, as shown in the figure image-20240723181667653

6. Import library file

The name of the CubeRaspberry driver library is CubeRaspberryLib. Use CubeRaspberryLib to import the library in the program.

VII. Check the firmware version number

1. Check the version number

(Python interactive interface: each statement needs to be run separately)

Enter python in the terminal to enter the interactive interface

image-20230717201747013

2. bot = CubeRaspberry(i2c_bus=1)

Using the smbus library function, we need to create an object, where the 1 in i2c_bus=1 represents i2c - 1. The I2C device we are currently using is mounted on this device bus.

We can query the bus and address of the specific device through the following steps.

Query the I2C bus

All the lists displayed by the system need to be queried. We need to find the bus where the two devices are mounted.

Query I2C devices

Find the device bus with I2C address 0e and 3c. This bus is the device bus object we need to create.

image-20230717204338694

8. API Introduction

The following is an introduction to the API of the CubeRaspberry driver library. The function usage and parameter content will be introduced in the control course later.