Need some direction

I have an SDI-12 moisture sensor and it is working very well with the code below but I need to separate the values for each parameter such as Volumetric Water Content or Temperature. cause what i am currently receiving all the parameters on a single output.
Can anybody help me.

#include <SDISerial.h>

//in order to recieve data you must choose a pin that supports interupts
#define DATALINE_PIN 2
#define INVERTED 1
//see: attachInterrupt() - Arduino Reference
//for pins that support interupts (2 or 3 typically)

SDISerial sdi_serial_connection(DATALINE_PIN, INVERTED);

char* get_measurement(){
char* service_request = sdi_serial_connection.sdi_query("?M!",1000);
//you can use the time returned above to wait for the service_request_complete
char* service_request_complete = sdi_serial_connection.wait_for_response(1000);
//dont worry about waiting too long it will return once it gets a response
return sdi_serial_connection.sdi_query("?D0!",1000);
}

void setup(){
sdi_serial_connection.begin(); // start our SDI connection
Serial.begin(9600); // start our uart
Serial.println("OK INITIALIZED"); // startup string echo'd to our uart
delay(3000); // startup delay to allow sensor to powerup and output its DDI serial string
}

int j=0;
void loop(){
uint8_t wait_for_response_ms = 1000;
char* response = get_measurement(); // get measurement data
//if you you didnt need a response you could simply do
// sdi_serial_connection.sdi_cmd("0A1")
Serial.print("RECV:");Serial.println(response!=NULL&&response[0] != '\0'?response:"No Response!"); //just a debug print statement to the serial port
delay(500);
}

Response from the sensor are as follows

RECV:1+99.64+25.37+79.65+0.03

RECV:1+99.74+25.35+79.74+0.03

RECV:1+99.64+25.35+79.65+0.04

RECV:1+99.84+25.35+79.83+0.02

RECV:1+99.64+25.37+79.65+0.02

RECV:1+99.93+25.35+79.92+0.00

RECV:1+99.84+25.37+79.83+0.05

RECV:1+99.84+25.37+79.83+0.01

RECV:1+99.84+25.37+79.83+0.02

Thank you very much

"SDI-12 (Serial Digital Interface at 1200 baud) is an asynchronous serial communications protocol for intelligent sensors that monitor environment data." [Wikipedia]

It would have helped to know what the moisture sensor is. A link to the library would have been nice also.

(1) If the responses are always the same length as in the example, then this is easy. If one must parse the plus signs, it gets a little more interesting (but not much).

(2) Please provide a link to the documentation for what you call "the response from the sensor".

(3) Darned if I know why j and wait_for_response_ms are declared and given values. They are never used. Also, the largest value for uint8_t would be 255, so I do not understand why 1000 is used.

(4) delay(500) wastes the considerable power of some unknown Arduino for a half of a second.

(5) It seems that this

  char* service_request = sdi_serial_connection.sdi_query("?M!",1000);

provides useful information that is just thrown away.

@Vaj - seems this is straight out of the library examples.

Looks like it's pretty easy to parse using '+' sign as separator? Can values be negatives?

Copy that data in a local buffer and use the strtok() function to go through the buffer then an atoi() or atof() will let you parse the data (see doc here)

I found the library but a link would have saved me some searching. It is still a guess (but a good one) that this is the correct library.

It is possible that only atof(...) is needed if the lengths are fixed. If the lengths are unknown, I agree that copying the data and using the strtok(...) function are handy. I might be tempted to parse this myself, or to use the function strtof(...) to help.

Yes indeed - I usually just copy paste a bit of the code directly in google and it will point you straight to the GitHub example where it comes from - so not a major issue to do but indeed would be better to have the info from the OP at the same time he sends the question

That being said - most beginners don't realize that there might be more than one library to do something or that the issue might appear somewhere in the execution of the code while the bug is elsewhere - so even if it is painful to remind them about this / I guess it comes as part of the mission we choose to put onto ourselves to help out. So I try be balanced in my answers - point to the best practice while trying to help at the same time. Goal is to increase the community and encourage beginners to stick to it and become better - and then help others.

I agree.

I agree.

VJ4088 Thank for the reply and sorry for PM you on this forum. I am a beginner so don't know my way around this stuff much