In this post we show how to create a Digital Spirit Level using a Raspberry Pi and python.
The code moves that bubbles on the display in relation to the angle read from the IMU.
Parts used in this project;
Any IMU or TFT can be used, however the code would need to be updated to accommodate the different devices. It is best to use a 480x320 TFT as the images are scaled to fit this resolution.
This guide assumes that some basic understanding of an IMU(Accelerometer and Gyroscope) is already known. And you have one already working with your Raspberry Pi.
If you don't, we do have some guides which covers this.
We have used our existing python code to read the values from the IMU, however we have removed the code related to the magnetometer as it isn't needed for this project.
Git repository here
The code can be pulled down to your Raspberry Pi with;
Placement of IMU
The IMU can be attached anywhere, however it is best to place it in the same orientation as shown below. If you do change the orientation, you will need to update the code accordingly.