Rx text bluethooth

I'm trying to read the data I receive from a GRBL1.1 board connected to an HC-05 module....with a few very simple blocks. the app crashes.. help.
premise: I transmit the commands and no problem... but reception doesn't work

What's your BlueTooth Client Delimiter value?

And does that match how you transmit your text to AI2?

Unfortunately, I don't know, I can't find comprehensive documentation for the GRBL 1.1 board. But in any case, something should be received; instead, the app crashes after a few seconds of connecting the Bluetooth

Can you get a Bluetooth terminal program from the Play Store and use it to show the data stream, without AI2?

The board I'm trying to control via MIT App Inventor is an RGBL 1.1F board connected to an HC-05 Bluetooth module. As suggested by you, I downloaded a specific app for RGBL codes, and when connected via Bluetooth, everything works fine. I am able to send the data correctly, and on the app's monitor, I can read the responses well (e.g., "ok", "serial", etc.). According to the RGBL documentation, this data is sent in the form of simple text.

Be sure to use println() at the end of each message to send from the sending device, to signal end of message.

Only use print() in the middle of a message.

Be sure not to println() in the middle of a message, or you will break it into two short messages and mess up the item count after you split the message in AI2.

Do not rely on timing for this, which is unreliable.

In the AI2 Designer, set the Delimiter attribute of the BlueTooth Client component to 10 to recognize the End of Line character.
Also, return data is not immediately available after sending a request,
you have to start a Clock Timer repeating and watch for its arrival in the Clock Timer event. The repeat rate of the Clock Timer should be faster than the transmission rate in the sending device, to not flood the AI2 buffers.

In your Clock Timer, you should check

  Is the BlueTooth Client still Connected?
  Is Bytes Available > 0?
     IF Bytes Available > 0 THEN
       set message var  to BT.ReceiveText(-1) 

This takes advantage of a special case in the ReceiveText block:

Receive text from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.

If you are sending multiple data values per message separated by | or comma, have your message split into a local or global variable for inspection before trying to select list items from it. Test if (length of list(split list result) >= expected list length) before doing any select list item operations, to avoid taking a long walk on a short pier. This bulletproofing is necessary in case your sending device sneaks in some commentary messages with the data values.

Some people send temperature and humidity in separate messages with distinctive prefixes like "t:" (for temperature) and "h:" (for humidity).
(That's YAML format.)

The AI2 Charts component can recognize these and graph them. See Bluetooth Client Polling Rate - #12 by ABG

To receive YAML format messages, test if the incoming message contains ':' . If true, split it at ':' into a list variable, and find the prefix in item 1 and the value in item 2.

Here is a simple BlueTooth text receiver sample, for single value per line:
initialize global message to

(Canned Response ABG - Bluetooth non-BLE SCAN Permission Blocks)

The easiest solution, for immediate relief
(from @Barry_Meaker) ...

I had the same issue. The problem is your app does not have permission to see nearby devices. The solution is to give your app permission on your phone (no code changes in your app).

on your phone,

  • goto settings
  • search for your app
  • in App Info for your app select Permissions
  • change Nearby Devices from Not Allowed to Allowed
  • Done

By the way, the very first time you run the app, Android will ask if you want to grant the app this permission. If you say no, or ignore the pop-up, the permission will be set as Denied. Android will not ask again.

A more complex approach, for professional app development:

See Bluetooth liste of devices deosn't work anymore - #7 by Anke
Special note for Xiaomi devices:
I have an error with bluetooth on android 12, Xiaomi Poco X3 NFC - #20 by Patryk_F

If these don't work,

(Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.

Thank you so much in the meantime. This works fine. I receive the code "ok" or "alarm" or "reset to continue" which is great. I'm just sorry that every message that arrives deletes the previous one.... If it's not too much to ask, is it possible to have 3 or 4 lines of messages that scroll? So that there's a history? If it's possible, otherwise, it's okay like this. Thanks again

When message arrives,
set LabelIncoming.Text to JOIN(message,'\n',LabelIncoming.Text)

to get freshest on top.

Reverse the order to get freshest last.


Do you need time stamps too?

everything's perfect, thank you very much