Closed Svein-Tore closed 2 years ago
The short answer is no. ubit.text
command is writing to the LED SERVICE
- LED Text
characteristic where as the on data reeceived command in makecode is working on the UART SERVICE
- TX Characteristic
. More details in:
https://lancaster-university.github.io/microbit-docs/resources/bluetooth/bluetooth_profile.html
The ubit.uart
command is probably what you are looking for. There is an example of its use in:
https://github.com/ukBaz/python-bluezero/blob/main/examples/microbit_uart.py
If you don't want to receive messages from the UART then you do not need to do the ubit.run_async()
functionality. So the https://github.com/ukBaz/python-bluezero/blob/main/examples/microbit_poll.py might be the better example with ubit.text
replaced with ubit.uart
.
Let me know if I've not explained that very well.
Hi Barry!
I've been on your workshop (https://ukbaz.github.io/howto/ubit_workshop.html) and there I found this program:
rom bluezero import microbit ubit = microbit.Microbit(adapter_addr='xx:xx:xx:xx:xx:xx', device_addr='yy:yy:yy:yy:yy:yy') my_text = 'Hello, world' ubit.connect() while my_text is not '': ubit.text = my_text my_text = input('Enter message: ')
ubit.disconnect()
You wrote in your email that
So the https://github.com/ukBaz/python-bluezero/blob/main/examples/microbit_poll.py might be the better example with ubit.text replaced with ubit.uart. So I wonder, If I change the line
ubit.text=my_text
in the program above with ubit.uart
Will it work (be able to get my_text in bluetooth on data received)?
Best wishes, Svein-Tore
fre. 4. mar. 2022 kl. 13:00 skrev Barry Byford @.***>:
The short answer is no. ubit.text command is writing to the LED SERVICE - LED Text characteristic where as the on data reeceived command in makecode is working on the UART SERVICE - TX Characteristic. More details in:
https://lancaster-university.github.io/microbit-docs/resources/bluetooth/bluetooth_profile.html
The ubit.uart command is probably what you are looking for. There is an example of its use in:
https://github.com/ukBaz/python-bluezero/blob/main/examples/microbit_uart.py
If you don't want to receive messages from the UART then you do not need to do the ubit.run_async() functionality. So the https://github.com/ukBaz/python-bluezero/blob/main/examples/microbit_poll.py might be the better example with ubit.text replaced with ubit.uart.
Let me know if I've not explained that very well.
— Reply to this email directly, view it on GitHub https://github.com/ukBaz/python-bluezero/issues/363#issuecomment-1059101072, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD563NQQWW6PRS5TFJTGNBLU6H3OBANCNFSM5P5BKO4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
Hi Barry!
After doing some testing I got it work!
Best wishes, Sve\in-Tore
lør. 5. mar. 2022 kl. 13:32 skrev Svein-Tore Narvestad @.***>:
Hi Barry!
I've been on your workshop ( https://ukbaz.github.io/howto/ubit_workshop.html) and there I found this program:
rom bluezero import microbit ubit = microbit.Microbit(adapter_addr='xx:xx:xx:xx:xx:xx', device_addr='yy:yy:yy:yy:yy:yy') my_text = 'Hello, world' ubit.connect() while my_text is not '': ubit.text = my_text my_text = input('Enter message: ')
ubit.disconnect()
You wrote in your email that
So the https://github.com/ukBaz/python-bluezero/blob/main/examples/microbit_poll.py might be the better example with ubit.text replaced with ubit.uart. So I wonder, If I change the line
ubit.text=my_text
in the program above with ubit.uart
Will it work (be able to get my_text in bluetooth on data received)?
Best wishes, Svein-Tore
fre. 4. mar. 2022 kl. 13:00 skrev Barry Byford @.***>:
The short answer is no. ubit.text command is writing to the LED SERVICE
- LED Text characteristic where as the on data reeceived command in makecode is working on the UART SERVICE - TX Characteristic. More details in:
https://lancaster-university.github.io/microbit-docs/resources/bluetooth/bluetooth_profile.html
The ubit.uart command is probably what you are looking for. There is an example of its use in:
https://github.com/ukBaz/python-bluezero/blob/main/examples/microbit_uart.py
If you don't want to receive messages from the UART then you do not need to do the ubit.run_async() functionality. So the https://github.com/ukBaz/python-bluezero/blob/main/examples/microbit_poll.py might be the better example with ubit.text replaced with ubit.uart.
Let me know if I've not explained that very well.
— Reply to this email directly, view it on GitHub https://github.com/ukBaz/python-bluezero/issues/363#issuecomment-1059101072, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD563NQQWW6PRS5TFJTGNBLU6H3OBANCNFSM5P5BKO4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
Well done on getting it working. Sounds like this issue is resolved so I'll go ahead and close it. Please re-open if it is not resolved.
Thanks!
søn. 6. mar. 2022, 07:27 skrev Barry Byford @.***>:
Well done on getting it working. Sounds like this issue is resolved so I'll go ahead and close it. Please re-open if it is not resolved.
— Reply to this email directly, view it on GitHub https://github.com/ukBaz/python-bluezero/issues/363#issuecomment-1059904232, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD563NXWOCR4OESTWGBU6M3U6RF6LANCNFSM5P5BKO4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
HI Barry!
Si I went into trouble. I now get the following error:
@.***:~/.local/bin $ python3 testing_Micorbit.py
Traceback (most recent call last):
File "/home/pi/.local/bin/testing_Micorbit.py", line 5, in
Any suggestion?
søn. 6. mar. 2022 kl. 09:03 skrev Svein-Tore Narvestad @.***>:
Thanks!
søn. 6. mar. 2022, 07:27 skrev Barry Byford @.***>:
Well done on getting it working. Sounds like this issue is resolved so I'll go ahead and close it. Please re-open if it is not resolved.
— Reply to this email directly, view it on GitHub https://github.com/ukBaz/python-bluezero/issues/363#issuecomment-1059904232, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD563NXWOCR4OESTWGBU6M3U6RF6LANCNFSM5P5BKO4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
There are not too many clues in that error message. It appears to be having an issue connecting.
What did you change before it stopped working?
Did you change the code on the micro:bit? Do you need to delete the pairing information and re-pair the two devices?
Have you tried restarting the BlueZ daemon on the Linux machine (sudo service bluetooth restart
)?
To get Bluetooth debug information on Linux:
bluetoothctl
?service bluetooth status
show errors?When running your script have separate terminals open with the following running to get more debug information:
bluetoothctl
journalctl -f -u bluetooth
sudo busctl monitor org.bluez
sudo btmon
Hi Barry!
Something went wrong with the pairing I guess!
Worked after pairing the microbit with the Rpi!
Svein-Tore
ons. 9. mar. 2022 kl. 09:00 skrev Barry Byford @.***>:
There are not too many clues in that error message. It appears to be having an issue connecting. What did you change before it stopped working? Did you change the code on the micro:bit? Do you need to delete the pairing information and re-pair the two devices? Have you tried restarting the BlueZ daemon on the Linux machine (sudo service bluetooth restart)?
To get Bluetooth debug information on Linux:
- Are you able to connect to the device using bluetoothctl?
- Does service bluetooth status show errors?
When running your script have separate terminals open with the following running to get more debug information:
- bluetoothctl
- journalctl -f -u bluetooth
- sudo busctl monitor org.bluez
- sudo btmon
— Reply to this email directly, view it on GitHub https://github.com/ukBaz/python-bluezero/issues/363#issuecomment-1062649381, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD563NWYRZKQAA5ZRPNIBH3U7BLB5ANCNFSM5P5BKO4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
Hi
I see it is possible to send a value to themicrobit with the command
ubit.text
I just wonder, if I add a bluetooth on data reeceived command in makecode, will it be possible to get that value on the microbit as variable?