Software apps and online services
Hand tools and fabrication machines
In this project we use data from the motion sensor on the Arduino Nano 33 BLE Sense which is mounted on a bike’s suspension and used under different road conditions. The data was cut into 5 seconds and labeled according to the surface variation and activities. Then processed in Edge Impulse Studio through Neural Network blocks: Spectral Analysis (x, y, z acc) and Classification (Keras) which will produce an ML model that can detect 5 road surface characters and rider activity output (idle, medium, rough, smooth, sprint). The model is deployed into the program on the Nano 33 BLE Sense which has an angle servo motor installed that can adjust the bike’s suspension knob. In the end, this project succeeded in implementing a "smart" system on the bike's suspension which can automatically adjust the level of travel on the suspension (lock, medium, open) according to the character of the road and the activities. Comfort, efficient use of energy have been achieved, and the effect of excessive bobbing can be eliminated with the help of embedded ML from Edge Impulse. This project also has the potential to maximise its use in sport cycling activities such as MTB (cross country, trail, downhill) so the riders focus more on handling and pedalling.
This data collecting is a very important stage and requires preparation, we have to make a mounting case for the Nano 33 BLE Sense and the battery on the bike suspension tube. For easy data recording, we use a smartphone with the Arduino Science Journal (Arduino SJ) app. We also use a smartphone bike mounting so the graphs result can be seen immediately when data recording occurs.
The first thing to do on Nano BLE Sense is to upload Arduino Science Journal firmware via Arduino IDE. Find and install the libraries by using the Library Manager (Tools > Manage Libraries…) the type arduino science journal, select latest version and download. After that, go to File > Examples > INCOMPATIBLE > Arduino_ScienceJournal > Nano33BLESenseFirmware. Then click the Upload button. Now Nano BLE sense is ready to be attached on bike suspension.
After everything is installed in place, power on and connect the Nano BLE Sense to the Science Journal app via bluetooth. Click on Add button then choose sensor input, add accelerometer X, Y, and Z. So now it is ready to take data samples, start ride, then start record - stop, and name each recorded condition (rough/gravel, medium/pavement, smooth/asphalt). In addition, I added an idle state, and also a sprint (power pedal and lean bike to left and right).
After getting data from the app, you can download the csv file. Then we can proceed to step 2 in Edge Impulse Studio side.
Open studio.edgeimpulse.com (sign-in/up). Create new project, then choose accelerometer data.
In dashboard > Project Info, choose one label per data and Arduino Nano 33 BLE Sense for latency.
Then in Data acquisition, click on Upload Data tab, choose your CSV files, auto split, then click Begin upload.
Now, it’s time for labelling. Click on data sample collected, click on … (three dots) then choose split sample. Set segment length 5000 ms (5 sec), or add segment manually then click Split. Repeat.. until all samples labelled in 5 sec interval. Make sure that the ratio between Training and Test data is ideal, around 80/20.
Once you have dataset ready, go to Create Impulse and set around 4500ms in Window size (for 5 sec data sample), and 80ms on Window increase. Then add Spectral Analysis processing block, and Classification (Keras) as learning block, then Save Impulse.
Go to Parameter section, and press Save parameters.
Click on Generate features button, you should get a result just like the one below.
Then, navigate to NN Classifier section, and leave training setting for Neural Network as it is. Train the model by press the Start training.. and you can see the progress. If everything is OK, you should see something like this (91% accuracy is quite good).
After that we can test the model, go to Model testing section and click classify all. If the accuracy result is more than 80%, then we can move on to the next step — deployment. (If accuracy result is not as good as expected, re-start with quality datas, label, or just retrain the model with Training cycle and Learning rate setting changes)
Now, we can start to deploy the model to Arduino Nano 33 BLE Sense. Click on deploy your impulse, choose Arduino Library, then click Build. The.ZIP library will be downloaded then open your Arduino IDE to add this library. After that you can find examples in menu File > Examples > Smart_Bike_Suspension_inferencing > nano_ble33_sense > nano_ble33_sense_accelerometer, upload it to your Nano 33 BLE Sense, open Serial monitor then try to simulate motion on your Nano 33 BLE Sense.
If your motion simulation detected by BLE Sense correctly, then we can move on final step, attach to servo and apply it on the bike suspension to test it on the real conditions.Step 5: Modify code, attach and test
We need to modify the example file above which is embedded with the trained model in order to convert the output to the desired servo rotation. So if the detected condition is idle or smooth, the servo will turn the suspension knob to lock position. If the road conditions are pavement or when sprinting, the servo turns the knob to half open (medium). And if a very rough condition is detected, the servo will fully open the knob in order to maximise the suspension travel. The following is a modified Arduino code that can be uploaded to the Nano 33 BLE Sense.
Check Arduino code in Code attachment below!
For installing servo components on bike suspension, we need to design servo mounting brackets with gears which are connected to the upper suspension knob (needs to mod the design for different suspension types and brands).
Check 3D part files in Custom parts & Enclosures below!
We have tested it in the real conditions and make it happen the idea of “smart” bike suspension. This project also has the potential to maximise its use in sport cycling activities such as MTB (cross country, trail, downhill) with complex conditions such as climbing, jumping, dropping, cornering, and data can be retrieved by involving professional athletes so the output setting of the suspension is better. scalable, and “smarter”.