Auto connect BLE

Hi all,
I would like to write a program to auto connect the Ble. I had gone through connect address but had find that it is for Bluetooth client extension and there is no option for Ble extension. Is there any way that i can connect to ble .

Hi Femilda,

  • First you have to connect your device once, to find out its address.
  • You then store the address in a TinyDB. I used the tag "microbit", but of course you can use anything you like.
  • If you start your app, find out if the address is stored, and if yes, use connect with address, like this:
  • The next time you start your app, you will find the address in the TinyDB and you can connect like this:

    Of course your BLE device should be turned on and within range.

Use the BLE extension shown in Anke's post.
If you need guidance on connecting BLE, use this tutorial: The Internet of Things: Data Acquisition and Analysis
or more precise, follow the tutorial described in the link here : 0_Preparation_Teacher Guide_L2IoT1_Internet of Things_20220901.docx - Google Docs
The tutorial is for micro:bits, but for other BLE devices the procedure will be similar.
The tutorial has a slightly older BLE extension that will give problems on newer phones, but if you exchange it with the one indicated by Anke, you should be fine, at least I was.

1 Like


I'm getting error like this while auto reconnecting. I have also tried to reconnect with connect with address then also not connecting.


I have tried to implement the same but still finds error to connect..

grafik

Thank you for the guidance, I'm able to reconnect.

the code had worked for couple of times and then it again Stucks and I can't connect again with ble I'm attaching the code.

Is the Location sensor enabled?

yes

Where is this procedure used? Clock1.Timer event?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.