UART with Micro:bit and App Inventor

Dear all,
I use BluetoothLE extension for App Inventor & Micorbit extension for App Inventor.
I use UART to send string “Hi” to App Inventor application.
But the label show [72,105]. I try with string “555”, it show [51,51,51]
How I can convert to string ?

1 Like

I suspect the UART_TX_Field is not going to deliver the text sent by the Micro:bit :upside_down_face:
There should be a dedicated Uart block set in the App Inventor Extension “SimpleMicrobit.aix”, downloaded from here:
iot.appinventor.mit.edu/#/microbit/microbitintro
and described here:
iot.appinventor.mit.edu/#/microbit/microbituart

…but it’s missing. I’m assigning your post to MIT, to find out what has happened.

2 Likes

While waiting for MIT, would you like to try an experiment?
Edit: Update to use the correct Uuids supplied by Evan.

TextFromMicroBit2

1 Like

Actually, the UUIDs you’ll want for that hack are:

Service UUID: 6E400001-B5A3-F393-E0A9-E50E24DCCA9E
Characteristic UUID: 6E400002-B5A3-F393-E0A9-E50E24DCCA9E

which are the UUIDs that the micro:bit uses for UART.

1 Like

So, something like this should work (it’s rough, but you can spruce it up)


MicroBitReceiveText.aia (284.4 KB)

1 Like

Dear ChrisWard,
I’m using Uart block set in the App Inventor Extension “SimpleMicrobit.aix”

If I use UART_TX tranfer code from App Inventor Application to Mirobit, it worked well ( code below, experiment transfer string “11” from application to Microbit)

I will try your experiment, but how I send string from Microbit to application with your file MicroBitReceiveText.asia ? which block in make code website?
Thanks

1 Like

Hi

You can simply run my example Project on your Android device (phone?), via the Companion. It should work with your original Make code:

OriginalMake

1 Like

Dear ChrisWard,
I try to use your project .aia, but application cannot receive the string from Microbit
I add two code to your project, use the Label Status to check the connectio between Microbit & application, they’re connected ( Microbit show “C” , application show “Status: Connected”)
But when I push A button, there is not any changes in application, Microbit show “Sent”, it means Microbit already sent String “Hi”.
I try with uart write line “hello”, the same result, not thing changes.

1 Like

Hi
There are a couple of things that need to be in place on your phone - first is obvious, bluetooth must be switched on. Second, Locate/Location must be switched on.

1 Like

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.

1 Like

Hi again

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).

So - in the dark!

Attached is the Project that fails:

MicroBitReceiveText.aia (286.0 KB)

1 Like


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”.

1 Like

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.

1 Like

Hello Choi

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…

1 Like

Updated App Code, still no joy here (Tested on Samsung S8, Android 9).

MicroBitReceiveText.aia (286.5 KB)

1 Like

Dear Chris,
This is your file that I edited can connect to phone.
But the event of read string from Microbit is not running.

MicroBitReceiveText.aia (286.2 KB)

1 Like

A different UUID? I will try it (even though I’m not here today).

1 Like

… but of course, that makes no difference to the scan :frowning_face: 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. :frowning_face:
Edit: Or perhaps it’s not properly paired!

1 Like

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.

1 Like

Dear Chris,
You need start “bluetooth uart service”
Untitled