Code to gather data from propshield sensors and save it to SD for later analysis


Well-known member
Hi All . . . I hope to get back in the game after an extended absence due to work and working on the house. I have recently bought an electric skateboard and I am looking to use a Teensy and a prop shield to manage a brake light, some indicators . . . and probably pimp it with some LED lighting while I'm at it. What I am hoping to do is write some code that can gather data from my rides and save it to SD card so that I can then study the data and write further code to control an LED brake light and indicators. The idea with the brake light would be to sense deceleration and switch the brake light on and then switch it off when I accelerate again. The idea with the indicators would be to somehow activate them, probably with push buttons, maybe via bluetooth, and then, after the board had tilted for a period in the direction indicated switch them back off automatically when it returned to level.

Does anyone have any example code for gathering prop shield sensor data and writing it to an SD card?

I have only just started to think about this one and so it will evolve over time but those are the main principles at the moment.

Any ideas?

It sounds like an exciting project! To gather sensor data from the prop shield and save it to an SD card using a Teensy, you'll need to utilize the appropriate libraries and write some code. While I don't have a specific example code tailored to your exact requirements, I can provide you with a general outline of the steps involved and suggest some libraries that might be useful.

Here's a high-level overview of the process:
1. Make sure you have the necessary libraries installed for the Teensy and prop shield. The Adafruit Prop Shield library is a good place to start, as it provides functions to access the onboard sensors.
2. Use the SD library to initialize the SD card and create a file to write the data. You'll need to wire the SD card module to your Teensy and include the appropriate library.
3. Utilize the functions provided by the prop shield library to read data from the sensors. For example, you might use the accelerometer to measure tilt and acceleration.
4. Analyze the sensor data to extract the relevant information you want to save. You can format it as a comma-separated value (CSV) or any other suitable format for easy analysis later.
5. Use the SD library to open the file on the SD card and write the formatted sensor data to it. Make sure to close the file when you're finished writing.
6. Continuously read sensor data, process it, and write it to the SD card at regular intervals during your rides.
I doubt @Experimentalist is still interested in that enquiry as it was poster 4 years ago.