Raspberry Pi Zero Helmet Impact Force Monitor
The Python code for this project is open-source! Here's a link to the GitHub repository.
For Folks New to Programming:
- Read through the program code and comments. Things that are easy to modify are in the "
User Parameters" section at the top.
For Folks More Comfortable w/ the Technical 'Deets:
- This program initializes the LIS331 accelerometer with default settings, including normal power mode and 50Hz data rate. Read through the LIS331 datasheet and modify initialization settings as desired.
The maximum acceleration scale used in this project is 24G, because impact force gets big real quick!
It is recommended to comment out the acceleration print statements in the main function when you are ready for full deployment.
Before you run the program, double check that the accelerometer address is 0x19. Open the terminal window and install some helpful tools with this command:
sudo apt-get install -y i2c-tools
Then run the i2cdetect program:
i2cdetect -y 1
You'll see a table of I2C addresses displayed as shown in the image below. Assuming this is the only I2C device connected, the number you see (in this case: 19) is the accelerometer address! If you see a different number, take note and change in the program (variable
The program reads the x, y, and z acceleration, calculates a g-force, and then saves the data in two files (in the same folder as the program code) as appropriate:
- AllSensorData.txt -- gives a timestamp followed by the g-force in the x, y, and z axes.
- AlertData.txt -- same as above but only for readings that are above our safety thresholds (absolute threshold of 9G or 4G for more than 3 seconds).
G-forces above our safety thresholds will also turn on our alert LED and keep it on until we restart the program. Stop the program by typing "CTRL+c" (keyboard interrupt) in the command terminal.
Here's a photo of both data files created during testing: