Dear ChrisWard,
THank you for your reply, I already connected successfully between application on the phone ( install by file apk, was built by your file .aia) and microbit. Microbit show C when I connectted and show D when I disconnected.
But I try send the string from Microbit button A to application, via [ bluetooth uart write string “Hi” ] block -> nothing happen on application ( label status did not change to Received ), while Microbit show string “Sent”. It means the event maybe not match between 2 objects.
Could I ask you, you use which command to send string from Microbit to application ?
If you use Python, just write down the code, I can understand it.
Thanks.
I have run some tests here with my Micro:Bit, via the Companion. The very first time I tried I got an error message in the App which said the Characteristic UUID was not recognised - since then, I have been unable to connect as BLE no longer finds the Micro:Bit (it finds only other Bluetooth devices nearby).
Dear ChrisWard,
You cannot see your Microbit because you stop scan at event DeviceFound.
Disable “stop scanning” at Device Found, application will continue scaning and see your Microbit, I tested and connected successfully. ( view image)
However, the code receive the string from Button A of Microbit does not work. The Microbit show “sent” but the label of application does not show the string “Hello”.
Dear all,
I check with “Serial Bluetooth Terminal” application, my phone receivce the message “Hi” from Microbit, not “[72,105]” such as app inventor
( I used my code as attached file, not file from ChrisWard )
Maybe the problem is UART_TX Field. Because I use UART_RX_Field can transfer message from app inventor to Microbit successfully.
In theory, the list of all devices is produced instantly, so the scan could be stopped in that Block, just as the ListView can be populated in that Block - however, the Block tip (pop-up help) does not suggest that is so. I will redesign the tasks to see if it makes a difference.
Edit: You are using the TX Characteristic Received Block for something it’s not intended for…
… but of course, that makes no difference to the scan I have also tried it with a Huawei p30 pro, same issue - my microbit is not listed/found.
So, dug up older project that only sends to the MicroBit. It writes LED Text and draws a smiley. That reminded me it’s possible to use BLE on the Microbit without UUIDs. However, it too no longer finds the MicroBit, so perhaps my MB’s BLE has died. Edit: Or perhaps it’s not properly paired!
OK, so my MB can indeed be found. However, it can’t connect:
Service 6e400001-b5a3-f393-e0a9-e50e24dcca9e, characteristic 6e400002-b5a3-f393-e0a9-e50e24dcca9e are not published by the connected device. Note: You will not see another error reported for 5 seconds.
I have tried Hex files set to “Just Works” and “Pass Key Pair”. However, there is no Microsoft Make Block for advertising Service and Characteristic Uuids (there is one for Eddystone Uuids) . The next step would be to edit the Javascript to include the Uuids but the subject is not described on their website.
Yes, you are correct. I did have before. Put it back, little bit of progress in that the original error is reported (Using the MB “JustWorks” setting:
Error 9011 in extension BluetoothLE: Unknown Characteristic
Interestingly, there isn’t a 9011 in the App Inventor list of errors - that must be a recent change. However, MB needs to work with the Service and Characteristic Uuids. There must be a way to do it, I can’t find any mention though. I have numerous MB links on my website by the way:
The difference between now and last year seems to be that App Inventor’s BLE Extension does not want to work with the “JustWorks” or “No pairing required” modes supported by MicroBit - they are both of course insecure.
Final try, I reset my MB to the verbatim original, via the latest Lancaster University Hex file. However, the Characteristic Uuid is still rejected
Perhaps it is slightly wrong - I cannot find any reference to the actual Uuids the MB has by default, only the Characteristics supported.
Let’s see how Evan gets on with the MicroBit Extension this weekend - if he has time, he is going to look into reinstating the Uart Blocks.
Here's an updated extension with a new component, Microbit_Uart_Simple (download). This version returns a single string rather than a list of bytes, and it automatically subscribes to the TX characteristic so you don't have to manage that any more. This is still a work in progress, so please let me know how things go with it.
The way BLE typically works is that when you pair with something the system records the characteristics that were advertised at that point in time and saves them. On future connections, rather than querying the device again it reuses the cached values. With the micro:bit and other programmable things, this has the unfortunate side effect of allowing you to change the characteristics without the device realizing that something is different. Sometimes turning the Bluetooth off and on clears the cache. If not, I sometimes use the BLE Scanner app (which I believe calls a private Android API) to refresh the devices.
Dear @ewpatton
I test with new simple Microbit Extension (com.bbc.microbit.profile-20200518.aix ), I can send a string from APP inventor to Microbit, but it does successfully for the first time, the second time Microbit receive a string " " ( maybe space letter )
For example, I create a textbox on App Inventor, and get the string from this textbox, send to Microbit. text is "data"
Result: 1st time: string can be sent to microbit successfully, and Microbit show "data" on LED 5x5.
2nd time, Microbit show " "
If I reset the Microbit, it repeat again, 1st time is successful, 2nd, 3rd , 4th time ... is failed.
I made a similar hex file and used Evans "new" UART extension. Same problem as DoCho. It is sent only once and I never see the massage sent event.
As I bought a new little robot with a micro:bit, I really would like the UART to work. Last summer I had a shaky version that could steer the other robot I had around, but I would like to improve on it this time!
Cheers, Ghica.
Here is a setup that works:
Use the old micro:bit extension that can be found here: http://iot.appinventor.mit.edu/assets/resources/com.bbc.microbit.profile.aix
And a .hex file (no pairing required, it receives a message via UART and it sends a message back with a sequence number.
Here is the .aia for it: MQUart5.aia (272.6 KB)
After connecting, if you press the send button, it sends Hello and it displays what it recieves back in a label.
I receive a string of numbers back that clearly say: Hello1 etc. but as a list of numbers that I should convert. I did not find out yet how to do that.
Hope it helps someone. It would be sooo nice if someone solved the UART problems for the SimpleMicrobit extension!
Cheers, Ghica.
The problem with these blocks is that you should use BytesReceived instead of StringsReceived,
Then it works fine. However, you get a list of ASCII characters (numbers) and I did not find an easy way to convert these to a string.
Cheers, Ghica.