mfrc522 UID - converting to dec

I have MFRC522 and need sent UID to server. For this example I have card with UID: 35 CB F8 C2 (this I can get by mfrc522.PICC_DumpToSerial(&(mfrc522.uid)); ).

This basic way is returning decimal UID : “00-2048194”

cardId = mfrc522.uid.uidByte[0] << 24;
cardId += mfrc522.uid.uidByte[1] << 16;
cardId += mfrc522.uid.uidByte[2] << 8;
cardId += mfrc522.uid.uidByte[3];

BUT - when I use another buyed card reader I am getting number “3271084853”. I know how to get it - I can take HEX UID backwards - in this example C2 F8 CB 35, convert it to DEC and we have “3271084853”.

Ok, can anyone help me how to do it in arduino and as result have string that I can pass to call URL (I know how to call it / it is working well… only this last think is missing). I am solving this for two days and I am lost…

Thank you for any help

study this

byte mfrc522_uid_uidByte[4] = {0x35, 0xCB, 0xF8, 0xC2 };

char uidString[9]; // 4 x 2 chars for the 4 bytes + trailing '\0'

// store on 2 char the Hex represnetation of byte v
// adds a trailing '\0'
// so b should point to an array with at least 3 bytes available to contain the representation
void storeHexRepresentation(char *b, const byte v)
  if (v <= 0xF) {
    *b = '0';
  itoa(v, b, 16); //

void setup() {
  for (byte i = 0; i < 4; i++) storeHexRepresentation(&uidString[2 * i], mfrc522_uid_uidByte[i]);

  Serial.print(F("\nYour string is:"));


void loop() {}

Thank you very much J-M-L! This is exactly what I was searching for.