|
8 | 8 | - Cheat sheet
|
9 | 9 | - RGB
|
10 | 10 | - Communication
|
11 |
| -author: 'José Bagur and Benjamin Dannegård' |
| 11 | +author: 'José Bagur, Benjamin Dannegård and Christopher Méndez' |
12 | 12 | hardware:
|
13 | 13 | - hardware/06.nicla/boards/nicla-voice
|
14 | 14 | software:
|
@@ -762,6 +762,108 @@ Let's use also the Arduino IDE Serial Plotter to test the example IMU sketch, op
|
762 | 762 |
|
763 | 763 | 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>), the gyroscope measurements on the three-axis will stay close to zero.
|
764 | 764 |
|
| 765 | +#### IMU and Machine Learning |
| 766 | +
|
| 767 | +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**. |
| 768 | +
|
| 769 | +
|
| 770 | +```arduino |
| 771 | +#include "NDP.h" |
| 772 | +
|
| 773 | +// Set to 'true' for the lowest power consumption mode, 'false' otherwise |
| 774 | +const bool lowestPower = false; |
| 775 | +
|
| 776 | +// Function to turn on the blue LED and print a label to the serial monitor if not in the lowest power mode |
| 777 | +void ledBlueOn(char* label) { |
| 778 | + nicla::leds.begin(); |
| 779 | + nicla::leds.setColor(blue); |
| 780 | + delay(200); |
| 781 | + nicla::leds.setColor(off); |
| 782 | + if (!lowestPower) { |
| 783 | + Serial.println(label); |
| 784 | + } |
| 785 | + nicla::leds.end(); |
| 786 | +} |
| 787 | +
|
| 788 | +// Function to turn on the green LED briefly |
| 789 | +void ledGreenOn() { |
| 790 | + nicla::leds.begin(); |
| 791 | + nicla::leds.setColor(green); |
| 792 | + delay(200); |
| 793 | + nicla::leds.setColor(off); |
| 794 | + nicla::leds.end(); |
| 795 | +} |
| 796 | +
|
| 797 | +// Function to make the red LED blink continuously |
| 798 | +void ledRedBlink() { |
| 799 | + while (1) { |
| 800 | + nicla::leds.begin(); |
| 801 | + nicla::leds.setColor(red); |
| 802 | + delay(200); |
| 803 | + nicla::leds.setColor(off); |
| 804 | + delay(200); |
| 805 | + nicla::leds.end(); |
| 806 | + } |
| 807 | +} |
| 808 | +
|
| 809 | +void setup() { |
| 810 | + Serial.begin(115200); |
| 811 | + nicla::begin(); |
| 812 | + nicla::disableLDO(); |
| 813 | + nicla::leds.begin(); |
| 814 | +
|
| 815 | + // Register event handlers for error, match, and event |
| 816 | + NDP.onError(ledRedBlink); |
| 817 | + NDP.onMatch(ledBlueOn); |
| 818 | + NDP.onEvent(ledGreenOn); |
| 819 | +
|
| 820 | + // Load Edge Impulse model and related firmware |
| 821 | + Serial.println("Loading synpackages"); |
| 822 | + NDP.begin("mcu_fw_120_v91.synpkg"); |
| 823 | + NDP.load("dsp_firmware_v91.synpkg"); |
| 824 | + NDP.load("ei_model_imu.synpkg"); |
| 825 | + Serial.println("packages loaded"); |
| 826 | +
|
| 827 | + NDP.getInfo(); |
| 828 | + NDP.configureInferenceThreshold(1088); |
| 829 | + NDP.interrupts(); |
| 830 | +
|
| 831 | + // Enter the lowest power mode, if set |
| 832 | + nicla::leds.end(); |
| 833 | + if (lowestPower) { |
| 834 | + NRF_UART0->ENABLE = 0; |
| 835 | + } |
| 836 | +} |
| 837 | +
|
| 838 | +// Predefined IMU data for testing |
| 839 | +extern "C" const unsigned char data_opensset_bin[]; |
| 840 | +extern "C" const unsigned char data_circ_bin[]; |
| 841 | +extern "C" const unsigned int data_opensset_bin_len; |
| 842 | +extern "C" const unsigned int data_circ_bin_len; |
| 843 | +
|
| 844 | +void loop() { |
| 845 | + // Send openset data (no match expected) |
| 846 | + Serial.println("Sending openset data... (no match expected)"); |
| 847 | + NDP.sendData((uint8_t*)data_opensset_bin, data_opensset_bin_len); |
| 848 | + delay(1000); |
| 849 | +
|
| 850 | + // Send circular IMU data (match expected) |
| 851 | + Serial.println("Sending circular IMU data.... (match expected)"); |
| 852 | + NDP.sendData((uint8_t*)data_circ_bin, data_circ_bin_len); |
| 853 | + delay(5000); |
| 854 | +} |
| 855 | +``` |
| 856 | +
|
| 857 | +In the example code above, a Machine Learning model is loaded into the Nicla Voice board, and predefined IMU data is sent to the Machine Learning model for inferencing. Depending on the result, the board will light its built-in RGB LED with different colors: |
| 858 | +
|
| 859 | +- If the model matches the input data with a known motion pattern, the built-in RGB LED is turned blue, and the event label is printed to the IDE's Serial Monitor. |
| 860 | +- If an error occurs, the built-in RGB LED will blink red continuously. |
| 861 | +- While an event is recognized, the built-in RGB LED is turned on green. |
| 862 | +
|
| 863 | +To learn more about your Nicla Voice board Machine Learning capabilities, check out the following tutorial and learn how to create a simple motion detection application: |
| 864 | +
|
| 865 | +- [Motion Detection with Nicla Voice and Machine Learning Tools](https://docs.arduino.cc/tutorials/nicla-voice/motion-detection-ml) |
| 866 | +
|
765 | 867 | ### Magnetometer
|
766 | 868 |
|
767 | 869 | The onboard magnetometer of the Nicla Voice can be used to determine the board's orientation relative to Earth's magnetic field, which is helpful for compass applications, navigation, or detecting the presence of nearby magnetic objects. The magnetometer on the Nicla Voice board is the BMM150, also from Bosch®. It is a 3-axis sensor that measures the strength and direction of magnetic fields surrounding the board.
|
@@ -961,108 +1063,6 @@ Now open the IDE's Serial Plotter by navigating to **Tools > Serial Plotter**. A
|
961 | 1063 |
|
962 | 1064 | 
|
963 | 1065 |
|
964 |
| -#### IMU and Machine Learning |
965 |
| -
|
966 |
| -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**. |
967 |
| -
|
968 |
| -
|
969 |
| -```arduino |
970 |
| -#include "NDP.h" |
971 |
| -
|
972 |
| -// Set to 'true' for the lowest power consumption mode, 'false' otherwise |
973 |
| -const bool lowestPower = false; |
974 |
| -
|
975 |
| -// Function to turn on the blue LED and print a label to the serial monitor if not in the lowest power mode |
976 |
| -void ledBlueOn(char* label) { |
977 |
| - nicla::leds.begin(); |
978 |
| - nicla::leds.setColor(blue); |
979 |
| - delay(200); |
980 |
| - nicla::leds.setColor(off); |
981 |
| - if (!lowestPower) { |
982 |
| - Serial.println(label); |
983 |
| - } |
984 |
| - nicla::leds.end(); |
985 |
| -} |
986 |
| -
|
987 |
| -// Function to turn on the green LED briefly |
988 |
| -void ledGreenOn() { |
989 |
| - nicla::leds.begin(); |
990 |
| - nicla::leds.setColor(green); |
991 |
| - delay(200); |
992 |
| - nicla::leds.setColor(off); |
993 |
| - nicla::leds.end(); |
994 |
| -} |
995 |
| -
|
996 |
| -// Function to make the red LED blink continuously |
997 |
| -void ledRedBlink() { |
998 |
| - while (1) { |
999 |
| - nicla::leds.begin(); |
1000 |
| - nicla::leds.setColor(red); |
1001 |
| - delay(200); |
1002 |
| - nicla::leds.setColor(off); |
1003 |
| - delay(200); |
1004 |
| - nicla::leds.end(); |
1005 |
| - } |
1006 |
| -} |
1007 |
| -
|
1008 |
| -void setup() { |
1009 |
| - Serial.begin(115200); |
1010 |
| - nicla::begin(); |
1011 |
| - nicla::disableLDO(); |
1012 |
| - nicla::leds.begin(); |
1013 |
| -
|
1014 |
| - // Register event handlers for error, match, and event |
1015 |
| - NDP.onError(ledRedBlink); |
1016 |
| - NDP.onMatch(ledBlueOn); |
1017 |
| - NDP.onEvent(ledGreenOn); |
1018 |
| -
|
1019 |
| - // Load Edge Impulse model and related firmware |
1020 |
| - Serial.println("Loading synpackages"); |
1021 |
| - NDP.begin("mcu_fw_120_v91.synpkg"); |
1022 |
| - NDP.load("dsp_firmware_v91.synpkg"); |
1023 |
| - NDP.load("ei_model_imu.synpkg"); |
1024 |
| - Serial.println("packages loaded"); |
1025 |
| -
|
1026 |
| - NDP.getInfo(); |
1027 |
| - NDP.configureInferenceThreshold(1088); |
1028 |
| - NDP.interrupts(); |
1029 |
| -
|
1030 |
| - // Enter the lowest power mode, if set |
1031 |
| - nicla::leds.end(); |
1032 |
| - if (lowestPower) { |
1033 |
| - NRF_UART0->ENABLE = 0; |
1034 |
| - } |
1035 |
| -} |
1036 |
| -
|
1037 |
| -// Predefined IMU data for testing |
1038 |
| -extern "C" const unsigned char data_opensset_bin[]; |
1039 |
| -extern "C" const unsigned char data_circ_bin[]; |
1040 |
| -extern "C" const unsigned int data_opensset_bin_len; |
1041 |
| -extern "C" const unsigned int data_circ_bin_len; |
1042 |
| -
|
1043 |
| -void loop() { |
1044 |
| - // Send openset data (no match expected) |
1045 |
| - Serial.println("Sending openset data... (no match expected)"); |
1046 |
| - NDP.sendData((uint8_t*)data_opensset_bin, data_opensset_bin_len); |
1047 |
| - delay(1000); |
1048 |
| -
|
1049 |
| - // Send circular IMU data (match expected) |
1050 |
| - Serial.println("Sending circular IMU data.... (match expected)"); |
1051 |
| - NDP.sendData((uint8_t*)data_circ_bin, data_circ_bin_len); |
1052 |
| - delay(5000); |
1053 |
| -} |
1054 |
| -``` |
1055 |
| -
|
1056 |
| -In the example code above, a Machine Learning model is loaded into the Nicla Voice board, and predefined IMU data is sent to the Machine Learning model for inferencing. Depending on the result, the board will light its built-in RGB LED with different colors: |
1057 |
| -
|
1058 |
| -- If the model matches the input data with a known motion pattern, the built-in RGB LED is turned blue, and the event label is printed to the IDE's Serial Monitor. |
1059 |
| -- If an error occurs, the built-in RGB LED will blink red continuously. |
1060 |
| -- While an event is recognized, the built-in RGB LED is turned on green. |
1061 |
| -
|
1062 |
| -To learn more about your Nicla Voice board Machine Learning capabilities, check out the following tutorial and learn how to create a simple motion detection application: |
1063 |
| -
|
1064 |
| -- [Motion Detection with Nicla Voice and Machine Learning Tools](https://docs.arduino.cc/tutorials/nicla-voice/motion-detection-ml) |
1065 |
| -
|
1066 | 1066 | ## Actuators
|
1067 | 1067 |
|
1068 | 1068 | ### RGB LED
|
@@ -1213,9 +1213,9 @@ digitalWrite(SS, HIGH);
|
1213 | 1213 | The Nicla Voice supports I2C communication, which allows data transmission between the board and other I2C-compatible devices. The pins used in the Nicla Voice for the I2C communication protocol are the following:
|
1214 | 1214 |
|
1215 | 1215 | | **Microcontroller Pin** | **Arduino Pin Mapping** |
|
1216 |
| -|:-----------------------:|:-----------------------:| |
1217 |
| -| `P0_23` | `SCL` or `3` | |
1218 |
| -| `P0_22` | `SDA` or `4` | |
| 1216 | +| :---------------------: | :---------------------: | |
| 1217 | +| `P0_23` | `I2C_SCL` or `3` | |
| 1218 | +| `P0_22` | `I2C_SDA` or `4` | |
1219 | 1219 |
|
1220 | 1220 | Please, refer to the [board pinout section](#pins) of the user manual to find them on the board. The I2C pins are also available through the onboard ESLOV connector of the Nicla Voice.
|
1221 | 1221 |
|
@@ -1280,9 +1280,9 @@ while (Wire.available()) {
|
1280 | 1280 | The pins used in the Nicla Voice for the UART communication protocol are the following:
|
1281 | 1281 |
|
1282 | 1282 | | **Microcontroller Pin** | **Arduino Pin Mapping** |
|
1283 |
| -|:-----------------------:|:-----------------------:| |
1284 |
| -| `P0_09` | `TX` or `1` | |
1285 |
| -| `P0_20` | `RX` or `2` | |
| 1283 | +| :---------------------: | :---------------------: | |
| 1284 | +| `P0_09` | `SERIAL1_TX` or `1` | |
| 1285 | +| `P0_20` | `SERIAL1_RX` or `2` | |
1286 | 1286 |
|
1287 | 1287 | Please, refer to the [board pinout section](#board-pinout) of the user manual to find them on the board.
|
1288 | 1288 |
|
|
0 commit comments