Twitter icon
Facebook icon
LinkedIn icon
Google icon
Reddit icon
StumbleUpon icon
Del.icio.us icon

Smart Bike Suspension

Added to IoTplaybook or last updated on: 11/08/2022
Smart Bike Suspension

Story

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.

Project diagram; no need to connect to servo for data collecting stage.
Project diagram - no need to connect to servo for data collecting stage

Things used in this project

Hardware components

Arduino Nano 33 BLE Sense
Arduino Nano 33 BLE Sense
 
× 1

Arduino CC

SparkFun LiPo Charger/Booster - 5V/1A
SparkFun LiPo Charger/Booster - 5V/1A
 
× 1

SparkFun

 
SparkFun Lithium ion battery - 1A, 3.7V
 
× 1  
SG90 Micro-servo motor
SG90 Micro-servo motor
 
× 1

Adafruit

 
Smartphone (Android or iPhone)
 
× 1  

Software apps and online services

Edge Impulse Studio
Edge Impulse Studio
 
 

Edge Impulse

 
Arduino Science Journal app
iOS or Android app
   
Arduino IDE
Arduino IDE
 
  Arduino.cc

Hand tools and fabrication machines

 
bolt, nuts, rubber foam, cable ties, o ring rubber, silicon glue

This project consists of 5 steps:

1. Collect data

2. Data acquisition and labelling

3. Train and build model

4. Deploy model and test

5. Modify code, attach, and test

Step 1: Collect Data

Arduino Nano 33 BLE Sense with battery attach to bike's suspension
Arduino Nano 33 BLE Sense with battery attach to bike's suspension

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.

Arduino SJ app on smartphone to collect data from Nano 33 BLE Sense via bluetooth
Arduino SJ app on smartphone to collect data from Nano 33 BLE Sense via bluetooth

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.

Connect and upload Arduino SJ firmware via Arduino IDE
Connect and upload Arduino SJ firmware via Arduino IDE

Arduino IDE menu to download the firmware
1 / 2 - Arduino IDE menu to download the firmware

 


2 / 2

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).

Bike setup to collect data
Bike setup to collect data

Collect data video (eg. in rough condition)

Sample result in smartphone screen
Sample result in smartphone screen

After getting data from the app, you can download the csv file. Then we can proceed to step 2 in Edge Impulse Studio side.

Sample result downloaded (csv file)
Sample result downloaded (csv file)

Step 2: Data acquisition and labelling

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.


1 / 2


2 / 2

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.


1 / 2


2 / 2

Step 3: Train and build model

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).


1 / 2


2 / 2

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)

Step 4: Deploy model and test

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.


1 / 2