long readTagID(const byte *data, const uint32_t numBytes) {
char tempBuffer[numBytes + 1]; // create a temporary buffer enough bytes including for a trailing null char
memcpy(tempBuffer, data, numBytes); // copy the bytes
tempBuffer[numBytes] = '\0'; // add the trailing null char
return atol(tempBuffer); // parse the content as a long number and return it
}
byte testData[] = "1000 and some garbage here";
void setup() {
Serial.begin(115200);
Serial.print("\reading the data -> ");
Serial.println(readTagID(testData, 4));
}
void loop() {}