int val1 =(mfrc522.uid.uidByte[0]);
int val2 =(mfrc522.uid.uidByte[1]);
int val3 =(mfrc522.uid.uidByte[2]);
int val4 =(mfrc522.uid.uidByte[3]);
String valA=String(val1);
String valB=String(val2);
String valC=String(val3);
String valD=String(val4);
uID=valA+valB+valC+valD;
The function above with mfrc522.uid.uidByte[x]
is from the MFRC522.h
Library by Miguel Balboa and it is initialized as byte there. But when I initialize the val1 to val4 as byte, the desired number doesn't appear. I don't intend to print the uID to serial (as someone may suggest that to readily print to serial as it converts it automatically to some ASCII strings), but instead in the client.print()
of the Ethernet library along with other codes. I want to save it into another "greater" variable in terms of speed and memory allocation. The Arduino community warns about the use of String
as it uses additional decoding which is not needed as well as may crash Arduino and make Arduino run out of memory. And somehow, I experience some lagging or hanging in the serial, which I thought maybe due to the use of Strings variable. Please help me. I've read some sprintf()
concatenations and free()
but not well documented, I'm quite confused on their explanations. :)