I'm trying to get data from a heat counter via the serial, the format of the response is:

t1=ХХХ.ХХ   t2=ХХХ.ХХ   t3=ХХХ.ХХ   t4=ХХХ.ХХ
P1=ХХ.ХХ    P2=ХХ.ХХ
VolSpd1=ХХ.ХХХ  VolSpd2=ХХ.ХХХ
MassSpd1=ХХ.ХХХ MassSpd2=ХХ.ХХХ
HeatSpd1=Х.ХХХ  HeatSpd2=Х.ХХХ
SumVolume1=Х.ХХХХХХХ    SumVolume2=Х.ХХХХХХХ
UnMeasTime1=Х.ХХХХХХХ   UnMeasTime2=Х.ХХХХХХХ

I managed to get the data and parce it on arduino but only from the first line. I do not know how to get all other data.


Since the format is just = , I'd parse it this way, instead of relying on newlines.

Just treat them as whitespace. So buffer all data till an = sign is found, store the buffer as the variable name, then read until you get something other than a digit or decimal point. Then store this as the value. Then do something with the value based on the variable name. Then read and ignore all following whitespace (spaces, tabs, newlines, carriage-returns). And start back from the top.

That way the parse will never get out of whack when some data get missing or something else goes wrong in the serial stream.

  • Could you support me with the code?
    – igor m
    Oct 27 '16 at 19:18
  • First give it a try yourself. Come back if you have any questions.
    – Gerben
    Oct 28 '16 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.