Home > Projects > Other Projects > ARDUINO NANO BLE SENSE – TinyML FITNESS BAND USING EDGE IMPULSE

ARDUINO NANO BLE SENSE – TinyML FITNESS BAND USING EDGE IMPULSE

Summary of ARDUINO NANO BLE SENSE – TinyML FITNESS BAND USING EDGE IMPULSE


This project creates a wearable TinyML fitness band using the Arduino Nano BLE Sense to classify physical motions like squats and jumping jacks. By leveraging Edge Impulse for model training and a custom Python script via Bluetooth Low Energy (BLE) for data collection, the device operates wirelessly without wired constraints. The system captures accelerometer data, processes it through a neural network classifier, and transmits real-time exercise recognition results to a smartphone app.

Parts used in the TinyML Fitness Band:

  • Arduino Nano Ble Sense
  • USB boost converter or Power Bank
  • Battery
  • Arm Band
  • Python script with Bluepy library
  • nRF Connect App

It is a disruptive fitness solution where we classified different physical motions and body positions using arduino nano ble sense.

Description

TinyML fitness band using “EDGE IMPULSE” is a disruptive fitness solution where I classified different physical motions and body positions using arduino nano ble sense. 

With the support of Edge Impulse, I collected data and trained ML models. In order to have accuracy and to perform different physical movements which might not be possible if wired. I wrote a small python script to collect data from BLE and send it to Edge Impulse Studio for data collection, which turned out successful! Check the video for the test of data collection example. ( I am wearing the device on my left arm). https://www.youtube.com/watch?v=UDsLDOZwtNk

Step 1: HARDWARE REQUIRED:

  • Arduino Nano Ble Sense or any TinyML compatible controller
  • USB boost convertor or Power Bank
  • Battery
  • Arm Band
Arduino Nano Ble Sense
USB boost converter 
Battery
Power Bank

Just Simply power your Arduino nano from your powerbank/ USB boost converter and you are ready to go.

NOTE- As Arduino BLE Sense operates at very low power, so some power banks do not work properly with the device. They would get automatic shut down after a while which would interrupt the process of collecting the data or testing the device. In that case, it is better suggested to use a boost converter and a 3.7v battery.

The device can be easily worn at your wrist or at your arm as I have done in the video demonstration.

STEP 2 : INSTALLING THE REQUIREMENTS :

Arduino IDE Software
Arduino Mbed Os Nano Boards

Arduino IDE is a fantastic minimalistic solution to microcontrollers with the potential of a computer environment for most Arduino-based projects.

We shall begin with the installation of IDE! you have to be sure in downloading the correct version of IDE for your operating systems, however, it is available for the most common OS including Windows, Linux, Mac OS X.

