Machine Learning in WIO Terminal (Seeed Studio) to recognize shake and roll two die using True Random Number Generator (TRNG)
GitHub: debsahu/WIOCatanDieRoll
Objective
- When WIO is shaken it will roll two die signifying a turn on Settlers of Catan board game
- Die roll needs to be completely random uniform distribution
- Die roll must happen when device is shook vigorously
Hardware
- WIO Terminal (Seeed Studio)
- USB-C cable
Software
- WIOImuTap: Uses in-built IMU to look for double tap to roll 2 die using TRNG
- EdgeImpulse: Upload and train NN using sensor data on Edge Impulse, deployed on WIO with live classification on serial port. Model is included
- AIShakeDie: Uses in-built IMU to recognize shake using NN from Edge Impulse and rolls 2 die using TRNG
Collecting data from WIO & storing on Edge Impulse, training Neural Network on Edge Impulse, Export and deploy TinyML on WIO
1. Collecting data from WIO & storing on Edge Impulse
Installing dependencies (Windows)
- Install Python 3
- Install Node.js v14 or higher - install additional Node.js tools or-else install Microsoft Visual Sudio 2015
- Open powershell as admin, install edge-impulse-cli
npm install -g edge-impulse-cli --force
For other OS please follow instructions from here.
Connecting WIO to Edge Impulse
- Connect WIO to computer using USB-C cable
- Enter bootloader by sliding power switch down twice in quick succession.
- WIO will show up as a new USB drive named
Arduino
, copy latest released precompiled UF2 firmware toArduino
drive - Start sending data to Edge Impulse, open a powershell and type
C:\> edge-impulse-daemon
Follow instructions on screen by logging into your Edge Impulse account and selecting a project.
- Open the Edge Impulse project on a browser and see if WIO is connected
2. Storing Accelerometer data on Edge Impulse
- Start collecting data from device:
- Generate appropiate labels for each data point, click on start sampling. When the countdown starts, perform appropiate action on the WIO based on the label given
- Once a 10s data collection is complete, check the collected data section and click on hamberger icon and split sample
- Split the sample into 1s chunks and click split
- Repeat to have lots of data for each label
- Do the same for Test data (top-left) for each label
3. Create Impulse & Process/Clean up data & training NN
- Create a new impulse (overall design of the project)
- Generate Spectral Features - clean up your raw accelerometer data
- Generate Features
- Train your neural network using cleaned-up training data features from previous step
4. Testing your NN performance
Click on Model Testing > Classify All
5. Deploying your NN on WIO
- Click on Deployment
- Select Arduino library
- Build your Arduino library
Copy contents from src directory into your project
See implementation in EdgeImpulse folder
TinkerGen IDE
Machine Learning on TinkerGen IDE in WIO Terminal (Seeed Studio) to recognize shake and roll two die
Navigate to TinkerGen IDE and create a free account.
Connect WIO terminal using USB-C cable and run CodeCraft Assistant
Navigate to Model Creation and create a new model using accelerometer data.
- Start obtaining accelerometer data from WIO terminal for various labels by clicking on Data Acquisition. Note that the accelerometer data is collected for at least 2s which makes up 128 points (62.5Hz).
Collect lots of data, more data is better. Yes, it takes time. Do not skip or skimp on this step
Train your model using the collected data by clicking on Training and Deployment.
Look for accuracy of the model generated.
- Deploy your model by clicking on Programming