Parsing info received in serial monitor

Hello All,

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


(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:


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.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.