I just bought the Nano 33 BLE but I have a problem getting the board connected to Windows 10.
I modified the example sketch LED so that I could just check the connection.
The full code is attached below.
When I try to connect to the board from Windows, I can find it with the set local name "LED" from the "Add Device" window.
While Windows is stuck on "connecting...." the serial says that central is connected.
Eventually Windows fails to connect and says try connecting again.
After that, even when I don't click on "LED" from "Add a Device", the loop on the board connects and disconnects constantly.
Can anyone tell me how to make a firm connection to Windows?
#include <ArduinoBLE.h>
BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service
// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);
const int ledPin = LED_BUILTIN; // pin to use for the LED
void setup() {
Serial.begin(9600);
// set LED pin to output mode
pinMode(ledPin, OUTPUT);
// begin initialization
if (!BLE.begin()) {
Serial.println("starting BLE failed!");
while (1);
}
// set advertised local name and service UUID:
BLE.setLocalName("LED");
BLE.setAdvertisedService(ledService);
// add service
BLE.addService(ledService);
// start advertising
BLE.advertise();
Serial.println("BLE LED Peripheral");
}
void loop() {
// listen for BLE peripherals to connect:
BLEDevice central = BLE.central();
// if a central is connected to peripheral:
if (central) {
Serial.print("Connected to central: ");
// print the central's MAC address:
Serial.println(central.address());
// while the central is still connected to peripheral:
while (central.connected()) {
}
// when the central disconnects, print it out:
Serial.print(F("Disconnected from central: "));
Serial.println(central.address());
}
}
What you are trying to do is likely pairing, even if Windows says connecting. Pairing is an optional security feature of BLE and currently not supported by the ArduinoBLE library. You will see the same thing on a smartphone.
You do not connect via the OS but from the app/program. I suspect this will be the same for Windows. I have not found a Windows BLE app that does connect only. Microsoft Bluetooth LE Explorer try's to "Discover and Pair" which will fail, even though it will show you the Arduino during scanning.
Do you have a Bluetooth LE app for Windows?
Try using a smartphone. I use BLE Scanner from bluepixel technologies. Its free on the iPhone. There are a few others, but I like that one the best.
I have tried the smartphone connection with your suggestion and succeeded. There were some desktop BLE applications but they did not work. Thanks anyways.
First, Please install the BLE library(IDE-> Sketch->Include library->Manage Libraries->BLE) and then, open the LED sketch under the Peripheral folder.
(File->Examples->ArduinoBLE->Peripheral->LED)
Install the nRF connect app on the mobile.
Upload the BLE sketch
Open the serial monitor
Follow the commands as per in the attachments
Pass values 0 and 1 to UINT 8 to turn on and turn off your board LED and you can see the output in the serial monitor too
I can subscribe to services from iPhone and Mac OSX, but as @Klaus_K mentions, there doesn't seem to be a Windows 10 app that lets you just subscribe to a service without pairing.
To add to my question from yesterday, running this web dashboard easily connects on OSX but never finds the device on Windows 10. Arduino Nano BLE Sense - Web BLE test
Has anyone successfully tested this on Windows 10?
I think Klaus has nailed it. I have been having similar problems and fundamentally it comes down to the Windows 10 BLE implementation does not like the Nano BLE (well the library basically) in its current form.
I have tried:
iOS apps including hand coded ones -> Works fine
MacOSX apps, Matlab and handcoded -> Works fine
Linux using Gatttool and the BlueZ libraries -> Works fine
Windows 10 including BluetoothLE, direct to the UWP libraries, Matlab, etc. -> Nothing works.
I managed to get Matlab to talk to the NANO once and read a characteristic. But this was on a completely new machine that had never seen a Nano before. After that - nada.
Everything I have come across points to the Win 10 trying to pair and refusing to connect if it can't. I think that the first time I tried with a windows machine it managed to connect but then windows remembered the device whereas the Nano did not and so it fell over ever after. I could try a completely fresh Win10 install but I haven't the time to wipe a machine to do that.
Looks like this won't be solved until the BLE library is updated to accept the Win 10 pair request.
Just to add, this issue really should sit in the ArduinoBLE library on Github but I can see that the library is not being actively developed by anyone.