Seeed Studio XIAO nRF52840 Sense Edge Impulse Getting Started

Welcome to this quickstart wiki on using Edge Impulse with Seeed Studio XIAO nRF52840 Sense! In this guide, we will explore how to use the onboard IMU sensor to detect human motion and classify different actions. Whether you're a seasoned developer or just starting out, this tutorial will provide you with the knowledge and skills you need to get started with Edge Impulse on the XIAO nRF52840 Sense board. So, let's dive in and get started!
Getting Started​
In this wiki, we will show you how to utilize the accelerometer on Seeed Studio XIAO nRF52840 Sense combined with Edge Impulse to enable motion recognition. The codes we present here are supported by latest version of Seeed nRF52 Boards.
When it comes to embedded AI applications, we highly recommend using the "Seeed nrf52 mbed-enabled Boards Library".
Hardware​
In this wiki, we need to prepare the following materials:
- Seeed Studio XIAO nRF52840 Sense
- Li-po battery (702025)
- Grove - OLED Display 0.66"
- Dupont cables or Grove cables
- 3D-printed shell
- Light guide plastic fiber
Hardware Set up
Step 1. Remove the Grove base on Grove - OLED Display 0.66" with a soldering iron
Step 2. Use wire cutters to process the DuPont cables to a length of about 3 cm and expose the inner cables of about 2 mm at both ends
Step 3. Pass the fiber through the small hole in the front and place the end at the LED
Step 4. Solder Seeed Studio XIAO nRF52840 Sense with other elements according to the diagram below:
It will be better if you use hot melt adhesive to reinforce welds.
Step 5. Assemble all components:
- Pass the fiber through the small hole in the front of shell
- Mount the screen to the fixed location
- Sandwich the battery between Seeed Studio XIAO nRF52840 and screen
- Handle the wires carefully
- Place the end of light guide plastic fiber at the RGB light of Seeed Studio XIAO nRF52840 and cut off the excess
- Assemble the case
The assemble one:
Software​
The required libraries are listed below. It is highly recommanded that use the codes here to check whether the hardware is functioning well. If you have problem about installing the library, please refer to here.
To set Seeed Studio XIAO nRF52840 Sense up in Edge Impulse, you will need to install the following software:
- Node.js v12 or higher.
- Arduino CLI
- The Edge Impulse CLI and a serial monitor. Install by opening command prompt or terminal and run:
npm install -g edge-impulse-cli
Problems with installing the CLI? Please check Installation and troubleshooting for more reference.
Connecting to Edge Impulse​
With all the software in place it's time to connect the development board to Edge Impulse.
- Step 1. Connect the Seeed Studio XIAO nRF52840 Sense to your computer via a USB Type-C cable.
- Step 2. Create a new project in Edge Impulse
- Step 3. Choose "Accelerometer data" and click "Let’s get started!"
- Step 4. Connect the XIAO nRF52840 Sense to Edge Inpulse
Move to Edge Impulse "Data acquisition" page, the outcome should be like this if the connection is successful. You can find the Device of "Seeed Studio XIAO nRF52840 Sense" is shown on the right of the page.
Training data acquisition​
- Step 5. Run the command in your
terminal
orcmd
orpowershell
to start it.
edge-impulse-data-forwarder
- Step 6. We need to use the CLI to connect the Seeed Studio XIAO nRF52840 Sense with Edge Impulse. First, login your account and choose your project
Name the accelerometer and the device.
- Step 7. Select the sensor as "3 axes". Name your label as
up
anddown
, modify Sample length (ms.) to 20000 and click start sampling.
- Step 8. Swing the Seeed Studio XIAO nRF52840 Sense up and down and keep the motion for 20 seconds. You can find the acquistion is shown up like this:
- Step 9. Split the data by clicking the raw data right top and choose "Split Sample". Click +Add Segment and then click the graph. Repeat it more than 20 time to add segments. Click Split and you will see the the sample data each for 1 second.
- Step 10. Repeat Step 8. and Step 9. and label data with different name to click different motion data, like
left
andright
,clockwise
,anticlockwise
and so on. The example provided is classifying up and down, left and right, and circle. You can change it as you may want to change here.
In Step 9. the split time is 1 second which means you at least do one swing of up and down in one second in Step 8. Otherwise, the results will not be accurate. Meanwhile, you can adjust the split time according to your own motion speed.
Building a machine learning model​
- Step 11. Rebalance the dataset, Click Dashboard and drop down page to find Perform train / test split
Click Perform train / test split and choose Yes and confirm it
- Step 12. Create Impulse
Click Create impulse -> Add a processing block -> Choose Spectral Analysis -> Add a learning block -> Choose Classification (Keras) -> Save Impulse
- Step 13. Spectral features
Click and Set up
Click Spectral features -> Drop down page to click Save parameters -> Click Generate features
The output page should be like:
- Step 14. Training your model
Click NN Classifier -> Click Start training -> Choose Unoptimized (float32)
The precision of the training model is very important to the final result. If your output training results are as low as less than 65%, we highly recommand you train for more times.
Deploying to Seeed Studio XIAO nRF52840 Sense​
- Step 15. Model testing
Click Model testing -> Click Classify all
If your accuracy is low, you can check you dataset by increasing the training set and extending the sample time
- Step 16. Build Arduino library
Click Deployment -> Click Arduino Library -> Click Build -> Download the .ZIP file
- Step 17. The name of .ZIP file is very important, it is set up as your name of the Edge Impulse project by default. Like here the project of the name is "XIAO-BLE-gestures_inferencing". Select the file as ""Add the ".ZIP file" to your Arduino libraries
- Step 18. Download the code here. Change the name of your headfile as the name of your own and upload it.
- Step 19. Move or hold the Seeed Studio XIAO nRF52840 Sense and check the results:
Click the monitor on the top right corner of Arduino.
When you move the Seeed Studio XIAO nRF52840 Sense in the left and right direction:
The monitor will output something like:
And the output display is like:
When you move the Seeed Studio XIAO nRF52840 Sense in the up and down direction:
The monitor will output something like:
And the output display is like:
When you hold the Seeed Studio XIAO nRF52840 Sense in the idle state:
The monitor will output something like:
And the output display is like:
Congratulation! You acheve the end of the project. It is encouraged that you can try more directions and check which one will perform the best output.
Resources​
Tech Support & Product Discussion​
.
Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.