There are a few python scripts stored in /prototype-python
.
imu-test.py
simply connects to the IMU and gathers and prints acceleration and gyro data to the console.imu-visual.py
connects to the IMU, reads data, and plots it on a graph to visually represent the data and the physical motion of the IMU.
To get the above scripts up and running, follow these steps.
Materials:
- Raspberry Pi (We are using a Raspberry Pi 3b+, but most should work).
- BMI160 IMU, you can find these on Amazon as well.
- Some female-to-female jumper wires.
Dependencies:
python3 -m pip install BMI160-i2c
python3 -m pip install smbus2
Steps
- Run
git clone https://github.com/mattallenn/gnc.git
in your directory of choice. - Wire up the components. Connect the 3.3V, GND, SCL, SDA, and SAO (to ground) from the IMU to the corresponding IO pins on the raspberry pi.
- Run
i2cdetect -y 1
. This should show a connection on0x68
or0x69
. You'll have to change the variable at the top of the.py
files to make sure this is correct. - Run either
python3 imu-test.py
orpython3 imu-visual.py
- Congratulation! Go drink because you now have some useful(?) data from a cheap, inaccurate Amazon clone IMU that probably won't work tomorrow.
A lot of this was adapted / taken from this python package.
hi there