String handling in Magic Scripts

Hi all,

Been away for some time, but grabbed my Atlas sensors again and I want the values presented in Nymea.

I have a serial connection between the Arduino with the sensors and Raspberry Pi (Nymea system).
I can receive the serial line with the Serial port Commander and can print the received info (log).

The string I want to receive will be in the form: “DO: 99.9 ORP: 255 PH: 7.5\r\n”
Now I want the string to be sliced into three values so I can enter these in the DO, ORP and PH sensors (input value).

I looked around in the documentation and in the QT documentation, but not getting it.

Can someone point me in the right direction how to work with strings?



Do you already have the string in a script? If so, you can use JavaScript on it and use methods like slice on it etc

Hi Michael,

I already have the string in the script and I will change the program in Arduino to send the values in a string separated by a space, so I can use str.split(“ “).

Thanks for the hint!

1 Like