Advice on how to parse a list of comma separated variable-value pairs

I need to read specific variable values that are passed to my Arduino via a serial connection. I am interested in reading only a limited number of variables (the names of which I know in advance). In other words I am only interested in a subset of the information passed to the Arduino. The data is transmitted in a human-readable form. An example of the form of the input string might be


I might only be interested in the value of the variables SPD and HDG for example. I'd ignore the rest.

I'm sure somebody has encountered this type of problem before so I hope they'll share their solution.


Do you have control over what is transmitted by the other side? If so you could use any number of freely available serialization/de-serialization libraries (including Json)

suggest you look up strtok()

Use the forum Google search function in the upper right of this page to search for the key words of your project like "parse string String". You will probably find many similar previous project discussions and code to get you started.

The parse example in Serial Input Basics may help.