You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/06.nicla/boards/nicla-voice/tutorials/user-manual/content.md
+197-4Lines changed: 197 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -441,7 +441,7 @@ The onboard magnetometer of the Nicla Voice can be used to determine the board's
441
441
442
442
#### Accelerometer and Gyroscope Data
443
443
444
-
The example code below shows how to get acceleration (m/s<sup>2</sup>) and angular velocity (in °/s) data from the onboard IMU and streams it to the Arduino IDE Serial Monitor.
444
+
The example code below shows how to get acceleration (m/s<sup>2</sup>) and angular velocity (in °/s) data from the onboard IMU and streams it to the Arduino IDE Serial Monitor and Serial Plotter.
// Set the BMI270 sensor in SPI mode, then read sensor data.
@@ -669,9 +669,9 @@ Next, user functions `ledBlueOn()`, `ledGreenOn()`, and `ledRedBlink()` definiti
669
669
Next, in the `setup()` function:
670
670
671
671
- The serial communication is initialized at a baud rate of 115200.
672
-
- The Nicla Voice board is initialized, and the LDO regulator (used for putting the board into power-saving modes) is disabled to avoid communication problems with the IMU.
672
+
- The Nicla Voice board is initialized, and the LDO regulator (used for putting the board into power-saving mode) is disabled to avoid communication problems with the IMU.
673
673
- Error and event handlers are initialized.
674
-
- NDP processor is initialized; this process includes populating the external Flash memory of the board with the NDP processor internal microcontroller firmware (`mcu_fw_120_v91.synpkg`), the NDP processor internal DSP firmware (`dsp_firmware_v91.synpkg`), and the ML model (`ei_model.synpkg`).
674
+
- NDP processor is initialized; this process includes populating the external Flash memory of the board with the NDP processor's internal microcontroller firmware (`mcu_fw_120_v91.synpkg`), the NDP processor's internal DSP firmware (`dsp_firmware_v91.synpkg`), and the ML model (`ei_model.synpkg`).
675
675
- The BMI270 sensor is initialized; this includes a software reset, loading the sensor configuration, and setting it into normal power mode with the accelerometer and gyroscope operational.
676
676
677
677
Finally, in the `loop()` function:
@@ -716,6 +716,199 @@ Upload the example sketch again and open the IDE's Serial Plotter by navigating
716
716
717
717
When the board is not moving, you should see acceleration measurements close to zero on the x and y-axis, while the z-axis will be close to 1g (approximately 9.81 m/s<sup>2</sup>). If you want to visualize gyroscope readings, uncomment the gyroscope data output and comment on the accelerometer data output; when the board is not moving, you should see gyroscope measurements on the three-axis close to zero.
718
718
719
+
#### Magnetometer Data
720
+
721
+
The example code below shows how to get raw magnetic field and Hall resistance data from the onboard magnetometer and stream it to the Arduino IDE Serial Monitor and Serial Plotter.
Here you can find a step-by-step explanation of the code:
880
+
881
+
First, the necessary libraries are included:
882
+
883
+
-`NDP.h` for the Nicla Voice board's basic functions and the magnetometer control.
884
+
- Macros are defined for checking the status of the magnetometer; these macros allow the sketch to detect and handle sensor errors.
885
+
886
+
Next, user functions `ledBlueOn()`, `ledGreenOn()`, and `ledRedBlink()` definition:
887
+
888
+
- These functions allow the onboard LEDs to flash specific colors to indicate different states: blue for a successful match, green for an event, and red to indicate an error.
889
+
890
+
Next, in the `setup()` function:
891
+
892
+
- The serial communication is initialized at a baud rate of 115200.
893
+
- The Nicla Voice board is initialized, and the LDO regulator (used for putting the board into power-saving mode) is disabled to avoid communication problems with the magnetometer.
894
+
- Error and event handlers are initialized.
895
+
- NDP processor is initialized; this process includes populating the external Flash memory of the board with the NDP processor's internal microcontroller firmware (`mcu_fw_120_v91.synpkg`), the NDP processor's internal DSP firmware (`dsp_firmware_v91.synpkg`), and the ML model (`ei_model.synpkg`).
896
+
- The BMM150 sensor is initialized; this includes setting it into normal operation with an output data rate (ODR) of 10 Hz.
897
+
898
+
Finally, in the `loop()` function:
899
+
900
+
- Memory is allocated for the sensor data; data is then read from the sensor and stored in this allocated space.
901
+
- Raw sensor data is then extracted and parsed into raw magnetometer data. Raw sensor data is extracted from the `sensor_data` array, 8-bits at a time, and then combined to form a 16-bit integer for each axis (X, Y, Z) and raw Hall resistance value.
902
+
- Raw magnetometer data is printed on the Serial Monitor, allowing the user to observe sensor data in real-time.
903
+
904
+
After uploading the example code, you should see the magnetometer data on the IDE's Serial Monitor, as shown below:
905
+
906
+

907
+
908
+
Now open the IDE's Serial Plotter by navigating to **Tools > Serial Plotter**. After a while, you should see a real-time graph showing raw data from the board's onboard magnetometer, as shown below (move the board):
909
+
910
+

911
+
719
912
#### IMU and Machine Learning
720
913
721
914
The example code below demonstrates how to use the Nicla Voice board to perform Machine Learning inference on IMU data. The code sets up event indicators using the onboard RGB LED and sends IMU data to the NDP processor for inference. The example can be found in the board's built-in examples by navigating to **File > Examples > NDP > IMUDemo**.
0 commit comments