How to send datas with BLE?

Hey guys,

It's my first post here, I'm a beginner in Arduino.

I have an Arduino Nano 33 IoT and I want to send a data of the accelerometer to my PC thanks to BLE.
I can read the data of the accelerometer on the serial monitor and now I want to see it on my other PC via BLE.

I don't know how to do, I took a look on the Exemples like BatteryMonitor or LED.

Can someone help me please?

Thanks a lot.
Biboxyf

Welcome to the forum.

I have some bad news for you. Think about it and let me know how you would like to proceed.

BLE was designed for low power small amounts of data. So, if you want to send a lot of data which an accelerometer can create you will find that difficult.

BLE is not well supported on Windows PCs. You can connect some simple BLE devices like keyboards and mouse, but all the interesting stuff happens on mobile devices and therefore BLE is much better supported there. You can find generic BLE apps on iOS and Android and some users have written Android apps for their own use.

If you want to learn about BLE and are happy with using a smart device instead of a PC, have a second look at the examples test them with an app. I use BLE Scanner on iPhone, and there are many others. Then try to modify them, post your code and we will point you in the right direction. There are examples in this sub forum and the two Arduino Nano 33 BLE sub forums as well.

If you really want accelerometer data on your PC, you have two options. First use WiFi it is well supported by the Arduino Nano 33 IoT and TCP/IP is well supported on PC. You just need to find a data protocol you can use on your PC and on the Arduino. The second option is to convert your Arduino Nano 33 IoT to use Bluetooth Classic. There are some users in this forum that have done that. I can point you to the post.

Hey Klaus_K, thanks for the answer.

I tried an app on Android that can read and write on Arduino (LightBlue) and I tried it with the exemple BatteryMonitor. It works very well.

On my PC, I tried Bluetooth LE Explorer but there is a problem during the connexion. The Arduino connect and disconnect a few seconds later so it's impossible to connect Arduino and PC. I don't know how to do...

It's a school project and my teacher wants to see datas on PC and not on phone... If someone has the answer...

Thanks.
Biboxyf

biboxyf:
On my PC, I tried Bluetooth LE Explorer but there is a problem during the connexion. The Arduino connect and disconnect a few seconds later so it's impossible to connect Arduino and PC. I don't know how to do...

Yes, I played with the Bluetooth LE Explorer a while ago and had the same issues. One of the potential issues is that the ArduinoBLE library does not support pairing. Pairing is a optional feature in BLE and usually not needed. In BLE you can simply connect. But the Bluetooth LE Explorer likely requires pairing.
I have talked to a few others on this forum over month and nobody could point me to a solution for Windows.

biboxyf:
It's a school project and my teacher wants to see datas on PC and not on phone... If someone has the answer...

Your teacher can want a lot but unless he has a solution he is asking too much. So, ask him whether he has a solution and can point you in the right direction. He does not need to give you the solution, but he should have tried himself. Say Hello from me. We would love to hear about a way to use native BLE on Windows PCs.

One option could be to use two Arduinos one connected to the PC as a Bluetooth Central sending the data to the PC via the Serial COM over USB and one collecting the data. They can then talk to each other over BLE. Ask your teacher if that is OK.

Thanks for the answer Klaus_K.

I talked to my teacher and he understood. Now, I can forget the PC part and send datas only on my Phone.

It's not easy to understand when we start

biboxyf:
Now, I can forget the PC part and send datas only on my Phone.

Good news. Start writing some code based on the library examples and if you have any questions let me know.

Hi, sorry to read that know, because I wish I proposed you my code: here is a simple example I built form parts of "LSM6DS3" library and "NINA wifi" library examples provided by Arduino IDE.

Begin with a try to "Arduino_LSM6DS3 -> SimpleAccelerometer" . It display real-time value on 3 axis on serial monitor (use your 33 IOT USB-plugged to your PC and Ctrl + Maj + M or Ctrl + Maj + L).

Then try the "WIFININA -> WifiWebServer". with a wi-fi available (and a login/pass), you can access with any web explorer (I use Chrome on my Win10 PC) to the dedicated IP of your 33 IOT, and so read the data it is sending (floatting analogic pin measurment in the example).
It is a good thing to test your ability to get a proper access to wi-fi with your board before next point.

Now it is time to merge the two codes!

attached is the code (AccelWebServer_2.ino), storing the last 50 "z" axis values (acceleration in vertical direction) recorded.

and then the resulting display (on Chrome), see Capture Acceler.PNG attached.

AccelWebServer_2.ino (6.03 KB)