Need Help with app (graphing/charting Charts component)

Hi so i have been trying to display pressure data and the timestamp on ChartData2D. However, i am receiving 3 different types of data. PA, PSI and KGF. I have implemented a reset button so that it will clear the Graph for the different data. So when im getting PA data , it will only display PA data and i will reset the graph and then when im getting PSI data, it will only display PSI data. but i keep getting this error



PSC_Meter2_Test_2.aia (421.4 KB)
anyone know why?

Is this with Companion app ? Are you using the latest companion ? (2.74/2.74u)

Please also post your sketch code.

You are expecting exactly 3 bytes of data, and it's unusual for numbers to be encoded like that.

You need to test the length of list bytevalues, to insure it has at least 3 items in it, before trying to access items in that list.

Also, list indexes do not need conversion, just use 1,2,3,...

You can get more reliable conversion decision making based on the incoming characteristicUUID, since you went to the trouble of making 3 of them, right?

image

Your technique for just keeping the last 10 readings on your graph is unnecessarily complicated.

I prefer to just keep an AI2 list of the last 10 readings, and clear and refresh the ChartData from it each time new data arrives.

See this Drunkard Walk sample for an example.


chart data source
chart_drunkards_walk.aia (2.5 KB)
charts_drunkard_walk.aia (3.5 KB)
Sample run

oh yes so basically the device that is sending the data to the app is an algometer and how it works is that the algometer can be set to three different types of units with a button. so if i press the button once , it will display Pa data and when i press it again it will display PSI data and if press one more time it will display kgf data.
SendDataButton.ino (4.6 KB)
ButtonForUnits.ino (4.3 KB)
BLE.ino (3.8 KB)
this is the sketch code for arduino

From the BLE sketch, the PSI variables are uint32 each, on separate characteristics.

So what is arriving in the bytes list?

so basically the data is being transmitted as 4 bytes in little-endian format. so lets say the data being sent is 0x12345678 (hexadecimal) which is , the value being transmitted will be 0x12 0x34 0x56 0x78 (hexadecimal)

Byte Index Value (Hex) Binary Representation
0 (LSB) 0x78 0111 1000
1 0x56 0101 0110
2 0x34 0011 0100
3 (MSB) 0x12 0001 0010

So let's see how you decode your input stream:
image
(your last blocks shot)

You are assuming that you will receive at least 3 bytes.
You fail to check length of list(byteValues) before attempting selects
You ignore the high end byte.
You apply a useless conversion to the list index.

so i tried the drunkward walk method. However my reset button doesnt work. Whenever a new data of a different unit is received, a random number appears on the graph. not sure why


in this case, its 25.3


this is the video of the process.
PSC_Meter2_Test (2).aia (424.2 KB)
this is the code

blocks (1)

Why do you add a constant 0 to the graph?

If you reset and more data is already in transit,
changing that global PressureIndex will put it momentarily out of sync with what's arriving, causing it to be mis-classified.

That's why I recommend removing that global variable, and using the incoming characteristic to decide how to process the incoming data.

If you decide to stick with that global variable, add an extra test to insure the characteristic matches too.