There you go with the link! – [ https://www.arduino.cc/en/software ]
As the installer is downloaded, you may install the IDE, enabling options such as libraries!

It is essential to install the required core for your specified microcontroller. For that, we move to board manager which is a great tool for its installation [FIG -2]. Here we’ll go with the quick steps:
On the left column do click on the “board manager”. Among the list of available options, search for Mbed OS core for Arduino nano 33 BLE sense. This may take a while. It will show “installed” at the board manager column when done as shown below.

After installing the boards, upload the code to get Accelerometer data over BLE.

Step 3: GETTING STARTED WITH EDGE IMPULSE STUDIO:

“Edge Impulse enables developers to create the next generation of intelligent device solutions with embedded Machine Learning.”

Edge Impulse Studio is a great platform to get started with Tiny Machine Learning.

If you have an existing Edge Impulse studio account, log into that. If you are new, create a new account by using this link [ https://studio.edgeimpulse.com/login ] then create your project by clicking “Create New Project”.

From the above menu, go to the project key section and copy the “API key” and “HMAC key” of your project.

Step 4: COLLECTING THE DATA (USING BLE):

On the Edge Impulse Studio documentation, [ https://docs.edgeimpulse.com/docs/arduino-nano-33-ble-sense] we can see that Arduino nano BLE sense is completely compatible with the Edge Impulse Studio and data can be collected using EDGE IMPULSE CLI or WEB USB interface. But for collecting data of “HUMAN MOTION”, it becomes a little harder to collect data via USB cable.

So for collecting data over BLE we have a custom python script, which depends on the “bluepy python library” for getting data over BLE and then forwards it directly to EDGE IMPULSE STUDIO.

To collect data via BLE we have two files, one for collecting test data and other for collecting training data, just open the code and add your “API KEY” and “HMAC KEY”. And you are ready to collect the data.

To run the python file simply use a terminal and use command

python3 train_collect.py [MAC Address of device] ” Data name” [time period of recording]

For reference check the image.

NOTE – Bluepy python library works only for LINUX so this code cannot be used on windows, I have received suggestions to use BLEAK python library which is much faster and supports Windows. So I will soon test it using BLEAK and change the code which would run on both LINUX and WINDOWS.

Step 5: DATA VERIFICATION:

Initially, I collected data for Squats, Jumping Jacks, and Rest positions, for testing my model, Which is pretty accurate.
Now I will be adding a few more exercises in the model which are Pushups, Skipping, pullups and more to check how much accuracy I could get deploying this on a tiny device.

Here the data in the images refer to the Rest, Squat, and Jumping Jack position.

Step 6: TRAINING THE MODEL:

For training the model, Edge Impulse provides easy to use UI. Just follow some steps and you are ready to go.

for visual instructions, refers to the images.

Step 1 – Go to Impulse Design and create impulse, you could choose from many options, but Edge Impulse provides you the best choices according to your data.

Step 2 – Choose Spectral Features(here you can change the training parameters if you do not get good results on default) and generate features for the model.

Step 3 – Go to Neural Network classifier (change the training parameters if needed) and Train your model.

Step4- Go to model testing and test your training data with respect to test data and check the accuracy of your model.

Step5 – Deploy the model. (Edge impulse supports many platforms, so you could directly download the code, compatible with your platform. In our case we would choose Arduino).

Step 7: TESTING ON THE DEVICE:

Simply Import the library, downloaded from Edge Impulse Studio, and in the Arduino examples, you would get some test examples to deploy on your device and test your model.

These examples can only be tested via USB serial. If you want to test your examples then modify the code attached. Or just download the attached library and upload the given code to your Arduino.

Library Download Link – https://drive.google.com/file/d/1mOxGAAqvDcCXva60EFks_9bs4sK0h5a0/view?usp=sharing

Step 8: TESTING WITH BLE:

To test your device with BLE, download the code attached in the above section. And download nRF Connect App for your device. In the nRF connect app connect to your device

In the client section just press on the UUID of your service (128-bit id, refer to the images, and press the download button). Then your phone will start displaying the exercise that you are currently doing.

I have attached images of REST, SQUATS, and JUMPING JACK.

There are wide applications of tinyML that can be implemented and edge impulse makes it easier to get started with it. So try your own application!

Source: ARDUINO NANO BLE SENSE – TinyML FITNESS BAND USING EDGE IMPULSE

Quick Solutions to Questions related to TinyML Fitness Band:

  • How is data collected from the device?
    Data is collected over Bluetooth Low Energy using a custom Python script that forwards information directly to Edge Impulse Studio.
  • Can this project run on Windows operating systems?
    The current Python script uses the Bluepy library which only works on Linux, though the author plans to test the Bleak library for Windows support.
  • What hardware powers the Arduino Nano BLE Sense?
    The device can be powered by a USB boost converter or a power bank, but some power banks may shut down automatically due to low power draw.
  • Which software is required to install the microcontroller core?
    Users must install the Arduino IDE and the Arduino Mbed Os Nano Boards core via the board manager.
  • What machine learning features are selected for the model?
    The project utilizes Spectral Features within the Edge Impulse UI to generate inputs for the Neural Network classifier.
  • How does the user view the detected exercises?
    The nRF Connect app connects to the device's service UUID to display the current exercise being performed in real time.
  • What physical motions were initially tested?
    The model was initially trained and tested on Squats, Jumping Jacks, and Rest positions.
  • Where can the deployment library be downloaded?
    The library compatible with Arduino is available via a Google Drive link provided in the article steps.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top