Send data from MFRC522 to Firebase via ESP32

Greetings.

I don’t know much about Arduino Programming and I am doing a project and I need to send a message that I saved in block 6 on an RFID card, when I read through the serial I get the saved message and I would like to send it through an ESP32 to a Firebase database, but I don’t know how to do it.

The connection is established and I can send information correctly.

I enclose some of the lines of Code that intervene here:

////////////////////////////////////////////////////////////////////////////////////////////

void setup() {
Serial.begin(115200); // Initializa serial communications con PC

Serial.println();

//while (!Serial); // parar si el puerto está abierto
SPI.begin(SCK_PIN, MISO_PIN, MOSI_PIN); // Inicia SPI bus
SPI.setDataMode(SPI_MODE3);
mfrc522.PCD_Init(); // Inicia MFRC522 card
delay(4);
// utiliza FFFFFFFFFFFFh que son los datos en chip de fábrica
for (byte i = 0; i < 6; i++) { //solo el bloque6
key.keyByte[i] = 0xFF;
}

WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print(“Conectado al Wi-Fi”);
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(300);
}
Serial.println();

Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
Firebase.reconnectWiFi(true);

//pinMode(RedLed, OUTPUT);

Serial.println(F(“Ingrese Tarjeta”));
}

void loop() {

//digitalWrite(RedLed, HIGH);

if ( ! mfrc522.PICC_IsNewCardPresent()) //leer si hay nueva tarjeta
return;

if ( ! mfrc522.PICC_ReadCardSerial()) //selecciona la nueva tarjeta
return;
byte sector = 1;
byte blockAddr = 6; //Lee solo del bloque6 sus 16bytes
byte dataBlock = {
0x01, 0x02, 0x03, 0x04, // 1, 2, 3, 4,
0x05, 0x06, 0x07, 0x08, // 5, 6, 7, 8,
0x08, 0x09, 0xff, 0x0b, // 9, 10, 255, 12,
0x0c, 0x0d, 0x0e, 0x0f // 13, 14, 15, 16
};
byte trailerBlock = 7;
MFRC522::StatusCode status;
byte buffer[18];
byte size = sizeof(buffer);
Serial.println(F(“Datos actuales en el sector:”));
mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector);
Serial.println();

Serial.print(F(“Cargando dato del bloque “)); Serial.print(blockAddr);
Serial.println(F(” …”));
status = (MFRC522::StatusCode) mfrc522.MIFARE_Read(blockAddr, buffer, &size);
if (status != MFRC522::STATUS_OK) {
Serial.print(F("MIFARE_Read() failed: "));
Serial.println(mfrc522.GetStatusCodeName(status));
}
Serial.print(F(“Dato en el bloque “)); funciona = Serial.print(blockAddr); Serial.println(F(”:”));
dump_byte_array(buffer, 16); Serial.println();
Serial.println();

while(iterar){

Firebase.getString(firebaseData, nodo + "/Nombre");
Serial.println(firebaseData.stringData());
delay(250);
Firebase.getString(firebaseData, nodo + "/Precensia");
Serial.println(firebaseData.stringData());
delay(250);
Firebase.getInt(firebaseData, nodo + "/Precio");
Serial.println(firebaseData.intData());

Firebase.setString(firebaseData, nodo + "/iterar", Hola);

iterar = false;
Firebase.end(firebaseData);

}

//delay(2000);
//digitalWrite(RedLed, LOW);

}
/**

  • Rutina que envia el valor hex al puerto serie.
    */
    void dump_byte_array(byte *buffer, byte bufferSize) {
    for (byte i = 0; i < bufferSize; i++) {
    // Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    // Serial.print(buffer[i], HEX);
    Serial.write(buffer[i]);

}
}