Split string with delimiter to individual values

Hello, i am using esp32 to send values to mit android app, in Arduino side i send all data via string separated by delimiter like value1,value2,value3 etc. in mit side i want to know how to split this string so can use separate values in labels. my current working setup for one value is this, how to make this to split my string to multiple values?

If you use comma like separator you can also use csv format and list components to manage data (list to csc
and CSV to list) .
In the text block you can also use split at and use comma like separator .the result will be a list with all the values

i am new to all this, can you show graphical example? i found in this forum this example, but its not working for me. This is how i send my data :
void dataToWeb() {
if (millis() - dataLastUpdate >= dataToWebInterval) {
dataLastUpdate = millis();
int a = random(1, 1023);
int b = random(1, 1023);
int c = random(1, 1023);
String message = "";
message += String(a) + ",";
message += String(b) + ",";
message += String(c) + ",";
webSocket.broadcastTXT(message);
}
}

i managed it to work this way. label4 shows raw string, all others separated values.
222

Show me the text you got and the result you want after split.

What does not work in this example ?

is there a way to ignore lets say everything after label3 if my list contains only 3 values? i want to list of variables in it to be dynamical, (1 value or another time 10 values), now if i send string too short (2 values) i got error list index too large, actually its too short. Maybe i can create default empty list, and then just overwrite it with my own values?

Now it works?
Yes you can.
You need one value on one label or you can show all the values in one label like a column

When you have a list you can use a for each block to manage the data, choose the best for you , there are two kind

This technique came from a BlueTooth environment, but shows the basic idea in procedure split_and_display:

Here is an updated blocks sample illustrating these ideas ...

BlueTooth_delimiter_sample.aia (3.4 KB) global message

1 Like

cool thanks, i ended up using just \n newlines and one Label, it works for my needs, will save your suggestion!

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