Use Gsensor in Ubuntu.
Gsensor Node
1 | $ ll /dev/accel |
Gsensor Demo
Read and write nodes using the ioctl function.
Source Code
The following source code only utilises the default settings to read data, additional functions can be implemented by the user.
1 | $ wget https://dl.khadas.com/development/code/docs_source/gsensor.c |
Compile
Use gcc
to compile this program directly on your SBC running Ubuntu.
1 | $ gcc -o gsensor gsensor.c |
Test
Use your hands to rotate the SBC while this program is running, and you can see live changes in Gsensor data.
1 | $ ./gsensor |