Case 1: Using Wukong 2040 sensor to train neural network

Case 1: Using Wukong 2040 sensor to train neural network

1. Preface

The Wukong2040 is built on Raspberry Pi RP2040, which is Raspberry Pi's first microcontroller - and is fully supported by Edge Impulse. You can sample raw data, build models, and deploy trained machine-learning models directly from Studio.

To get started with your Raspberry Pi RP2040 and Edge Impulse, you'll need:

  1. Raspberry Pi 2040 microcontroller. Pre-built firmware and binary files exported by Edge Impulse Studio are tailored for Raspberry Pi Pico. But with a few simple steps, you can collect data and run your model using other RP2040-based boards such as the Arduino Nano RP2040 Connect
  2. Using a Raspberry Pi Pico makes it easier to connect external sensors for data collection/inference. The board's Edge Impulse firmware is open source and hosted on GitHub: edgeimpulse/firmware-pi-rp2040


2. Installation Steps

2.1 Connect the development board to the computer

Connect the board to your computer using a micro-USB cable while holding down the BOOTSEL button to force the Raspberry Pi Pico into USB mass storage mode.


2.2. Update firmware

The board does not yet ship with the correct firmware. Update firmware:

a) Latest Edge Impulse firmware and unzip the file.

b) Drag the ei_rp2040_firmware.uf2 file from the folder to the USB mass storage device.

c) Wait for the flash to complete, unplug, and reinsert the motherboard to boot the new firmware.


3. Set Buttons

Run from command prompt or terminal:


This will launch a wizard asking you to log in and select your Edge Impulse project. If you want to switch projects, run with --clean.


4. Verify That The Device is connected

that's all! Your device is now connected to Edge Impulse. To verify this, go to the Edge Impulse project and click on the device. The device will be listed here.


5. Next Steps: Build a Machine-learning Model

Once everything is set up, you can now build your first machine-learning model. Since the Raspberry Pi Pico doesn't have any built-in sensors, we decided to add the following supported sensors out of the box via pre-built firmware: Temperature and Humidity Sensor (GP18; pin D18 on the Pi Pico Grove Shield).

There is a wide variety of analog signal sensors that can take advantage of the RP2040 10-bit ADC (Analog-to-Digital Converter), from common sensors (e.g. light sensors, sound level sensors) to more specialized sensors (e.g. carbon dioxide sensors, natural sensors) gas sensors and even electromyography detectors.

Once you have a compatible sensor, you can:

a) Build a continuous action recognition system

b) Build a sensor fusion model

c) Recognition from audio

d) Respond to your voice


While the pre-built Edge Impulse firmware was primarily tested with a Pico board, it is compatible with other boards except for I2C sensors and microphones - different boards use different peripheral pins, so if you want to use the LSM6DS3/LSM6DSOX accelerometer& Gyroscope module or microphone, you need to change the pin values in the Edge Impulse RP2040 firmware source code, recompile and upload it to the development board.