How To Get Started with WisBlock and Edge Impulse

KHM-030-00.jpg

WisBlock is a modular system that makes it easy to implement edge IoT solutions. It is your ally from rapid prototyping to mass production without the need to create new hardware modules for each step.

WisBlock ecosystem lets you decide on several core options as the RAK11200 (ESP32), RAK4631 (nRF52840), and the RAK11310 (RP2040), to develop your TinyML project alongside the largest variety of sensors in the market, from PDM microphones for audio recognition to motion sensors for movement models and many more.

A starter kit is available in the RAK store.

Setting Up Your Development Board

KHM-030-01.png

The minimum hardware you will need to start developing with WisBlock and Edge Impulse are as follows:

KHM-030-02.png

Installing Dependencies

To set WisBlock up in Edge Impulse, you will need to install the following software:

Uploading Data to Edge Impulse

Once you have the software already installed, it’s time to start creating your dataset.

Select the core you are using:

Deploying the Trained Model Locally

Once your dataset is created and your model is trained, it’s time to deploy it back to your WisBlock.

Select the core you are using:


RAK11200 Edge Impulse Guide

RAK11200 Data Uploading

Download the Edge Impulse firmware .zip file.

Download the ESP Flash Download Tool.

Open the Flash Download Tool and set chipType to "ESP32" and left workMode on "develop", then click OK.

Connect the WisBlock Base, where RAK11200 is attached to the computer via USB.

Short the BOOT0 and GND pins, then reset the board to restart the core in boot mode.

KHM-030-03.jpg

Search for the firmware files and set them on the right memory partition.

Search for the ei_rak11200_firmware.bin and set it on @ 0x10000 partition

Search for the bootloader.bin and set it on @ 0x1000 partition

Search for the partition-table.bin and set it on @ 0x8000 partition

Set the SPI SPEED to 40 MHz, SPI MODE to DIO, and DoNotChgBin checked. Everything should look like this:

KHM-030-04.png

Click the START button and wait until you see a FINISH status on the Download panel.

KHM-030-05.png

Finally, reset the board.

📝 NOTE: You can also build the firmware using the RAK11200 Edge Impulse source code.

Connecting to Edge Impulse

Connect your WisBlock board to your PC through the USB cable. In the command prompt or terminal, run the following code:

edge-impulse-daemon

This will start a wizard which will ask you to log in and choose an Edge Impulse project. If you want to switch projects, run the command:

--clean

Verifying Connection

After running the command, your WisBlock is now connected to Edge Impulse. To verify this, go to your Edge Impulse Project, and click Devices. The device should be listed here.

KHM-030-06.png

Building a Machine Learning Model

Now that you have successfully set up the connection, you can now build your first machine learning model. For this, you need to connect supported WisBlock sensors to your board. In this case, a PDM microphone or a 3-axis accelerometer.

KHM-030-07.png

KHM-030-08.png

Collecting your first data:

KHM-030-09.png

KHM-030-010.png

Define the label and the sample length of your data, and click Start sampling. After the time you have set, you will see the uploaded sample.

KHM-030-011.png

KHM-030-012.png

Now, you are ready to create your dataset for your custom project. Also, you can follow these tutorials for specific use cases.

📝 NOTE: The Data forwarder lets you easily send data from any sensor into Edge Impulse. For more WisBlock Sensors options, refer to RAK store.

WisBlock team is working on supporting new sensors with Edge Impulse everyday.

RAK11200 Trained Model Deployment

RAK11200 ESP32 core lets you deploy your model using the native ESP IDF or PlatformIO. You can select your preferred option.

Deploying Your Model Back to WisBlock

ESD IDF

After training and validating your model, you can now deploy it to your WisBlock board. This makes the model run without an internet connection, minimizes latency, and runs with minimal power consumption.

On your Edge Impulse project, navigate to the Deployment tab on the left menu and select the C++ library option.

KHM-030-013.png

Edge Impulse offers an optimization tool that can help you increase on-device performance but may reduce accuracy. You can test each option one by one and stay with the best results. You can also click the Analyze optimizations button before deploying it and see the recommended choice for your target. Or, click Build to use the currently selected option.

KHM-030-014.png

KHM-030-015.png

KHM-030-016.png

Download the .zip library and save it to your preferred location, then unzip it.

KHM-030-017.png

Now, you need to build the firmware for your corresponding core with the trained model added to it.

Download and install ESP IDF v4.4.

  • Download or clone the firmware from the Github repository.
  • You'll need two additional components to compile the firmware:
    • LIS3DHTR_ESP-IDF
    • ESP-NN
  • Then open the ESP-IDF 4.4 CMD from the Desktop shortcut.
  • Navigate to the firmware folder ../RAK11200-Edge-Impulse-Firmware.

KHM-030-018.png

Get the additional components by cloning the corresponding repositories to the components folder in the root folder of the project: ../RAK11200-Edge-Impulse-Firmware/components.

