Peripheral Examples

This topic provides examples of using the 40-pin GPIO header to connect to external peripherals.

Run Sense HAT (B) SHTC3 Sensor

This example connects Sense HAT (B) to VisionFive 2 and runs the SHTC3 sensor test program.
Note: The official libraries of BCM2835, Python, and wiringPi are not supported. Use the system call is instead.
  1. Connect Sense HAT to the 40-pin header of VisionFive 2 as follows.
    Figure 1. Connect Sense Hat (B) to the 40-Pin Header
    Sense HAT (B) VisionFive 2 Pin Number
    3V3 1
    GND 9
    SDA 3
    SCL 5
  2. Download the source code from

  3. (Skip if you already install the compile tool) Install the compile tool. For example:
    sudo apt-get install gcc-riscv64-linux-gnu
  4. Execute the following to compile:
    riscv64-linux-gnu-gcc SHTC3_dev.c -o shtc3
    It generates the shtc3 file in the same directory.
  5. Copy the executable code from the shtc3 file to the board, and change the execution permission by executing the following command:
    chmod +x shtc3
  6. Run the SHTC3 sensor.
    ./shtc3
    The output like the following indicates the execution is successful.
    
    root@starfive:~# ./shtc3 
    
    SHTC3 Sensor Test Program ...
    Fopen : /dev/i2c-0
    Temperature =  52.20°C , Humidity =  55.32% 
    Temperature =  23.81°C , Humidity =  55.29% 
    Temperature =  23.79°C , Humidity =  55.30% 
    Temperature =  23.82°C , Humidity =  55.29% 
    Temperature =  23.81°C , Humidity =  55.29% 
    Temperature =  23.82°C , Humidity =  55.30% 
    

Run 2.4inch LCD Module

This example connect the 2.4inch LCD Module to VisionFive 2 and demos how pictures are displayed.

  1. Connect the 2.4inch LCD module with the 40-pin header of VisionFive 2.
    Figure 2. Connect 2.4inch LCD with 40-Pin Header
    2.4inch LCD Module VisionFive 2 Pin Number
    VCC 17
    GND 39
    DIN 19
    CLK 23
    CS 24
    DC 40
    RST 11
    BL 18
  2. Download the source code from

  3. Execute the following command to copy the code to the board.
    tar -xvf LCD_Demo.tar.gz
    cd visionfive2/
    ./main 2.4
    The following two figures will be displayed in turn. One is the photo of VisionFive 2 and the other is the official example figure.
    Figure 3. Example Output