This repository contains the material used in the Arduino demo made on SMR385. This material lets you connect an Arduino® Nano 33 BLE Sense Rev2 to Edge Impulse® using its Data Forwarder tool.
- The boards: Nano 33 BLE Sense Rev2 and Nicla Vision
- Arduino ecosystem installation
- Edge Impulse CLI installation
- Creating datasets with Edge Impulse® (Nano 33 BLE Sense Rev2 board)
- Creating datasets with OpenMV (Nicla Vision)
The Arduino Nano 33 BLE Sense Rev2 is a compact and versatile development board based on the nRF52840 microcontroller from Nordic Semiconductor®. The board was designed for low-power applications and features wireless connectivity via Bluetooth® Low Energy (BLE).
Some key features of the Nano 33 BLE Sense Rev2 board are the following:
- Microcontroller: 32-bit ARM Cortex-M4 processor running at 64 MHz (nRF52840), 1 MB of Flash, and 256 kB of SRAM
- Connectivity: Bluetooth® Low Energy connectivity
- 11 onboard sensors: 9-axis Inertial Measurement Unit (IMU), temperature, humidity, barometric pressure, digital microphone, gesture, proximity, ambient light, and color sensor
There are currently two versions of the Nano 33 BLE Sense board, Rev1, and Rev2. The IMU, temperature sensor, humidity sensor, and microphone of the boards differ, so the libraries used with each of the boards.
The Nicla Vision is a powerful development board with a 2MP color camera in a tiny form factor (just 23x23 mm). With Wi-Fi® and Bluetooth® Low Energy connectivity, the Nicla Vision maximizes compatibility with professional and consumer equipment.
Some key features of the Nicla Vision board are the following:
- Microcontroller: Dual 32-bit Arm® Cortex®-M7 running at 480 MHz and Cortex®-M4 running at 240 MHz microcontroller (STM32H747AII6), 2 MB of Flash, and 1 MB of RAM (same as the Portenta H7!)
- Connectivity: Wi-Fi® and Bluetooth® Low Energy connectivity
- Onboard sensors: 6-axis IMU, digital microphone, and distance sensor
- Onboard camera: 2MP color camera
- Security: Onboard crypto chip
To use the Nano BLE Sense 33 Rev2 board with the Arduino ecosystem tools, you need to install the following:
- IDE: Arduino IDE 2.0+
- Core: Arduino Mbed OS Nano Boards (installation via the Boards Manager of the Arduino IDE)
- Libraries: Arduino_BMI270_BMM150 (installation via the Library Manager of the Arduino IDE)
To use the Nicla Vision board with the Arduino ecosystem tools, you need to install the following:
- IDE: Arduino IDE 2.0+ and OpenMV v3.0+
- Core: Arduino Mbed OS Nicla Boards (installation via the Boards Manager of the Arduino IDE)
Install the Arduino and OpenMV IDE first, and then use the Boards Manager and Library Manager to install the board core and libraries.
Note for the Nicla Vision: Before using your board, ensure its bootloader is updated to the latest release. This can be done by running the STM32H747_manageBootloader
example. The example can be found by navigating into File > Examples > STM32H747_System > STM32H747_manageBootloader.
With OpenMV running, connect your Nicla Vision board to your computer. Select the Connect icon in the bottom left side of the OpenMV IDE; you should see your Nicla Vision onboard green LED start flashing; this indicates that your board is on bootloader mode.
The following connection dialogue will open; select the "Install the latest release firmware" option.
Note: DO NOT ERASE THE INTERNAL FILE SYSTEM of your Nicla Vision board.
Now, navigate to select File > New File and add the following code into the OpenMV code editor window and save it as nicla_vision_test.py
. The following code will start the Nicla Vision camera and display the feed in the OpenMV IDE's frame buffer. You will also use this code to capture frames for the ML model:
import sensor, image, time
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
print(clock.fps())
Select the Start icon (green triangle) in the bottom left of the OpenMV IDE; the camera feed will display in the OpenMV IDE's frame buffer (notice that the dynamic color balance is also shown).
Now your Nicla Vision is all set up and working! Now let's create an image dataset to build a TinyML model. We will train a model that can recognize Nano 33 BLE Sense and Xiao boards, so we must capture many images of our targets and some of the background. So we will end up with three data classes:
nano
xiao
background
We will take about 30 images of each board and the background from different angles and with different lighting (if possible). The more variety, the more accurate the model will be. Please, upload into this shared Google Drive your images.
Create a directory on your computer to store the images taken with your Nicla Vision board. With your board connected to the OpenMV IDE, click the connect button again and start the camera using the start button. Navigate to Tools > Dataset Editor > New Dataset. A new dialogue box will open; choose the dataset directory you created before. Close the dataset_capture_script.py
file that opens in the OpenMV IDE code editor. Close this script, as we already have a capture script setup. Select the New Class Folder button in the middle left side of the OpenMV IDE:
Give the class a name (nano
, xiao
, or background
), and then select the Capture Data button in the middle left side of the OpenMV IDE:
Move the camera to a different view and click the capture again. Keep repeating this with different views until you have about 30 to 50 images of your target object. Once you have enough pictures of your first target, create a new data class and capture images of the next target; also, remember the background!