Running Example with Sense Hat (B)
Take SHTC3 sensor as an example:
- Download the source code from: SHTC3_dev.c
-
(Optional) Install the tool to compile. The following is an example to install:
sudo apt-get install gcc-riscv64-linux-gnu
Note: This step can be skipped if the tool has been installed. -
Execute the following to compile:
riscv64-linux-gnu-gcc SHTC3_dev.c -o shtc3
Result:The output file is shtc3 in the same directory.
-
Copy the executable code from the shtc3 file to the board, and change the execution
permission by executing the following command:
chmod +x shtc3
-
Execute the following command to run:
./shtc3
Result:The following output 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%