MIcro:bit UART write number cause disconnection failure

Hi, I have tried to develop an app to receive the UART valule feedback by a micro:bit. The app is working fine however the bluetooth disconnection isn't working when I press the disconnect button.

I started by trying to the project file shared by @Ghica under the topic of App Inventor, Micro:bit and UART and it works fine. However, when i switched from Uart.write string to Uart.write number, the problem appears. I have to manually press the microbit reset button to disconnect the bluetooth connection everytime.

I have tried to insert the command of "call Microbit.uart1- requestTXCharacteristic" when bluetooth connected and "call Microbit.uart1-StopTXCharacteristicUpdates" when bluetooth disconnected yet the result is still the same. May someone enlighten me on this problem?

Thanks in advance for the advices given.

Hi Thenk_Hou,
There are several things you can try to solve your problem:

  1. There is a newer version of the BLE extension here: Beta version of BLE extension for Android 12 permission changes - #48 by ewpatton You could try it.
  2. Post your blocks and/or .aia and the .hex from you micro:bit, so that I or someone else, can take a look.
  3. If everything works fine with sending strings, why not just send strings then? On the micro:bit you can use "convert (num) to text" and "parse to number (text)", both from the Text blocks. On the AppInventor side you can just use text as numbers, no conversion needed.

There isn't actually a formal disconnect function for Bluetooth, so the App Inventor Bluetooth disconnect function may not work with every device. Usually however, we find something in the User's code that inadvertently keeps the connection going.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.