cd components
git clone <https://github.com/AIWintermuteAI/LIS3DHTR_ESP-IDF.git> LIS3DHTR_ESP-IDF/
cd LIS3DHTR_ESP-IDF 
git checkout 641bda8c3e4b706a2365fe87dd4d925f96ea3f8c 
cd ..
git clone <https://github.com/espressif/esp-nn.git> esp-nn/
cd esp-nn 
git checkout 24d18025f300c1e15afa2abb86519da54c7a5d90 
cd ..
cd ..

With the last cd .., you must be in the project folder ../RAK11200-Edge-Impulse-Firmware.

Add Your Trained Model Library

Replace the edge-impulse-sdk, model-parameters, and tflite-model folders from the project with the new ones in the trained model library.

KHM-030-019.png

KHM-030-020.jpg

Build the Application

  • Delete the build folder from the project. (Important)
  • Run the following command:
idf.py build

Flash

  • Connect the RAK11200 ESP32 WisBlock board to your computer.
  • Short BOOT0 and GND then press the Reset button of the base board. (To restart the core in boot mode)
  • Identify the COM port where it's connected.
  • Run the following command:
idf.py -p COMxx flash monitor

Where COMxx needs to be changed to the actual port where your WisBlock is connected on your system.

  • After uploading successfully, reset the board.
📝 NOTE: Also, you can build and flash the firmware using the Visual Studio Code Esspressif plugin.

Run the Model

From a command prompt or terminal, run:

edge-impulse-run-impulse

If your model uses audio, you may use the --continuous command as follows:

edge-impulse-run-impulse --continuous

Your model should run and print the inference results in the terminal continuously.

KHM-030-021.png

PlatformIO

After training and validating your model, you can now deploy it to your WisBlock board. This makes the model run without an internet connection, minimizes latency, and runs with minimal power consumption.

📝 NOTE: In installing and setting up the PlatformIO to work with WisBlock ecosystem boards, refer to the Learn section.

On your Edge Impulse project, navigate to the Deployment tab on the left menu and select the Arduino library option.

KHM-030-022.png

Edge Impulse offers an optimization tool that can help you increase on-device performance but may reduce accuracy. You can test each option one by one and stay with the best results. You can also Analyze optimizations before deploying it and see the recommended choice for your target. Or, click Build to use the currently selected option.

KHM-030-023.png

KHM-030-024.png

KHM-030-025.png

Download the .zip library, save it to your preferred location, and then unzip it.

Finally, to deploy your model:

  1. Clone or download the WisBlock examples for PlatformIO from the repository.
  2. Open the example that better fits your needs on Visual Studio Code.

If you are working with:

  • Keyword spotting or sound recognition → “inference_microphone_continuous” is recommended.
  • Accelerometer or any other sensor → “inference_accelerometer” is recommended.

Drag and drop the Arduino library to the lib folder of your project:

KHM-030-026.jpg

Finally, Build your project, connect your WisBlock board to your computer and Upload the code.

KHM-030-027.png

KHM-030-028.png

Run the Serial Monitor, and you should start seeing the inference results:

KHM-030-029.png


RAK11310 Edge Impulse Guide

RAK11310 Data Uploading

Download the Edge Impulse firmware .uf2 file.

Connect the WisBlock Base where RAK11310 is attached to the computer via USB.

Hold the BootSel button in the RAK11300 module, reset the module (press the reset button of WisBlock Base Board for at least 2 seconds), then wait for the USB Mass Storage RPI-RP2 to appear before releasing the BootSel button.

KHM-030-030.png

Drag and drop the .uf2 file to the RPI-RP2 USB Mass Storage.

KHM-030-031.png

📝 NOTE: You can also build the firmware using the RAK11310 Edge Impulse source code.

Connecting to Edge Impulse

Connect your WisBlock board to your PC through the USB cable. From a command prompt or terminal, run the following command:

edge-impulse-daemon

This will start a wizard which will ask you to log in and choose an Edge Impulse project. If you want to switch projects, run the command:

--clean

Verifying Connection

After running the command, your WisBlock is now connected to Edge Impulse. To verify this, go to your Edge Impulse Project, and click Devices. The device should be listed here.

KHM-030-032.png

Building a Machine Learning Model

Now that you have successfully set up the connection, you can now build your first machine learning model. For this, you need to connect supported WisBlock sensors to your board. In this case, a PDM microphone or a 3-axis accelerometer.

KHM-030-033.png

KHM-030-034.png

Collecting your first data:

KHM-030-035.png

KHM-030-036.png

Define the label and the sample length of your data, and click Start sampling. After the time you have set, you will see the uploaded sample.

KHM-030-037.png

KHM-030-038.png

Now, you are ready to create your dataset for your custom project. Also, you can follow these tutorials for specific use cases.

📝 NOTE: The Data forwarder lets you easily send data from any sensor into Edge Impulse. For more WisBlock Sensors options, refer to RAK store.

WisBlock team is working on supporting new sensors with Edge Impulse everyday.

RAK11310 Trained Model Deployment

Deploying Your Model Back to WisBlock

After training and validating your model, you can now deploy it to your WisBlock board. This makes the model run without an internet connection, minimizes latency, and runs with minimal power consumption.

On your Edge Impulse project, navigate to the Deployment tab on the left menu and select the C++ library option.

