Hello,
I cannot get a stable BLE connection to Nicla Voice.
Trying with the example above in the Bluetooth communication section, connecting with iOS/iPadOS/macOS we always get the same anomalous behavior:
The connection is made and a few moments later (ranging from a few hundred ms up to a few seconds) the connection is closed by the board.
The app we use to test the connection is nrfConnect (but we also tried with our own swift iOS/macOS/iPadOS app that I could share for testing). NrfConnect stays in a spinning "Connecting" state.
On macOS I was able to connect only once after flashing, then after restart the app always this strange
behaviour.
This is the official example in the Bluetooth® Low Energy section.
https://docs.arduino.cc/tutorials/nicla-voice/user-manual/
#include "Nicla_System.h"
#include <ArduinoBLE.h>
// Define the voltage service and its characteristic
BLEService voltageService("1101");
BLEUnsignedCharCharacteristic voltageLevelChar("2101", BLERead | BLENotify);
const int analogPin = A0;
/**
Read voltage level from an analog input of the Nicla Voice,
then maps the voltage reading to a percentage value ranging from 0 to 100.
@param none
@return the voltage level percentage (int).
*/
int readVoltageLevel() {
int voltage = analogRead(analogPin);
int voltageLevel = map(voltage, 0, 1023, 0, 100);
return voltageLevel;
}
void setup() {
// Initialize the Nicla system and the built-in RGB LED
nicla::begin();
nicla::leds.begin();
Serial.begin(9600);
// Wait for the serial connection to be established
while (!Serial)
;
// Initialize the BLE module
if (!BLE.begin()) {
Serial.println("starting BLE failed!");
while (1)
;
}
// Set the local name and advertised service for the BLE module
BLE.setLocalName("VoltageMonitor");
BLE.setAdvertisedService(voltageService);
voltageService.addCharacteristic(voltageLevelChar);
BLE.addService(voltageService);
// Start advertising the BLE service
BLE.advertise();
Serial.println("- Bluetooth device active, waiting for connections...");
}
void loop() {
// Check for incoming BLE connections
BLEDevice central = BLE.central();
// If a central device is connected
if (central) {
Serial.print("- Connected to central: ");
Serial.println(central.address());
// Turn off the LED when disconnected
nicla::leds.setColor(blue);
// While the central device is connected
while (central.connected()) {
// Read the voltage level and update the BLE characteristic with the level value
int voltageLevel = readVoltageLevel();
Serial.print("- Voltage level is: ");
Serial.println(voltageLevel);
voltageLevelChar.writeValue(voltageLevel);
delay(200);
}
}
// Turn off the LED when disconnected
nicla::leds.setColor(red);
Serial.print("- Disconnected from central: ");
Serial.println(central.address());
}```
While trying to connect with NRFConnect the serial Nicla output is
- Voltage level is: 2
- Voltage level is: 0
- Disconnected from central: 4d:4e:61:02:52:89
- Disconnected from central: 00:00:00:00:00:00
- Disconnected from central: 00:00:00:00:00:00
- Connected to central: 4d:4e:61:02:52:89
- Voltage level is: 3
- Voltage level is: 3
- Voltage level is: 1
- Voltage level is: 0
- Voltage level is: 0
- Disconnected from central: 4d:4e:61:02:52:89
- Disconnected from central: 00:00:00:00:00:00
- Disconnected from central: 00:00:00:00:00:00
- Disconnected from central: 00:00:00:00:00:00
- Disconnected from central: 00:00:00:00:00:00
- Disconnected from central: 00:00:00:00:00:00
- Disconnected from central: 00:00:00:00:00:00
- Connected to central: 4d:4e:61:02:52:89
- Voltage level is: 0
- Voltage level is: 3
- Voltage level is: 4
- Voltage level is: 1
- Voltage level is: 0
- Disconnected from central: 4d:4e:61:02:52:89
- Disconnected from central: 00:00:00:00:00:00
- Disconnected from central: 00:00:00:00:00:00
- Connected to central: 4d:4e:61:02:5
Versions:
macOS: 15.4.1 (24E263)
iOS: 18.4.1
Arduino IDE: 15.4.1 (24E263)
CLI Version 1.2.0
ArduinoBLE: 1.4.0
Core: Arduino Mbed OS Nicla Boards 4.2.4
Steps to reproduce:
- Get a brand new Nicla Voice
- Follow NDP120 Processor Firmware Update (from Nicla Voice User Manual) https://docs.arduino.cc/tutorials/nicla-voice/user-manual/#software-requirements
- Upload the sketch found here: https://docs.arduino.cc/tutorials/nicla-voice/user-manual/#bluetooth-low-energy
- Download and install on iPhone nRF Connect for Mobile from Appstore
- Open nRF Connect and tap VoltageMonitor
Behaviour:
- nrfConnect will stay in a spinning "Connecting" state
- if you open the serial monitor on Arduino IDE you will notice the board printing continuously
Connected to central:
some voltage values
Disconnected from
Without having a really stable and working connection.