Problem graphing data from Arduino Bluetooth to Screen 2

I'm trying to graph data coming from Arduino on Screen 2 of my app. The app does the connection with Arduino through Bluetooth, and actually gets the data sent. However, at the time of graphing it sends the error: "the operation format as decimal cannot accept the arguments." I made another app with the same code on Screen 1 and it works perfectly. I don't know if the problem is caused by using Screen 2, or something else. Any help will be greatly appreciated!

Without seeing the code, all I could guess is that the data isn't getting from Screen1 to Screen2.


Please export your project and post it here.

firebase.aia (11.6 KB)

firebase.aia (11.6 KB)

Thanks

I see you using a BlueTooth component in two screens.

Before I go further, do you know that switching screens breaks your BlueTooth connection?

We will need to see your Arduino code too, to see how you delimit your transmissions.

From what I see in your blocks, you are probably jamming numbers together ...

Standard advice:

Please see the Delimiter article in FAQ

Be sure to use println() at the end of each message to send from the sending device, to signal end of message. 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:

ReceiveText(numberOfBytes)
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.

I have all of those things in my programming. The thing is, the code on screen 2, as it is written, actually works when it's the only screen on the app. I have another app which only uses the code on Screen 2 and it graphs data perfectly. However, when I try to use it on Screen 2 of my other app, it just doesn't work.

Here is the clock timer event from your ECG screen ...

Prove your messages are what you expect.

Here is a logger you can use to record your incoming messages before you try to eat them.

Clicked on log logger_to_list.aia (2.6 KB) sample run

Here an example with Virtual Screen

2 posts were merged into an existing topic: Problem with App Inventor and bluetooth arduino