Extracting relevant values

I have a string of hexadecimal values, it consist of data type, and the next two hexadecimal values are the values of parameters (for eg. temperature). How do I extract the relevant data type and next two parameters? For example my data string is, 0E 01 54 0E 00 71 0E FF F1 16 00 42 16 04 A9 12 00 64 0A 00 C8 0A 00 00 0A 00 00 0A 00 00 0E 01 18 0E 01 7C. The data type is 0E and I want to extract out the next two values afterwards.

Hello mytice

Post your current sketch to see how we can help.

Screenshot 2023-06-12 121526
My current sketch is just like that only, because I am unsure of how to extract the data. I only know the at the end of the program, the variable Data will be for eg. (0E 01 54 0E 00 71 0E FF F1 16 00 42 16 04 A9 12 00 64 0A 00 C8 0A 00 00 0A 00 00 0A 00 00 0E 01 18 0E 01 7C)

How do I focus which data type I want, so that I can extract the next two values ?

Hello mytice

Check, test and fine tune this small example to continue:

//variables
constexpr uint8_t DataString[] { 0x0E, 0x01, 0x54, 0x0E, 0x00, 0x71, 0x0E, 0xFF, 0xF1, 0x16, 0x00, 0x42, 0x16, 0x04, 0xA9, 0x12, 0x00, 0x64, 0x0A, 0x00, 0xC8, 0x0A, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x0E, 0x01, 0x18, 0x0E, 0x01, 0x7C};
void setup()
{
  Serial.begin(115200);
}
void loop()
{
  for (uint8_t n = 0; n < sizeof(DataString); n++)
  {
    if (DataString[n] == 0x0e) Serial.print(DataString[n + 1]), Serial.println(DataString[n + 2]);
  }
  while(1);
}

Have a nice day and enjoy coding in C++.Have a nice day and enjoy coding in C++.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.