Skip to main content
Visitor II
February 28, 2024
Question

Can't connect the SensorTile with Raspberry pi

  • February 28, 2024
  • 1 reply
  • 1863 views

Hi,

I want connect my SensorTile box with my Raspberry pi. For this, I use example_ble_1.py, but every time when i try to connect the devices then one of the given errors occur:

guest@raspberrypi:~ $ sudo python3 example_ble_1.py

##################

BlueST Example

##################

Scanning Bluetooth devices...

Discovery started.
New device discovered: TB2 .
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/blue_st_sdk/manager.py", line 313, in discover
self._scanner.scan(timeout_s)
File "/usr/local/lib/python3.9/dist-packages/bluepy/btle.py", line 854, in scan
self.stop()
File "/usr/local/lib/python3.9/dist-packages/bluepy/btle.py", line 803, in stop
self._mgmtCmd(self._cmd()+"end")
File "/usr/local/lib/python3.9/dist-packages/bluepy/btle.py", line 309, in _mgmtCmd
rsp = self._waitResp('mgmt')
File "/usr/local/lib/python3.9/dist-packages/bluepy/btle.py", line 362, in _waitResp
raise BTLEDisconnectError("Device disconnected", resp)
bluepy.btle.BTLEDisconnectError: Device disconnected

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/guest/example_ble_1.py", line 312, in
main(sys.argv[1:])
File "/home/guest/example_ble_1.py", line 189, in main
manager.discover(SCANNING_TIME_s)
File "/usr/local/lib/python3.9/dist-packages/blue_st_sdk/manager.py", line 325, in discover
raise BlueSTInvalidOperationException(msg)
blue_st_sdk.utils.blue_st_exceptions.BlueSTInvalidOperationException:
Bluetooth scanning requires root privilege, so please run the script with "sudo".

guest@raspberrypi:~ $ sudo python3 example_ble_1.py

##################

BlueST Example

##################

Scanning Bluetooth devices...

Discovery started.
New device discovered: TB2 .
Discovery stopped.

Available Bluetooth devices:

  1. TB2 : [c0:50:06:32:19:33]

Select a device to connect to ('0' to quit): 1
Connecting to TB2 ...
Device TB2 disconnected unexpectedly.

Exiting...

Accelerometers

 
    This topic has been closed for replies.

    1 reply

    Technical Moderator
    February 29, 2024

    Hi @Milan127 ,

    Welcome to ST Community!

    The python implementation of BlueST protocol (BlueST SDK) uses the bluepy BLE stack.

    Due to this, one of the limitations of bluepy is that when running a discovery process the already connected devices get disconnected.

    You can read about this here: BlueSTSDK_Python

    I can suggest you to first disconnect the device and then try to connect to it and see if this mitigates the intrinsic bluepy issue.

    Milan127Author
    Visitor II
    February 29, 2024

    Hi @Federica Bossi,

    I don't really get it, how can I disconnect the SensorTilebox when I can't even connect in the first place? Might it be someting else that can cause this problem?

     

    Milan127Author
    Visitor II
    March 1, 2024

    The Sensortile that I am using is the STEVAL-MKSBOX1V1.