KHM-030-039.png

Edge Impulse offers an optimization tool that can help you increase on-device performance but may reduce accuracy. You can test each option one by one and stay with the best results. You can also Analyze optimizations before deploying it and see the recommended choice for your target. Or, click Build to use the currently selected option.

KHM-030-040.png

KHM-030-041.png

KHM-030-042.png

Download the .zip library and save it to your preferred location, then unzip it.

KHM-030-043.png

Now, you need to build the firmware for your corresponding core with the trained model added to it.

📝 NOTE: Tested with the GNU Arm Embedded Toolchain version 10.3.1.

Add Your Trained Model Library

Replace the edge-impulse-sdk, model-parameters, and tflite-model folders from the project with the new ones in the trained model library.

KHM-030-044.png

KHM-030-045.jpg

Build the Application

  • Delete the build folder from the project. (Important)
  • Run the following command:
mkdir build
cd build
cmake -G "MinGW Makefiles" ..
make

Flash the Firmware

Connect the RAK11310 RP2040 WisBlock board to your computer.

Hold the BootSel button in the RAK11300 module, reset the module (press the reset button of WisBlock Base Board for at least 2 seconds), then wait for the USB Mass Storage RPI-RP2 to appear before releasing the BootSel button.

Run the following command:

cp ei_rak11310_firmware.uf2 /g/

After uploading successfully, reset the board.

📝 NOTE: Also, you can build and flash the firmware using the Visual Studio Code CMake tools.

Run the Model

From the command prompt or terminal, run:

edge-impulse-run-impulse

If your model uses audio, you may use the --continuous command as follows:

edge-impulse-run-impulse --continuous

Your model should run and print the inference results in the terminal continuously.

KHM-030-046.png


RAK4631 Edge Impulse Guide

The RAK4631 does not have firmware like the other cores to upload data with the official Edge Impulse ingestion service, but the solution for this is covered in this guide.

RAK4631 Data Uploading

Audio Data

To upload audio directly to Edge Impulse, you can use your smartphone or personal computer. This way, you can create your dataset even easier. On your Edge Impulse project, go to Devices and click Connect a new device:

KHM-030-047.png

Select the device you want to use, mobile phone or computer:

KHM-030-048.png

Once you select your device, the Audio data collection web interface will appear, then grant access to your microphone:

KHM-030-049.png

Then, give a name to your sample, and define its length and category, then start recording:

KHM-030-050.png

You should see a success message pops up, and your recording should be visible in the Data acquisition tab of your project:

KHM-030-051.png

You can easily record high-quality and long-lasting audio recordings using this method. Enjoy creating your dataset.

Other Sensor Data

If your project uses a custom or any other sensor from our ecosystem, use the data forwarder to upload your data through serial communication.

If, for example, you are working with a 3-axis accelerometer with a simple code, make your WisBlock print the axis data separated by commas at a certain frequency.

Serial.print(x);
Serial.print(",");
Serial.print(y);
Serial.print(",");
Serial.println(z);

The output should look like this:

-0.12,-6.20,7.90
-0.13,-6.19,7.91
-0.14,-6.20,7.92
-0.13,-6.20,7.90
-0.14,-6.20,7.91

Once your board is printing the data through serial, open a command prompt or terminal and run the data forwarder by typing:

edge-impulse-data-forwarder

If this is the first time running this command, you will be asked to enter your Edge Impulse account credentials. Select the project you want to send your data to and name the axis. The baud rate should be 115200, but if you want to use a different one, you need to change it like this:

edge-impulse-data-forwarder --baud-rate 460800

For examples and more options, refer to this guide: Data Forwarder.

RAK4631 Trained Model Deployment

After training and validating your model, you can now deploy it to your WisBlock board. This makes the model run without an internet connection, minimizes latency, and runs with minimal power consumption.

On your Edge Impulse project, navigate to the Deployment tab on the left menu and select the Arduino library option.

KHM-030-052.png

Edge Impulse offers an optimization tool that can help you increase on-device performance but may reduce accuracy. You can test each option one by one and stay with the best results. You can also Analyze optimizations before deploying it and see the recommended choice for your target. Or, click Build to use the currently selected option.

KHM-030-053.png

KHM-030-054.png

KHM-030-055.png

Download the .zip library, save it to your preferred location, and then unzip it.

📝 NOTE: In installing and setting up the PlatformIO to work with WisBlock ecosystem boards, refer to the Learn section.

Finally, to deploy your model, execute the following steps:

  1. Clone or download the WisBlock examples for PlatformIO from the repository.
  2. Open the example that better fits your needs on Visual Studio Code.

If you are working with:

  • Keyword spotting or sound recognition → “inference_microphone_continuous” is recommended.
  • Accelerometer or any other sensor → “inference_accelerometer” is recommended.

KHM-030-056.jpg

Finally, Build your project, connect your WisBlock board to your computer and Upload the code.

KHM-030-057.png

KHM-030-058.png

Run the serial monitor, and you should start seeing the inference results:

KHM-030-059.png

📝 NOTE: RAK4631 works only with PlatformIO.

 

Updated