Read SHTC3 Data

This section describes how to use VisionFive 2 or VisionFive 2 Lite's I2C to read SHTC3 data through an example program with Python.

Hardware Setup

Connect Sense HAT to the 40-pin header as follows.

Figure 1. Connect Sense Hat (B) to the 40-Pin GPIO Header
Sense HAT (B) 40-Pin GPIO Header
Pin Number Pin Name
3V3 1 3.3V Power
GND 9 GND
SDA 3 GPIO58 (I2C SDA)
SCL 5 GPIO57 (I2C SCL)

Run Demo Code

Perform the following steps on Debian of VisionFive 2 or VisionFive 2 Lite.

  1. Locate the directory where the test code, I2C_Sense_Hat.py, exists.

    1. Source into the PYthon3 Virtual Environment.
      source ./myvenv/bin/activate
    2. Install the dependency.
      python3 -m pip install pillow
    3. Get the directory where VisionFive.gpio exists.

      python3 -m pip show VisionFive.gpio
      Note: The output depends on how the application is installed.
    4. Enter the VisionFive.gpio directory.

      cd <VisionFive.gpio directory>
    5. Enter the sample-code directory.

      cd ./VisionFive/sample-code/
  2. Under the sample-code directory, execute the following command to run the demo code.

    sudo python I2C_Sense_Hat.py
    Alternatively, you can also run the following command.
    sudo python3 I2C_Sense_Hat.py
    The temperature and humidity data are displayed as follows.
    [riscv@fedora-starfive sample-code]$ sudo python3 I2C_Sense_Hat.py
    i2c_dev: /dev/i2c-1
    Temperature = 27.85°C , Humidity = 56.59 %
    
    Temperature = 27.83°C , Humidity = 56.60 %
    
    Temperature = 27.85°C , Humidity = 56.61 %
    
    Temperature = 27.86°C , Humidity = 56.60 %
    
    Temperature = 27.86°C , Humidity = 56.60 %
    
    Temperature = 27.80°C , Humidity = 56.60 %
    
    Temperature = 27.87°C , Humidity = 56.60 %
    
    Note: For details about the source code, see
  3. (Optional) Exit the Python3 Virtual Environment.

    deactivate