Parsing info received in serial monitor

Hello All,

The advertisement I am receiving in the serial monitor is something like this for example:

OK+00000000:00000000000000000000000000000000:00000
00000:B8782E07067C:-074OK+4C000215:2F237454CF6D4A0FADF2F491
1BA7FFA6:00000001AC:0CF3EE041DDE:-046OK+E

(I split that into three lines to fit the screen, but in reality is it one continuous string; I also added the bolding)

Goal: I need to parse that string of data in order to tease out the needed info.

So, in summary, what I would like to do is the parse the incoming data string shown above, look for the unique code “0CF3EE041DDE”, then capture the data measurement following it. (In the case above, it’s 046).

Any suggestions would be greatly appreciated. If there is some tutorial page with this sort of example, you’re are welcome to just give me the link, and I will figure it out from there.

Thanks in advance! :slight_smile:

Zimbu

There is a Serial.find() function: Serial.find() - Arduino Reference
and a Serial.parseInt() function: Serial.parseInt() - Arduino Reference

if (Serial.find(":0CF3EE041CCE:")) {
   int RSSI = Serial.parseInt();
   // Do something with the RSSI value
} else {
   // Timeout occurred waiting for .find()
}

You can set the timeout with Serial.setTimeout() - Arduino Reference

Well, that answer is a surprise! I was guessing that is would be something with strtok and strstr.

I will start working on your method asap and see what happens.

Thanks! :slight_smile:

void setup()
{
  Serial.begin(9600);
  Serial.println("Serial find test");
}

Even easier to read

Nice one Zimbu ,
Do you how to calculate the distance based on the RSSI value ? I'm struggling with finding a correct formula

RSSI signal/distance calculation
Read about trilateration.