Connecting BLE Sense to the PC

Hello Community!!!

I just got my ble sense, I tried connecting it to the pc via a classic bluetooth, then learned later, ble doesn't support the classic devices, and I am not sure about how to connect the ble sense to my pc.

I want to take the accelerometer readings while running, so in a need to connect it to the pc. Does any one know how to connect it to a pc via ble.

I learned that I should include ble.h files, to call the adruino but how do I upload it to the ble sense arduino? without a usb cable?

It would be really great if someone could help me. Thank you.

Regards
Jing ze

Bluetooth Classic and Bluetooth LE are two different things. They are not compatible.

First you need to find out whether your PC supports BLE.

In BLE you do not need to pair. Pairing is an optional security feature currently not supported by the Arduino BLE library. This is usually done trough the OS.

You should be able to connect to your BLE device from your application. BLE has been designed to connect, get the data and disconnect to allow very low power applications.

I do not think there is a update over the air support available.

What application do you want to use to connect to your Arduino over BLE?

My PC supports BLE.

So if I dont have to pair the BLE sense is it that including the "ble.h" function, will connect the pc's ble to the ble sense directly.

I have seen a video where they have connected ble to computer, but I am not sure how they did it.

https://create.arduino.cc/projecthub/whatsupdog/the-muttmentor-9d9753?ref=part&ref_id=107215&offset=0

The link above is where I have found that they have connected through ble that I have mentioned.

I am not able to get what do you mean by "application that I want to connect to my arduino". I am new to arduino, just learning

Jing ze

Jingze_Gu:
I am new to arduino, just learning

OK. Here is what I recommend you should do.

Install the Arduino BLE library for the Arduino Nano 33 BLE using the Tools -> Manage Libraries

Look at the examples. File -> Examples -> ArduinoBLE

There are two categories

  • Central
  • Peripheral

Start with the Peripheral and load the LED example. Get an application for your smartphone that supports BLE. I use BLE Scanner 4.0 on the iPhone (its free and from Bluepixel Technologies). Connect to your Arduino LED and look at your source code and the data the app provides.

The sketch does the following, its creates a structure called GATT which holds the data and then starts advertising. Anyone can detect these advertisements, connect to the Arduino and read the GATT. The Arduino code decides which data has read or write access.

If you like an example for other types of data e.g. accelerometer have a look at the following post. In post #11 you can find a test sketch I have written that also includes this.

https://forum.arduino.cc/index.php?topic=659562.0

Regarding the application. If you want to read the data that the Arduino provides using the GATT you will need a program that connects to the Arduino and reads the data, just like the app on the smartphone.

If you have two Arduino Nano 33 BLE you can use the LEDControl example from the Central subfolder. The Central device is doing exactly the same thing as the smartphone app.

I did some ground work.

But I dont want it to connect it to a phone application. I want to connect it directly to the bluetooth in the computer.

(Like uploading a program in the nano arduino with the help of hc 05 which uploads the program via bluetooth and it shows the output. )

So I want to connect it directly to the computer, so could you help me get values via a bluetooth. without a cord to the arduino nano 33 ble sense

Thanks
Jing ze

During development the software can only be programmed into the Arduino Nano BLE Sense via the USB cable. There is no update over the air support (OTA) in the bootloader.

For your application you can read and write data from any platform that supports BLE.

Thank you for the reply.

Is there a possiblity after uploading the program and then disconnectiing the cord and connecting with the battery can I read the data?

with the program that I have already uploaded. I tried but I dint have any good output.

Sincerely
Jing ze

Please post your code. Use code tags. Click Preview in the Quick reply and click the </> button. It should looks like this.

Example code

What program do you use to read the data and which platform (e.g. iPhone)?

Klaus_K:
Please post your code. Use code tags. Click Preview in the Quick reply and click the </> button. It should looks like this.

Example code

What program do you use to read the data and which platform (e.g. iPhone)?

#include <ArduinoBLE.h>
#include <Arduino_LSM9DS1.h>

int accelX=1;
int accelY=1;
float x, y, z;

BLEService customService("1101");
BLEUnsignedIntCharacteristic customXChar("2101", BLERead | BLENotify);
BLEUnsignedIntCharacteristic customYChar("2102", BLERead | BLENotify);

void setup() {
IMU.begin();
Serial.begin(9600); 
while (!Serial);

pinMode(LED_BUILTIN, OUTPUT);

if (!BLE.begin()) {
Serial.println("BLE failed to Initiate");
delay(500);
while (1);
}

BLE.setLocalName("Arduino Accelerometer");
BLE.setAdvertisedService(customService);
customService.addCharacteristic(customXChar);
customService.addCharacteristic(customYChar);
BLE.addService(customService);
customXChar.writeValue(accelX);
customYChar.writeValue(accelY);

BLE.advertise();

Serial.println("Bluetooth device is now active, waiting for connections...");
}


void loop() {

BLEDevice central = BLE.central();
if (central) {
Serial.print("Connected to central: ");
Serial.println(central.address());
digitalWrite(LED_BUILTIN, HIGH);
while (central.connected()) {
delay(200);
read_Accel();

customXChar.writeValue(accelX);
customYChar.writeValue(accelY);

Serial.print("At Main Function");
Serial.println("");
Serial.print(accelX);
Serial.print(" - ");
Serial.println(accelY);
Serial.println("");
Serial.println("");
}
}
digitalWrite(LED_BUILTIN, LOW);
Serial.print("Disconnected from central: ");
Serial.println(central.address());
}

void read_Accel() {

if (IMU.accelerationAvailable()) {
IMU.readAcceleration(x, y, z);
accelX = (1+x)*100;
accelY = (1+y)*100;

}
}

I am trying to connect to the nearby desktop(platform) through the ble

Jing ze

I tested the sketch with my phone and could see the data updating live.

If you want to use a program on a PC you will need to look for one that does not require pairing. I tested the Microsoft Bluetooth Explorer. I could see the Arduino but the program requires pairing for data display and that does not work.

1 Like