Sending realtime data EMG to my Android via BluetoothLE

Where do those '()' come from?

...we need to see the contents of the Label Muhammad -

For example, is it [(556,543)] or (556,543) or 556,543 ?

Edit: or something else - there seems to be a leading comma there


The content is like that sir, under the graph column

OK, not brilliant - it seems the BLE extension adds those parentheses.

CleanupValue

or:

Given that stringValues is a list as returned from the BLE block,
consider a

  • CSV Row From List or
  • JOIN WITH SEPARATOR ','
    conversion block to turn it into parentheses-free text.

Be aware that AI2 has native charts and graph components, that should not require extensions.

These blocks will deal with the ( ) problem by using a list block to extract your content from stringValues.

It will also settle a difference of opinion among Power Users as to where those ( ) came from.

1 Like

image
Maybe come from this sir?

Well, I just know it sir. And I don't understand about that extension is that added automatically or something?

No, ABG is correct - 'stringValues' is defined as an App Inventor List. We are not using it as a List.

It is because a List of values is expected and thus, if possible, should be processed as such. However, the Arduino is not delivering a List (two or more values sent one after the other), it is sending a concatenated String of two values to suit the graph extension, and therefore in this case 'select list item' might not work. However, you can try it, it works here if I make a test List of one, but my test is not using the value as received via BLE.

If 'select list item', does not work, we have to clean-up the String by removing the brackets, but it should work as per ABG's example.

'Select list item'?.......is that like list picker in app?

Ah, I see. So what should I do sir?

It's a Blocks List

Snap1

.... use ABG's code

1 Like

Excuse me sir, how about I change block set label1 to update graph?

How about this sir, if for example I want to display a graph and use this block


Then I also want to connect BluetoothLE with this block

Will there be errors or crashes with the program from those blocks?

That was just a minimal test to see if data could be extracted cleanly (without ()) from the BLE data stream.

Did you actually try those blocks, using a Label of your choice?

Did you see data arrive in the Label?

Did it look like the data you sent?

If all those are true, my work here is done.

Questions about setting up BLE connections I leave to BLE experts.
Be aware you took a non-BLE Bluetooth sample and converted it into a BLE app.

Questions about how to feed data into a graph extension, I leave to you and the author of that graph extension.

If you want to use the native AI2 graph component, see

image
I have change it sir, and the result is the data extracted cleanly without ()


EDIT : I'm sorry if I just replied, because there is only one Arduino and my friend is still using it to retrieve EMG data so I take turns using it

The 'Strings Received' Block should be as per ABG's example.

The Button_Connect Block should be fine - but do you use a Clock Timer to allow the Scan to find all available devices?