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
To enable Bluetooth® Low Energy communication on the Nicla Voice, you can use the [ArduinoBLE library](https://www.arduino.cc/reference/en/libraries/arduinoble/). The library works with the Nicla Voice with some minor modifications.
1329
-
1330
-
To get started with the ArduinoBLE library and the Nicla Voice, follow these steps:
1331
-
1332
-
Include the `Nicla System` header:
1333
-
1334
-
```arduino
1335
-
#include "Nicla_System.h"
1336
-
```
1337
-
1338
-
In the `setup()` function, call `nicla::begin()` to initialize the Nicla Voice board:
1339
-
1340
-
```arduino
1341
-
void setup() {
1342
-
nicla::begin();
1343
-
}
1344
-
```
1328
+
To enable Bluetooth® Low Energy communication on the Nicla Voice, you can use the [ArduinoBLE library](https://www.arduino.cc/reference/en/libraries/arduinoble/).
1345
1329
1346
1330
Here is an example of how to use the ArduinoBLE library to create a voltage level monitor application:
1347
1331
1348
1332
```arduino
1349
1333
#include "Nicla_System.h"
1350
1334
#include <ArduinoBLE.h>
1351
1335
1336
+
1352
1337
// Define the voltage service and its characteristic
Serial.println("- Bluetooth device active, waiting for connections...");
1397
1390
}
1398
1391
1392
+
1399
1393
void loop() {
1400
-
// Check for incoming BLE connections
1401
-
BLEDevice central = BLE.central();
1394
+
// Check for incoming BLE connections
1395
+
BLEDevice central = BLE.central();
1402
1396
1403
-
// If a central device is connected
1404
-
if (central) {
1405
-
Serial.print("- Connected to central: ");
1406
-
Serial.println(central.address());
1407
1397
1408
-
// Set the LED color to red when connected
1409
-
nicla::leds.setColor(red);
1398
+
// If a central device is connected
1399
+
if (central) {
1400
+
Serial.print("- Connected to central: ");
1401
+
Serial.println(central.address());
1410
1402
1411
-
// While the central device is connected
1412
-
while (central.connected()) {
1413
-
// Read the voltage level and update the BLE characteristic with the level value
1414
-
int voltageLevel = readVoltageLevel();
1415
1403
1416
-
Serial.print("- Voltage level is: ");
1417
-
Serial.println(voltageLevel);
1418
-
voltageLevelChar.writeValue(voltageLevel);
1404
+
// Turn off the LED when disconnected
1405
+
nicla::leds.setColor(blue);
1419
1406
1420
-
delay(200);
1421
-
}
1422
-
}
1423
1407
1424
-
// Turn off the LED when disconnected
1425
-
nicla::leds.setColor(off);
1408
+
// While the central device is connected
1409
+
while (central.connected()) {
1410
+
// Read the voltage level and update the BLE characteristic with the level value
1411
+
int voltageLevel = readVoltageLevel();
1412
+
1413
+
1414
+
Serial.print("- Voltage level is: ");
1415
+
Serial.println(voltageLevel);
1416
+
voltageLevelChar.writeValue(voltageLevel);
1426
1417
1427
-
Serial.print("- Disconnected from central: ");
1428
-
Serial.println(central.address());
1418
+
1419
+
delay(200);
1420
+
}
1421
+
}
1422
+
1423
+
1424
+
// Turn off the LED when disconnected
1425
+
nicla::leds.setColor(red);
1426
+
1427
+
1428
+
Serial.print("- Disconnected from central: ");
1429
+
Serial.println(central.address());
1429
1430
}
1430
1431
```
1431
1432
1432
-
The example code shown above creates a Bluetooth® Low Energy service and characteristic for transmitting a voltage value read by one of the analog pins of the Nicla Voice to a central device.
1433
+
The example code shown above creates a Bluetooth® Low Energy service and characteristic for transmitting a voltage value read by the analog pin A0 of the Nicla Voice to a central device Bluetooth® device like a smartphone or another microcontroller.
1433
1434
1434
-
- The code begins by importing all the necessary libraries and defining the Bluetooth® Low Energy service and characteristic.
1435
+
- The code begins by importing all the necessary libraries and defining the Bluetooth® Low Energy service and characteristics.
1435
1436
- In the `setup()` function, the code initializes the Nicla Voice board and sets up the Bluetooth® Low Energy service and characteristic; then, it begins advertising the defined Bluetooth® Low Energy service.
1436
-
- A Bluetooth® Low Energy connection is constantly verified in the `loop()` function; when a central device connects to the Nicla Voice, its built-in LED is turned on (red). The code then enters into a loop that constantly reads the voltage level from an analog input and maps it to a percentage value between 0 and 100. The voltage level is printed to the Serial Monitor and transmitted to the central device over the defined Bluetooth® Low Energy characteristic.
1437
+
- A Bluetooth® Low Energy connection is constantly verified in the `loop()` function, being the built-in LED in red while looking for a connection. When a central device connects to the Nicla Voice, its built-in LED will change its color to blue. The code then enters into a loop that constantly reads the voltage level from an analog input and maps it to a percentage value between 0 and 100. The voltage level is printed to the Serial Monitor and transmitted to the central device over the defined Bluetooth® Low Energy characteristic.
1438
+
1439
+
You can use the [nRF Connect for Mobile](https://www.nordicsemi.com/Products/Development-tools/nrf-connect-for-mobile) app from Nordic Semiconductor to test the functionality of the example code shown below. nRF Connect is a powerful tool that allows you to scan and explore Bluetooth® Low Energy devices and communicate with them.
1440
+
1441
+
1442
+

1443
+
1437
1444
1438
1445
### ESLOV Connector
1439
1446
1440
1447
The Nicla Voice board features an onboard ESLOV connector meant as an **extension** of the I2C communication bus. This connector simplifies connecting various sensors, actuators, and other modules to the Nicla Voice without soldering or wiring.
The ESLOV connector is a small 5-pin connector with a 1.00 mm pitch; the mechanical details of the connector can be found in the connector's datasheet.
1445
1453
1446
1454
The pin layout of the ESLOV connector is the following:
@@ -1473,4 +1481,4 @@ Join our community forum to connect with other Nicla Voice users, share your exp
1473
1481
1474
1482
Please get in touch with our support team if you need personalized assistance or have questions not covered by the help and support resources described before. We're happy to help you with any issues or inquiries about the Nicla Voice.
1475
1483
1476
-
- [Contact us page](https://www.arduino.cc/en/contact-us/)
1484
+
- [Contact us page](https://www.arduino.cc/en/contact-us/)
0 commit comments