Skip to content

Commit fa02e7d

Browse files
Refine documentation for clarity and consistency in titles, headings, and instructions across multiple files
1 parent 0e8b8dc commit fa02e7d

3 files changed

Lines changed: 156 additions & 125 deletions

File tree

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,72 @@
11
---
2-
title: Board Connection and IDE setup
2+
title: Board connection and IDE setup
33
weight: 4
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
### Arduino Nano RP2040
9+
## Arduino Nano RP2040
1010

11-
To get started with your first **TinyML project**, the **Arduino Nano RP2040 Connect** is a good option. Built by Arduino, it uses the **RP2040 microcontroller** and is fully supported by the Arduino core package. The board comes with built-in Wi-Fi, Bluetooth, and an onboard IMU—features that is useful for deploying machine learning models at the edge.
11+
To get started with your first **TinyML project**, the **Arduino Nano RP2040 Connect** is a good option. Built by Arduino, it uses the **RP2040 microcontroller** and is fully supported by the Arduino core package.
12+
13+
14+
The board comes with built-in Wi-Fi, Bluetooth, and an onboard IMU. These are features that are useful for deploying machine learning models at the edge.
1215

1316
![example image alt-text#center](images/nano.png "Arduino Nano RP2040")
1417

1518
Its compatibility with popular tools like Edge Impulse and the Arduino IDE makes it a suitable choice for TinyML applications. You can learn more about the Arduino Nano RP2040 Connect on the [official Arduino website](https://store.arduino.cc/products/arduino-nano-rp2040-connect-with-headers?_gl=1*1laabar*_up*MQ..*_ga*MTk1Nzk5OTUwMS4xNzQ2NTc2NTI4*_ga_NEXN8H46L5*czE3NDY1NzY1MjUkbzEkZzEkdDE3NDY1NzY5NTkkajAkbDAkaDE1MDk0MDg0ODc.).
1619

17-
## Put everything together
20+
## Connect and set up the Arduino Nano RP2040 Connect
21+
22+
This guide will help you connect the Arduino Nano RP2040 Connect to your computer and set up the Arduino IDE for programming.
1823

19-
### Step 1: Connect the LED to the Arduino Nano RP2040
24+
## Gather the components
2025

21-
To visualize the output of the voice command model, you will use a simple LED circuit.
26+
To visualize the output of the voice command model, you'll use a simple LED circuit.
2227

23-
### Components Needed
28+
You will need the following components:
2429

25-
- Arduino Nano RP2040 Connect
26-
- 1x LED
27-
- 1x 220Ω resistor
30+
- Arduino Nano RP2040 Connect
31+
- LED
32+
- 1× 220 Ω resistor
2833
- Breadboard and jumper wires
2934

30-
#### Circuit Diagram
35+
## Connect the LED to the Arduino Nano RP2040
3136

32-
- **Anode (long leg) of the LED**Connect to **GPIO pin D2** via the 220Ω resistor
33-
- **Cathode (short leg)**Connect to **GND**
37+
- **Anode (long leg) of the LED**connect to **GPIO pin D2** through a 220 Ω resistor
38+
- **Cathode (short leg)**connect to **GND**
3439

35-
![example image alt-text#center](images/led_connection.png "Circuit Connection")
40+
![Diagram showing the physical breadboard circuit connecting an LED to GPIO D2 and GND on the Arduino Nano RP2040 alt-text#center](images/led_connection.png)
3641

37-
![example image alt-text#center](images/led_connection_schematic.png "Circuit Schematic Connection")
42+
![Schematic diagram showing the LED connected between GPIO D2 and GND with a 220 Ω resistor in series alt-text#center](images/led_connection_schematic.png)
3843

39-
### Step 2: Set Up the Arduino IDEs
44+
## Set up the Arduino IDE
4045

4146
To program and deploy your trained model to the Arduino Nano RP2040, you first need to configure your development environment.
4247

43-
Follow the detailed setup instructions provided in the [Arduino Nano RP2040 Install Guide](https://learn.arm.com/install-guides/arduino-pico/)
48+
Follow the steps in the [Arduino Nano RP2040 install guide](https://learn.arm.com/install-guides/arduino-pico/).
4449

45-
This guide will walk you through:
50+
This guide walks you through:
4651

47-
- Installing the Arduino IDE
52+
- Installing the Arduino IDE
4853
- Adding the board support package for the Nano RP2040
4954

50-
{{% notice Note %}}
51-
Follow every instruction in the guide *except* `How do I set up the Raspberry Pi Pico W?`, as it is not needed for this project.
52-
{{% /notice %}}
55+
{{< notice Note >}}
56+
Follow all steps in the guide except *How do I set up the Raspberry Pi Pico W?*, which is not required for this project.
57+
{{< /notice >}}
5358

54-
### Step 3: Select Your Board and Port in the Arduino IDE
59+
## Select your board and port in the Arduino IDE
5560

56-
First, open the **Arduino IDE**.
61+
Open the Arduino IDE. To select your board:
5762

58-
To select your board:
59-
60-
1. Go to **Tools** > **Board**.
61-
2. From the list, choose **Arduino Nano RP2040 Connect**.
63+
Go to **Tools** > **Board** then select **Arduino Nano RP2040 Connect**
6264

6365
To select your port:
6466

65-
1. Connect your Arduino board to your computer using a USB cable.
66-
2. Go to **Tools** > **Port**.
67-
3. Select the port labeled with your board’s name, e.g., `COM4 (Arduino Nano RP2040 Connect)` or `/dev/cu.usbmodem...` on macOS.
67+
Connect your board to your computer using a USB cable, then follow these steps:
68+
69+
- Go to **Tools** > **Port**
70+
- Select the port labeled with your board's name, such as `COM4 (Arduino Nano RP2040 Connect)` or `/dev/cu.usbmodem...` on macOS.
6871

69-
*Your Arduino IDE is now ready to upload code to the Arduino Nano RP2040.*
72+
Your Arduino IDE is now ready to upload code to the Arduino Nano RP2040.

content/learning-paths/embedded-and-microcontrollers/edge/program-and-deployment.md

Lines changed: 90 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,79 @@
11
---
2-
title: Program your first tinyML device
2+
title: Program your first TinyML device
33
weight: 5
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
# Programming your first tinyML device
9+
## Program and deploy your first TinyML device
1010

11-
This section helps you create a complete sketch that you can upload onto your Arduino Nano RP2040.
11+
This section shows you how to create a complete sketch that you can upload onto your Arduino Nano RP2040.
1212

13-
## Step 1: Create a New Sketch
13+
You’ll begin by setting up a new sketch in the Arduino IDE, then add the library generated by Edge Impulse. After reviewing a sample program, you’ll upload it to your board to run real-time audio inference and control an LED based on voice commands.
1414

15-
1. Open the **Arduino IDE**.
16-
2. Go to **File** > **New**.
17-
3. A new sketch (blank code window) will open, ready for you to start writing your code.
18-
4. Save your sketch by going to **File** > **Save**. Choose a name and location for your file.
15+
By the end of this section, your board will be able to respond to the words "on" and "off". It is a simple, but powerful, demonstration of TinyML in action.
1916

20-
## Step 2: Upload the Arduino Library from Edge Impulse
17+
## Create a new sketch
2118

22-
1. After creating and saving your sketch, go to **Sketch** > **Include Library** > **Add .ZIP Library**.
23-
2. In the file dialog that opens, navigate to the location of the **ZIP file** you exported from Edge Impulse in [Set up your environment](/learning-paths/embedded-and-microcontrollers/edge/software-edge-impulse/)
24-
3. Select the **ZIP file** and click **Open**.
19+
To create a new sketch in the Arduino IDE, follow these steps:
2520

26-
## Step 3: Include the Library in Your Sketch
21+
* Open the **Arduino IDE**, and then go to **File** > **New**.
22+
* A new sketch window will open, and you will see a blank sketch with the default structure, which includes two main functions: `setup()` and `loop()`. The `setup()` function runs once when the program starts, and the `loop()` function runs continuously after that.
23+
* You will see a blank sketch with the default structure, which includes two main functions: `setup()` and `loop()`. The `setup()` function runs once when the program starts, and the `loop()` function runs continuously after that.
24+
* Now save your sketch using **File** > **Save**, and give it a clear name. For example, you can name it **"TinyML_Voice_Control"** or something similar that describes your project.
2725

28-
Finally, to include the library and model in your sketch, go to **Sketch** > **Include Library** and select the newly installed library and model from the list.
26+
{{< notice Note >}}
27+
Make sure to save it in a location where you can easily find it later, such as your **Documents** folder or a dedicated **Arduino** folder.
28+
{{< /notice >}}
2929

30-
{{% notice Note %}}
31-
The libray should be of the form `Name_of_your_library_inferencing.h`
32-
{{% /notice %}}
3330

34-
# Code walk-through
31+
## Upload the Arduino library from Edge Impulse
32+
33+
* After creating and saving your sketch, go to **Sketch** > **Include Library** > **Add .ZIP Library**
34+
* In the file dialog that opens, navigate to the location of the ZIP file you exported from Edge Impulse in [Set up your environment](/learning-paths/embedded-and-microcontrollers/edge/software-edge-impulse/)
35+
* Select the ZIP file and click **Open**
36+
* The Arduino IDE will automatically install the library and any dependencies it requires.
37+
38+
## Include the library in your sketch
39+
40+
To include the library and model in your sketch, go to **Sketch** > **Include Library** and select the newly installed Edge Impulse library from the list.
41+
42+
{{< notice Note >}}
43+
The header file should be named something like `Name_of_your_library_inferencing.h`
44+
{{< /notice >}}
3545

36-
In the example repository, you will find a code snippet `Code_Sample.ino`, which is used as a sketch for the project. Before running the code, it’s important to understand what each part does.
46+
This will add the necessary include statement at the top of your sketch, allowing you to use the functions and classes provided by the Edge Impulse library.
47+
48+
## Code walk-through
49+
50+
In the example repository, you will find a code snippet named `Code_Sample.ino`, which is used as a sketch for this project. Before running the code, it’s important to understand what each part does.
3751

3852
Take a few minutes to read through the comments and logic in the sketch before uploading it to your board. The code is available in the example repository, and below is a walk-through of the steps.
3953

40-
## Include Necessary Libraries and Define Data Structure for Inference
54+
## Include the library in your sketch
55+
56+
To include the library and model in your sketch, go to **Sketch** > **Include Library** and select the newly installed Edge Impulse library from the list.
57+
58+
{{< notice Note >}}
59+
The header file should be named something like `Name_of_your_library_inferencing.h`
60+
{{< /notice >}}
61+
62+
This will add the necessary include statement at the top of your sketch, allowing you to use the functions and classes provided by the Edge Impulse library.
4163

42-
This block sets up the core dependencies for running Edge Impulse inference on audio input. It includes necessary libraries and defines a structure `inference_t` that holds the audio buffer and relevant state needed to manage sampling and inferencing.
64+
## Code walk-through
65+
66+
In the example repository, you will find a code snippet named `Code_Sample.ino`, which is used as a sketch for this project. Before running the code, it’s important to understand what each part does.
67+
68+
Take a few minutes to read through the comments and logic in the sketch before uploading it to your board. The code is available in the example repository, and below is a walk-through of the steps.
69+
70+
## Include libraries and define inference data structure
71+
72+
This block sets up the core dependencies for running Edge Impulse inference on audio input. It includes the necessary libraries and defines a structure `inference_t` that holds the audio buffer and relevant state needed to manage sampling and inferencing.
4373

4474
```c
4575
#include <Name_of_your_library_inferencing.h> // Include the Edge Impulse inference SDK for running the model
46-
#include <PDM.h> // Include the Pulse Density Modulation (PDM) library for audio input
76+
#include <PDM.h> // Include the Pulse Density Modulation (PDM) library for audio input
4777

4878
// Define a structure to store inference-related audio data
4979
typedef struct {
@@ -54,16 +84,16 @@ typedef struct {
5484
} inference_t;
5585
```
5686

57-
## Code to Define Global Variables for Inference and Sample Buffer
87+
## Define global variables for inference and sample buffer
5888

59-
Declares and initializes global variables used for storing inference data, raw audio samples, debug mode flag, and a recording readiness flag. These are essential for coordinating the data collection and inference process.
89+
This block declares and initializes global variables used to store inference data, raw audio samples, a debug flag, and a recording readiness flag. These variables coordinate the data collection and inference process.
6090

6191
```c
6292
static inference_t inference; // Global instance of the inference structure to manage audio data
6393
static signed short sampleBuffer[2048]; // Buffer to temporarily store raw audio samples (16-bit signed)
6494
static bool debug_nn = false; // Flag to enable/disable detailed neural network debug output
6595
static volatile bool record_ready = false; // Flag indicating when the system is ready to start recording (volatile due to use in ISR)
66-
```
96+
6797

6898
## Setup Function for Initializing the Serial and Microphone
6999

@@ -98,9 +128,10 @@ void setup() {
98128
The macro `#define LED_PIN 2` specifies the pin number to which the LED is connected. You can change this value to any available digital pin on your board.
99129
{{% /notice %}}
100130
101-
## Main Loop to Handle Inference and Control LED
131+
## Main loop to handle inference and control LED
132+
133+
The `loop()` function runs continuously after `setup()`. It performs the inference process, including recording audio, running the classifier, and controlling an LED based on the model's prediction.
102134
103-
Defines the `loop()` function, which runs continuously after `setup()`. It performs the inference process, including recording audio, running the classifier, and controlling an LED based on the inference result.
104135
105136
```c
106137
void loop() {
@@ -152,9 +183,9 @@ In this example, the LED will turn on if the model predicts the "on" label with
152183
You are free to modify these threshold values to better suit your application or improve model response.
153184
{{% /notice %}}
154185

155-
## PDM Data Ready Callback for Buffer Management
186+
## PDM data ready callback for buffer management
156187

157-
Defines the `pdm_data_ready_inference_callback()` function, which is triggered when the Pulse Density Modulation (PDM) buffer is full. It reads available audio data and stores it in the inference buffer for processing.
188+
The `pdm_data_ready_inference_callback()` function is triggered when the Pulse Density Modulation (PDM) buffer is full. It reads the available audio data and stores it in the inference buffer for processing.
158189

159190
```c
160191
/* PDM buffer full callback */
@@ -177,7 +208,7 @@ static void pdm_data_ready_inference_callback(void) {
177208
}
178209
```
179210
180-
## Initialize Microphone for Inference
211+
## Initialize microphone for inference
181212
182213
Allocates memory for audio sampling, configures the PDM microphone, and prepares the system to begin audio inference.
183214
@@ -215,7 +246,7 @@ static bool microphone_inference_start(uint32_t n_samples) {
215246
216247
```
217248

218-
## Microphone Inference Record Function
249+
## Microphone inference record function
219250

220251
Defines the `microphone_inference_record()` function, which waits for the microphone buffer to be filled with audio samples. Once the buffer is ready, it resets the buffer state and prepares for the next recording cycle.
221252

@@ -231,7 +262,7 @@ static bool microphone_inference_record(void) {
231262
}
232263
```
233264
234-
## Microphone Data Handling and Cleanup
265+
## Microphone data handling and cleanup
235266
236267
Defines two functions: `microphone_audio_signal_get_data()`, which converts raw audio data from the buffer into a float format, and `microphone_inference_end()`, which cleans up by stopping the PDM and freeing memory allocated for the audio buffer.
237268
@@ -249,7 +280,7 @@ static void microphone_inference_end(void) {
249280
}
250281
```
251282

252-
## Function to Print the Inference Results
283+
## Function to print the inference results
253284

254285
Defines the `print_inference_result()` function, which outputs the results of the inference, including the timing of different stages — **DSP**, classification, anomaly detection — and the prediction values for each class.
255286

@@ -280,52 +311,51 @@ void print_inference_result(ei_impulse_result_t result) {
280311
The `ei_printf` command is a custom logging function from the Edge Impulse SDK, used for printing debug or inference-related information to the serial monitor, optimized for embedded systems. It works similarly to `printf` but is tailored for the Edge Impulse environment. You can find the complete `Code_Sample.ino` in the example repository and try it out yourself.
281312
{{% /notice %}}
282313
283-
# Run Your Code
314+
## Run your code
284315
285316
Now that you have a good understanding of the code, you should run it on your device. With your **Arduino Nano RP2040** plugged into your computer, and the correct [board and port](/learning-paths/embedded-and-microcontrollers/egde/connect-and-set-up-arduino/) selected in the Arduino IDE, follow these steps:
286317
287-
#### If you're using the **Upload Button**
318+
If you're using the **Upload Button**:
288319
289-
1. Click the **right-facing arrow** at the top-left of the Arduino IDE window.
290-
2. The IDE will compile your code and upload it to your board.
291-
3. Wait for the message **“Done uploading.”** to appear at the bottom of the IDE.
320+
- Click the **right-facing arrow** at the top-left of the Arduino IDE window.
321+
- The IDE will compile your code and upload it to your board.
322+
- Wait for the message **“Done uploading.”** to appear at the bottom of the IDE.
292323
293-
#### If you're using the **Sketch Menu**
324+
If you're using the **Sketch Menu**:
294325
295-
1. Go to **Sketch** > **Upload**.
296-
2. The IDE will compile and upload your sketch to the board.
297-
3. Once the upload is complete, you’ll see **“Done uploading.”** at the bottom.
326+
- Go to **Sketch** > **Upload**.
327+
- The IDE will compile and upload your sketch to the board.
328+
- Once the upload is complete, you’ll see **“Done uploading.”** at the bottom.
298329
299330
Your board should now start running the uploaded code automatically.
300331
301-
### Verify Your Code is Running
332+
## Verify your code is running
302333
303-
To further confirm that your code is running properly:
334+
To confirm that your code is running properly:
304335
305-
1. Go to **Tools** > **Serial Monitor** in the Arduino IDE.
306-
2. Set the baud rate to **115200** (if it's not already).
307-
3. Observe the output messages:
308-
- Start and end of recording
309-
- Inference process
310-
- Predictions for each label
336+
- Go to **Tools** > **Serial Monitor** in the Arduino IDE
337+
- Set the baud rate to **115200** (if it's not already)
338+
- Observe the output messages:
339+
- Start and end of recording
340+
- Inference process
341+
- Predictions for each label
311342
312343
These messages indicate that your model is working and processing voice input as expected.
313344
314-
### Recording Your Voice to Toggle the LED
315-
316-
1. Wait for the **"Recording..."** message to appear on the Serial Monitor. This indicates that the system is ready to record your voice input.
317-
318-
2. Speak your command (e.g., "on" or "off") quickly, as the system only records for a brief 1-second window. Once that window closes, inference will take place, and the system will process the voice command.
345+
## Record your voice to toggle the LED
319346
320-
3. The system will make a prediction based on the input, toggling the LED accordingly.
347+
- Wait for the **Recording...** message to appear on the Serial Monitor. This means the system is ready to capture voice input.
348+
- Say your command (for example, "on" or "off") clearly and promptly. The system records for only about one second.
349+
- The model will make a prediction based on your voice input and toggle the LED accordingly.
350+
- You can adjust the **threshold** values in the code to control how confident the prediction must be before the LED toggles. This helps fine-tune the system’s responsiveness.
351+
- If the LED turns on when you say "on" and turns off when you say "off", your system is working correctly.
321352
322-
4. You can adjust the **threshold** for prediction accuracy in the code to fine-tune when the LED should toggle, based on the prediction confidence level. This helps control how sensitive the system is to voice commands.
323353
324-
### Serial Monitor Output
354+
## Serial Monitor output
325355
326-
Your Serial Monitor should look like the image below.
356+
Your Serial Monitor should look like the image below:
327357
328-
![example image alt-text#center](images/serial_monitor.png "Figure 16. Circuit Connection")
358+
![example image alt-text#center](images/serial_monitor.png "Circuit Connection")
329359
330360
Congratulations, you’ve successfully programmed your first TinyML microcontroller! You've also built a functional, smart system to control an LED with your voice.
331361

0 commit comments

Comments
 (0)