Parsing string to variables

Hi, I have a problem parsing a string from a bluetooth device that transmits data collected from multiple ESP32 slaves via ESP-NOW protocol.
The blocks and project attatched are a standalone playground before i implement it, so i have
to enter a random string by hand to see the result.

My situation: My ESP32 master is sending a string to android which can for example read like this:
The letter represents the device id and the number the measured value of a sensor.
The string length and content can vary, since the slaves only propagate, when the value changes,
so they can look like: d3424;h23424 or b2331;c234234;g345345 and so on, you get the idea.

What i want is that the app splits the string in a way that for example b3424 will change variable sensor_b value to 3424 and so on.
I tried a lot and searched the interwebs but i still can’t wrap my head around this problem and only came to a partial solution. The code attached only works with the letter alone. The string a;b will set the value to the letter, but once i make it a123;b234 the value is empty.
I know there is still no routine to separate the letter from the value, at this state i just wanted to
see if it assigns a id+value string to the right variable.

text_parser.aia (4.4 KB)

Welcome @Tom_A_Hawk.
Did You try split blocks ?

If we mean the same, yes. As you can see at the blocks i am splitting the string up into a list at ; , look for specific letters in the list, when the letter is found aquire the list index position and set the corresponding variable to the value. Or at least i tried as it obviously doesn’t work as intended but i don’t know where it goes wrong.

You can ignore value3 and value4, it is just in there to see if the string gets processed at all.


here you go


aia file:
silver_textParser.aia (4.9 KB)


Happy Koding!


Thank you for your reply! This looks a lot different than mine :smiley:
I will have a look at it on the weekend, when i have more time for it.

1 Like

in a good way I guess? :thinking:

Happy Koding!


Yes, I had a look at dictionarys, but it seemed like it was only suitable for “static” data.
I have a hard time to understand kodulars functions without examples and make use of them.

I modified your example a bit to see what every variable does and recognized that i can’t leave out a sensor value like for example a12;f56 string or i can’t inverse the order like f09;e87;d65;c43
My goal is to throw any csv string at that algorithm as long as it contents have a leading letter and is followed by integers for my sensor usecases.

silver_textParser.aia (7.7 KB)

I already have the sensor network transmitting to android via the ESP32 master in this string layout: 5335;38355;1111111;3534;1111111;1111111 . A 1111111 value represents sensor value hasn’t changed (random out of ADC range value) and in a fixed order. But when i shorten the string by excluding the 1111111; i have to identify which value is which sensor. That’s why i have to add the letter.

Thanks again I have to wait for the weekend to come back at this problem

I will re visit the issue and report back to you.


I hope this can help you:

aia file:
silver_textParserF.aia (3.7 KB)

1 Like

Thank you very much!
Your code had the problem on my side it sets empty variable values if you don’t enter values for all sensors in one string, but i think i managed to solve that by excluding empty values from processing and at the same time i added a “is number” condition.

I will start implementing that into my app tomorrow, that is enough for today :smiley:

textParser_v02.aia (8.9 KB)

1 Like

I added error handling methods to the Kode, you can try it!

textParser_v03.aia (7.3 KB)

1 Like

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