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/05.nicla/boards/nicla-sense-me/tutorials/cheat-sheet/cheat-sheet.md
+35-35Lines changed: 35 additions & 35 deletions
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ featuredImage: 'gear'
33
33
34
34

35
35
36
-
The Arduino® Nicla Sense ME is our smallest form factor yet, with a range of industrial grade sensors packed into a tiny footprint. It features 5 industrial grade Bosch sensors that can accurately measure rotation, acceleration, pressure, humidity, temperature, air quality and CO2 levels.
36
+
The Arduino® Nicla Sense ME is our smallest form factor yet, with a range of industrial grade sensors packed into a tiny footprint. It features 4 industrial grade Bosch sensors that can accurately measure rotation, acceleration, pressure, humidity, temperature, air quality and CO2 levels.
37
37
38
38
## Goals
39
39
@@ -127,7 +127,7 @@ The Nicla System header is required to use the RGB LED.
127
127
#include "Nicla_System.h"
128
128
```
129
129
130
-
Since the functions are scoped under a specific name called "nicla" we can use the following statement to have convenient access without repeating explicitly the namespace before every function call.
130
+
Since the functions are scoped under a specific name called "nicla", you can use the following statement to have convenient access without repeating explicitly the namespace before every function call.
131
131
132
132
```cpp
133
133
usingnamespacenicla;
@@ -149,7 +149,7 @@ The LED can be set to the desired RGB value using red, green and blue components
149
149
- magenta
150
150
- cyan
151
151
152
-
To turn set the LED to a predefined color (e.g. green or blue):
152
+
To set the LED to a predefined color (e.g. green or blue):
153
153
154
154
```arduino
155
155
void loop() {
@@ -166,7 +166,7 @@ To turn the LED off:
166
166
leds.setColor(off);
167
167
```
168
168
169
-
We can also choose a value between 255 - 0 for each color component to set a custom color:
169
+
You can also choose a value between 255 - 0 for each color component to set a custom color:
170
170
171
171
```arduino
172
172
void loop() {
@@ -189,17 +189,17 @@ There are three ways to read from the on-board sensors:
189
189
2. Read sensor values through Bluetooth® Low Energy
190
190
3. Read sensor values through UART by connecting an ESLOV cable
191
191
192
-
To read from the sensors in any of these mode, you need to install the **Arduino_BHY2** and **Arduino_BHY2Host** libraries. These can be found in the library manager using the Arduino IDE. To do so in the IDE select **Tools->Manage Libraries...**, now search for **Arduino_BHY2** and **Arduino_BHY2Host** in the new window that opened and click on the install button.
192
+
To read from the sensors in any of these mode, you need to install the **Arduino_BHY2** and **Arduino_BHY2Host** libraries. These can be found in the library manager using the Arduino IDE. To do so in the IDE, select **Tools->Manage Libraries...**, now search for **Arduino_BHY2** and **Arduino_BHY2Host** in the new window that opened and click on the install button.
193
193
194
-
To use the sensors in our sketches, we need to know the sensors ID. You can find them in the section "Sensor IDs" of this article. They can also be found in the header file [here](https://github.com/arduino-libraries/Arduino_BHY2/blob/main/src/sensors/SensorID.h). Additionally, there is an example sketch in the library that will print all available sensors in the serial monitor of the Arduino IDE. This example sketch can be found in **File > Examples > Arduino_BHY2 > ShowSensorList** in the Arduino IDE.
194
+
To use the sensors in your sketches, you need to know the sensors ID. You can find them in the section "Sensor IDs" of this article. They can also be found in the header file [here](https://github.com/arduino-libraries/Arduino_BHY2/blob/main/src/sensors/SensorID.h). Additionally, there is an example sketch in the library that will print all available sensors in the Serial Monitor of the Arduino IDE. This example sketch can be found in **File > Examples > Arduino_BHY2 > ShowSensorList** in the Arduino IDE.
195
195
196
-
In the following section you can see how these ID's are used in an Arduino sketch.
196
+
In the following section, you can see how these ID's are used in an Arduino sketch.
197
197
198
198
### Sensor Classes
199
199
200
200
-**Sensor**: This class handles all the other sensors which have a single value to be read, like temperature, gas, pressure, etc. And also the event sensors, like the step detector. This generic sensor class provides the sensor data through the `value` property.
201
-
-**SensorOrientation**: Use this class to handle sensors with the Euler format, used for example with orientation. It allows you to read the `pitch`, `roll` and `heading` property.
202
-
-**SensorXYZ**: This class handles sensors with the XYZ format, like the accelerometer and the gyroscope. Contains`x``y` and `z` values
201
+
-**SensorOrientation**: This class handles sensors with the Euler format, used for example with orientation. It allows you to read the `pitch`, `roll` and `heading` property.
202
+
-**SensorXYZ**: This class handles sensors with the XYZ format, like the accelerometer and the gyroscope. It contains`x``y` and `z` values
203
203
-**SensorQuaternion**: Can be used to handle sensors with the quaternion format, can be used to calculate rotation vector, game rotation vector and geomagnetic rotation vector. You can access the `x`, `y`, `z` and `w` property using this class.
204
204
-**SensorActivity**: Use this class to handle sensors with the activity format. The activity is encoded as ID and can be retrieved from the `value` property. Use `getActivity` to get a human readable version of the activity e.g. "Walking activity started".
205
205
-**SensorBSEC**: BSEC stands for Bosch Sensortec Environmental Cluster, basically you can access the air quality (IAQ) level and it contains the following data:
@@ -210,7 +210,7 @@ In the following section you can see how these ID's are used in an Arduino sketc
210
210
|`iaq_s()`| IAQ value for stationary use cases | unsigned 16bit |
The `begin()` function starts the sensor by calling the `configure()` with default parameters, making it easy to start and use on-board sensors. The parameters in the `configure()` function are, sample rate and latency. If specific parameters are needed then simply call `configure()` with your preferred values. E.g.: `configure(10, 1)`. In this case the sample rate would be set to `10 Hz` and the latency would be `1ms`.
337
+
The `begin()` function starts the sensor by calling the `configure()` with default parameters, making it easy to start and use on-board sensors. The parameters in the `configure()` function are sample rate and latency. If specific parameters are needed, then simply call `configure()` with your preferred values. E.g.: `configure(10, 1)`. In this case, the sample rate would be set to `10 Hz` and the latency would be `1ms`.
338
338
339
339
-**Sample rate** is used also to enable/disable the sensor. 0 to disable, > 0 to enable.
340
-
-**Latency** indicates how much ms time a new value is retained in its fifo before a notification to the host is sent via interrupt expressed in 24 bit
340
+
-**Latency** indicates how much ms time a new value is retained in its fifo before a notification to the host is sent via interrupt expressed in 24 bit.
341
341
342
342
Reading the sensor values:
343
343
@@ -372,7 +372,7 @@ short gyroZ = gyroscope.z();
372
372
373
373
#### Temperature
374
374
375
-
To read the temperature in standalone mode you also need to use the Arduino_BHY2 library as described in the section above.
375
+
To read the temperature in standalone mode, you also need to use the Arduino_BHY2 library as described in the section above.
376
376
377
377
Follow these steps to use the library to read the sensor values.
378
378
@@ -415,7 +415,7 @@ void loop(){
415
415
416
416
#### Gas
417
417
418
-
To get readings from the gas sensor in standalone mode you also need to use the Arduino_BHY2 library as described in the section above.
418
+
To get readings from the gas sensor in standalone mode, you also need to use the Arduino_BHY2 library as described in the section above.
419
419
420
420
Follow these steps to use the library to read the sensor values.
421
421
@@ -458,7 +458,7 @@ void loop(){
458
458
459
459
#### Pressure
460
460
461
-
To get readings from the pressure sensor in standalone mode you also need to use the Arduino_BHY2 library as described in the section above.
461
+
To get readings from the pressure sensor in standalone mode, you also need to use the Arduino_BHY2 library as described in the section above.
462
462
463
463
Follow these steps to use the library to read the sensor values.
464
464
@@ -500,7 +500,7 @@ void loop(){
500
500
```
501
501
#### Quaternion Rotation
502
502
503
-
To get readings from the IMU in a quaternion format in standalone mode you also need to use the Arduino_BHY2 library as described in the section above.
503
+
To get readings from the IMU in a quaternion format in standalone mode, you also need to use the Arduino_BHY2 library as described in the section above.
504
504
505
505
Follow these steps to use the library to read the sensor values.
506
506
@@ -543,7 +543,7 @@ void loop(){
543
543
544
544
#### Activity
545
545
546
-
To get activity status in standalone mode you also need to use the Arduino_BHY2 library as described in the section above.
546
+
To get activity status in standalone mode, you also need to use the Arduino_BHY2 library as described in the section above.
547
547
548
548
Follow these steps to use the library to read the sensor values.
549
549
@@ -586,7 +586,7 @@ void loop(){
586
586
587
587
#### BSEC Data
588
588
589
-
To get readings from the BME sensor in standalone mode you also need to use the Arduino_BHY2 library as described in the section above.
589
+
To get readings from the BME sensor in standalone mode, you also need to use the Arduino_BHY2 library as described in the section above.
590
590
591
591
Follow these steps to use the library to read the sensor values.
592
592
@@ -635,11 +635,11 @@ In order to transmit data over ESLOV to another Arduino board you need to connec
635
635
636
636

637
637
638
-
1. To have the Nicla Sense ME pass the sensor data through ESLOV you need to upload the **App** sketch. You can find it in the Examples menu in the IDE under **Arduino_BH2 > App**. After you upload the sketch you can disconnect the Nicla Sense ME from the USB cable. It can be powered through the ESLOV connection.
638
+
1. To have the Nicla Sense ME pass the sensor data through ESLOV, you need to upload the **App** sketch. You can find it in the Examples menu in the IDE under **Arduino_BH2 > App**. After you upload the sketch, you can disconnect the Nicla Sense ME from the USB cable. It can be powered through the ESLOV connection.
639
639
640
-
1. For the receiving device you need to upload the passthrough sketch. You can find it in the Examples menu in the IDE under **Arduino_BHY2Host > Passthrough**. After you upload the sketch a separate serial port will be exposed. One port is used for debugging and the other one is used for passing through the sensor data. The latter one is the one you will use for configuring the sensors and reading from them.
640
+
2. For the receiving device you need to upload the passthrough sketch. You can find it in the Examples menu in the IDE under **Arduino_BHY2Host > Passthrough**. After you upload the sketch, a separate serial port will be exposed. One port is used for debugging and the other one is used for passing through the sensor data. The latter one is the one you will use to configure the sensors and read from them.
641
641
642
-
3. When you're done uploading the sketches you can use the **bhy** script to interact with the sensors. In the downloaded package (see [here](#sensors)) navigate into the tools folder. There you will find binaries of the bhy tool for Linux and Windows. If you like you can build the tool yourself (e.g. if you're on macOS). For that, if you haven't installed **Go** yet, please do so by following [there](https://golang.org/doc/install) instructions.
642
+
3. When you're done uploading the sketches, you can use the **bhy** script to interact with the sensors. In the downloaded package (see [here](#sensors)), navigate into the tools folder. There you will find binaries of the bhy tool for Linux and Windows. If you like, you can build the tool yourself (e.g. if you are on macOS). For that, if you haven't installed **Go** yet, please do so by following [there](https://golang.org/doc/install) instructions.
643
643
From the terminal execute this command to start the build: `go build`
644
644
645
645
4. Use the bhy command as follows:
@@ -693,12 +693,12 @@ Sensor id: 10 name: GYRO_PASS values: x : -12.000000 y : 12.000000 z : -
693
693
Sensor id: 10 name: GYRO_PASS values: x : -13.000000 y : 12.000000 z : -10.000000
694
694
```
695
695
696
-
***If there is not ESLOV activity in the first minute after power up, the LDO is disabled and then also ESLOV is disabled. This has been made for low power reasons. However you could change this timeout by calling `BHY2.setLDOTimeout(milliSeconds)` from your sketch.***
696
+
***If there is not ESLOV activity in the first minute after power up, the LDO is disabled and then also ESLOV is disabled. This has been made for low power reasons. However, you could change this timeout by calling `BHY2.setLDOTimeout(milliSeconds)` from your sketch.***
697
697
698
698
### Sensor Data Over WebBLE
699
699
700
700
Sensor data from the Nicla Sense ME can also be retrieved through Bluetooth® Low Energy in the web browser. For that you can use the bhy tool. Please follow steps 1 - 3 from the "Sensor Data Over ESLOV" section. Then execute the following command to start the webserver: `./bhy webserver`.
701
-
When the server has started you can open the landing page in your browser: [http://localhost:8000/](http://localhost:8000/). Click on "Open sensor page".
701
+
When the server has started, you can open the landing page in your browser: [http://localhost:8000/](http://localhost:8000/). Click on "Open sensor page".
702
702
703
703

704
704
@@ -714,7 +714,7 @@ Use the sensor IDs from the section "Sensor IDs" to enable and configure the des
714
714
715
715
## BSX Sensor Fusion Software
716
716
717
-
The BHI260AP sensor runs a customizable firmware based on the BSX Sensor Fusion library. It provides a complete 9-axis fusion solution, which combines the measurements from 3-axis gyroscope, 3-axis geomagnetic sensor and a 3-axis accelerometer to provide a robust absolute orientation vector. The algorithm fuses the sensor raw data from the accelerometer, geomagnetic sensor and gyroscope in an intelligent way to improve each sensor’s output.
717
+
The BHI260AP sensor runs a customizable firmware based on the BSX Sensor Fusion library. It provides a complete 9-axis fusion solution, which combines the measurements from 3-axis gyroscope, 3-axis geomagnetic sensor and a 3-axis accelerometer, to provide a robust absolute orientation vector. The algorithm fuses the sensor raw data from the accelerometer, geomagnetic sensor and gyroscope in an intelligent way to improve each sensor’s output.
718
718
719
719
Go to this [site](https://www.bosch-sensortec.com/software-tools/software/sensor-fusion-software/) or take a look at the BHI260AP's [datasheet](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bhi260ap-ds000.pdf) for more information.
720
720
@@ -733,13 +733,13 @@ The pins used for SPI (Serial Peripheral Interface) on the Nicla Sense ME are th
733
733
734
734
You can refer to the [pinout](#pins) above to find them on the board.
735
735
736
-
To use SPI, we first need to include the [SPI](https://www.arduino.cc/en/reference/SPI) library.
736
+
To use SPI, you first need to include the [SPI](https://www.arduino.cc/en/reference/SPI) library.
737
737
738
738
```arduino
739
739
#include <SPI.h>
740
740
```
741
741
742
-
Inside `void setup()`we need to initialize the library.
742
+
Inside `void setup()`you need to initialize the library.
743
743
744
744
```arduino
745
745
SPI.begin();
@@ -766,19 +766,19 @@ The pins used for I2C (Inter-Integrated Circuit) on the Nicla Sense ME are the f
766
766
767
767
You can refer to the [pinout](#pins) above to find them on the board.
768
768
769
-
To use I2C, we can use the [Wire](https://www.arduino.cc/en/Reference/wire) library, which we need to include at the top of our sketch.
769
+
To use I2C, you can use the [Wire](https://www.arduino.cc/en/Reference/wire) library, which you need to include at the top of your sketch.
770
770
771
771
```arduino
772
772
#include <Wire.h>
773
773
```
774
774
775
-
Inside `void setup()`we need to initialize the library.
775
+
Inside `void setup()`you need to initialize the library.
776
776
777
777
```arduino
778
778
Wire.begin();
779
779
```
780
780
781
-
And to write something to a device connected via I2C, we can use the following commands:
781
+
And to write something to a device connected via I2C, you can use the following commands:
782
782
783
783
```arduino
784
784
Wire.beginTransmission(1); //begin transmit to device 1
@@ -796,13 +796,13 @@ The pins used for UART (Universal asynchronous receiver-transmitter) are the fol
796
796
797
797
You can refer to the pinout above to find them on the board.
798
798
799
-
To send and receive data through UART, we will first need to set the baud rate inside `void setup()`.
799
+
To send and receive data through UART, you will first need to set the baud rate inside `void setup()`.
800
800
801
801
```arduino
802
802
Serial1.begin(9600);
803
803
```
804
804
805
-
To read incoming data, we can use a while loop() to read each individual character and add it to a string.
805
+
To read incoming data, you can use a while loop() to read each individual character and add it to a string.
806
806
807
807
```arduino
808
808
while(Serial1.available()){
@@ -812,7 +812,7 @@ To read incoming data, we can use a while loop() to read each individual charact
812
812
}
813
813
```
814
814
815
-
And to write something, we can use the following command:
815
+
And to write something, you can use the following command:
816
816
817
817
```arduino
818
818
Serial1.write("Hello world!");
@@ -856,7 +856,7 @@ The parameters of `BHY2Host::begin` are: data pass through and communication con
856
856
857
857
#### Using the Bluetooth® Low Energy Library
858
858
859
-
To enable Bluetooth® Low Energy on the Nicla Sense ME, we can use the [ArduinoBLE](https://www.arduino.cc/en/Reference/ArduinoBLE) library. The example sketches included in the library work also with Nicla Sense ME with some minor modifications:
859
+
To enable Bluetooth® Low Energy on the Nicla Sense ME, you can use the [ArduinoBLE](https://www.arduino.cc/en/Reference/ArduinoBLE) library. The example sketches included in the library work also with Nicla Sense ME with some minor modifications:
860
860
861
861
Include the Nicla System header at the top of your sketch:
862
862
@@ -872,7 +872,7 @@ nicla::begin();
872
872
873
873
Here is an example of how to use the Bluetooth® Low Energy library to advertise a byte characteristic that can be used for example to toggle an LED.
874
874
875
-
Include the library header it at the top of our sketch:
875
+
Include the library header it at the top of your sketch:
876
876
877
877
```arduino
878
878
#include <ArduinoBLE.h>
@@ -906,4 +906,4 @@ BLEDevice central = BLE.central();
906
906
907
907
## Conclusion
908
908
909
-
This cheat sheet is written as a quick reference mainly to look up the features of this product. For a more in-depth walk though experience please have a look at the other tutorials.
909
+
This cheat sheet is written as a quick reference mainly to look up the features of this product. For a more in-depth walk though experience, please have a look at the other tutorials.
0 commit comments