Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bleak.exc.BleakError: Device with address D6:66:C1:A7:CF:0F was not found. #3

Closed
raspberrypieman opened this issue Sep 7, 2022 · 6 comments

Comments

@raspberrypieman
Copy link

I have installed Python 3.10.7 and pip installed kaspersmicrobit

I am running this code:

 import time
 from kaspersmicrobit import KaspersMicrobit
 CHANGE_THIS_TO_YOUR_MICROBIT_BLUETOOTH_ADDRESS = 'D6:66:C1:A7:CF:0F'
 def pressed(button):
     print(f"button {button} pressed")  
 with KaspersMicrobit(CHANGE_THIS_TO_YOUR_MICROBIT_BLUETOOTH_ADDRESS) as microbit:
     microbit.buttons.on_button_a(press=pressed)
     time.sleep(10)

and getting this error:

Traceback (most recent call last):
File "Y:\Source\Python_Python3_MyTools\Microbits\kaspers_microbit_test.py", line 14, in
with KaspersMicrobit(CHANGE_THIS_TO_YOUR_MICROBIT_BLUETOOTH_ADDRESS) as microbit:
File "C:\Users\Raspberry\AppData\Local\Programs\Python\Python310\lib\site-packages\kaspersmicrobit\kaspersmicrobit.py", line 103, in enter
self.connect()
File "C:\Users\Raspberry\AppData\Local\Programs\Python\Python310\lib\site-packages\kaspersmicrobit\kaspersmicrobit.py", line 120, in connect
self._device.connect()
File "C:\Users\Raspberry\AppData\Local\Programs\Python\Python310\lib\site-packages\kaspersmicrobit\bluetoothdevice.py", line 68, in connect
self.loop.run_async(self.client.connect()).result()
File "C:\Users\Raspberry\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 458, in result
return self.__get_result()
File "C:\Users\Raspberry\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 403, in __get_result
raise self._exception
File "C:\Users\Raspberry\AppData\Local\Programs\Python\Python310\lib\site-packages\bleak\backends\winrt\client.py", line 213, in connect
raise BleakError(
bleak.exc.BleakError: Device with address D6:66:C1:A7:CF:0F was not found.

I have tried to add a screen-shot below which should show that:
I can see in Windows Settings \ Bluetooth that my microbit (vatig) is paired but not connected.
and in More Bluetooth Options, in the Hardware tab / Details / Association Endpoint Address = d6: 66:c1:a7:cf:0f

I have downloaded the simple script to my V1 microbits, which looks like this in Javascript:

bluetooth.onBluetoothConnected(function () {
    basic.showString("C")
})
bluetooth.onBluetoothDisconnected(function () {
    basic.showString("X")
})
bluetooth.startButtonService()
bluetooth.startAccelerometerService()
bluetooth.startIOPinService()
bluetooth.startLEDService()
bluetooth.startTemperatureService()
basic.showLeds(`
    # . . # #
    # . . . #
    # # # . .
    # . # . .
    # # # . .
    `)

What else can I do to try to diagnose this problem - I have tried with 3 different v1 microbits ?

Regards,
Martyn
vatig_ethernet_addr

@janickr
Copy link
Owner

janickr commented Sep 7, 2022

Hi Martyn,

I'm afraid I will not be able to solve this issue 😞 . I only have one v1 micro:bit (I think it is a v1.5 actually) and it always gives me trouble on windows. In my case, whenever I pair it with windows, it will show the "C" on its led display. Is this also the case with your micro:bits? Besides trying to connect with kaspersmicrobit, I also failed connecting using bleak, and even failed with the windows runtime API.

You could try to connect directly with bleak, like this: bleak-device-info.py

Or scan for devices using bleak, like this: bleak-scan.py

But my guess is that connecting using bleak will give the same error, and that the scan will not find the micro:bits

Regards,
Janick

@raspberrypieman
Copy link
Author

Janick,
Thanks for your response.
I get no errors when pairing my micro:bits with Windows, just the expected tick on the LEDs when pairing complete.
I tried 'bleak-device-info.py' but got the same error message.
I also tried 'bleak-scan.py' and got a list of MAC addresses but none matched my micro:bits.

I have a few Linux boxes and Raspberry Pi's. I don't know if any have Bluetooth. If so I will try again under Linux.
Regards, Martyn

@janickr
Copy link
Owner

janickr commented Sep 7, 2022

Just out of curiosity: which version number do your micro:bits have?

Let me know if you can claim success on linux 🥇

@raspberrypieman
Copy link
Author

Janick,
All my micro:bits appear to be v1.3.
I could not achieve a bluetooth connection to any micro:bits from a Raspberry Pi4.
Will try with an Ubuntu system when I can find a suitable dongle.

@janickr
Copy link
Owner

janickr commented Mar 20, 2023

Hi Martyn,

I found out that my microbit v1.5 works in windows when use a hex file generated with the "No pairing required" setting and with the microbit removed from the paired devices in windows.

see also:
#4 (comment)

Maybe this works for your v1.3 microbits too.

Regards,
Janick

@janickr
Copy link
Owner

janickr commented Mar 26, 2023

Documentation site and hex files are updated to prefer "No pairing require" as this works for the micro:bit v1

Closing this issue for now.

@janickr janickr closed this as completed Mar 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants