In this code i am taking the TID data(20bytes of 160bits) in the form of array according documentation and and its working correctly and getting the output of RFID tags.
Now I just need your guidance that how can i convert the array of 20 Bytes into a single variable or into a double long datatype? or another. Because I have to push it on to my MySQL database server for further processing.
I had tried the following code which works fine
byte x[10] = "450210921";
long result = atol(x);
Serial.print("long value of the byte is: ");
Serial.println(result);
but when i put the above code into my main code, getting not any error and I am not getting the required output.!
void setup()
{
Serial.begin(115200);
}
void loop()
{
byte response;
byte myTID[20]; //TIDs are 20 bytes
byte tidLength = sizeof(myTID);
//Read unique ID of tag
response = nano.readTID(myTID, tidLength);
if (response == RESPONSE_SUCCESS)
{
for(byte x = 0 ; x < tidLength ; x++)
{
if(myTID[x] < 0x10) Serial.print("0");
/*temp[x]=(myTID[x], HEX);*/
//Swapping values into temp variable
temp[x]=myTID[x];
Serial.print(temp[x]);
}
/*byte x[10] = "450210921";*/
//Convert a whole array into a single long variable
long result = atol(temp);
Serial.print("long value of the byte is: ");
Serial.println(result);
}
else
Serial.println("Failed read");
}