0

I have the following string:

String msg = "t22h58m798s2";

Than I created some variables:

int temperature;
int humidity;
int moisture;
int state;

I need to set value of temperature to two numbers after t character in msg. The same for other variables. Finally temperature should be 22, humidity - 58, moisture - 798 and state - 2. I receive msg from other Arduino's sensor values. I think I should do it using indexOf and charAt method, but I'm not sure how. Please hep me.

1 Answer 1

1

You can use substring function in arduino to a string from a particular character to another one. Like in this particular case you can use something like String temperature= msg.substring("1, 3");

Refer this for more information. http://arduino.cc/en/Tutorial/StringSubstring

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.