Transfer data array to arduino mega 1 to arduino mega 2, using xbee

I'm creating a code to transfer data from an RFID reader connected to an Arduino Mega to another Arduino via XBee, including the access status (granted or denied). The communication is established, and the data along with the access status are transmitted successfully. However, I'm facing difficulty in transferring the data matrix, which includes detailed information about the RFID card. I'm using the function MFRC522Debug::PICC_DumpToSerial(mfrc522, Serial, &(mfrc522.uid)); to print the data matrix to the Serial monitor, but I haven't been able to find a way to transfer it to Arduino 2. I tried implementing some functions in the code, but they caused issues and had to be removed. Does anyone know of a method to achieve this? Thanks for your time.
this is the code for the transmiter


#include <MFRC522v2.h>
#include <MFRC522DriverSPI.h>
#include <MFRC522DriverPinSimple.h>
#include <MFRC522Debug.h>

// Create MFRC522 instance.
// MFRC522 mfrc522(SS_PIN, RST_PIN);

// Configurable, see typical pin layout above.
MFRC522DriverPinSimple ss_pin(53);

// Create SPI driver.
MFRC522DriverSPI driver{ss_pin};

// Create MFRC522 instance.
MFRC522 mfrc522{driver};

void setup() {
  // Initiate a serial communication
  Serial.begin(9600);

  // Initiate serial for arduino 2
  Serial3.begin(9600);

  // Initiate SPI bus
  SPI.begin();

  // Initiate MFRC522
  mfrc522.PCD_Init();

  // Show details of PCD - MFRC522 Card Reader details
  Serial.println("show your card to the ready");
  Serial.println();
  MFRC522Debug::PCD_DumpVersionToSerial(mfrc522, Serial);
  Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
  // Show details of PCD - MFRC522 Card Reader details
  // MFRC522Debug::PCD_DumpVersionToSerial(mfrc522, Serial3);
}

void loop() {
  if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial()) {
    // Print UID tag
    Serial.print("UID tag :");
    String content= "";
    byte letter;
    // hexadecimal converter
    for (byte i = 0; i < mfrc522.uid.size; i++) {
      Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
      Serial.print(mfrc522.uid.uidByte[i], HEX);
      content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
      content.concat(String(mfrc522.uid.uidByte[i], HEX));
    }
    Serial.println();
    content.toUpperCase();
    // Check if UID matches the desired one
    if (content.substring(1) == "23 7F 8C 16") { //UID CARD to compare
      Serial3.print("A");
      Serial.println("Authorized access");
      Serial.println();
      delay(1000);
    } else {
      Serial3.println("P");
      Serial.println(" Access denied");
      delay(1000);
    }
    // Dump card details to Serial
    MFRC522Debug::PICC_DumpToSerial(mfrc522, Serial, &(mfrc522.uid));
    // MFRC522Debug::PICC_DumpToSerial(mfrc522, Serial3, &(mfrc522.uid));
    delay(300);
  }
}

// Function declaration to read serial data
String readSerialData();

void setup() {
  Serial.begin(9600);    // Initialize Serial communication
  Serial3.begin(9600);   // Initialize Serial3 communication
  Serial.println("Present your card");  // Prompt message
}

void loop() {
  // Check if there is data available on Serial3
  if (Serial3.available() > 0) {
    // Read the received character from Serial3
    char receivedChar = Serial3.read();
    // Check the received character
    if (receivedChar == 'A') {
      Serial.println("Access Granted");  // Print message for Access Granted
    } else if (receivedChar == 'P') {
      Serial.println("Access Denied");   // Print message for Access Denied
    }
  }
}
  }
*/

In the provided code, data from the RFID reader is successfully transmitted to Arduino 2 based on access status. However, the issue lies in transferring the detailed data matrix to Arduino 2. You may try uncommenting the line MFRC522Debug::PICC_DumpToSerial(mfrc522, Serial3, &(mfrc522.uid)); to send the data matrix to Arduino 2 via Serial3. If this doesn't work, further troubleshooting or alternative methods may be necessary.

How much text does the PICC_DumpToSerial send?

My guess is that you sending more data than what the Xbee can handle in one lump.

The workaround is to chop the data into smaller pieces and send one piece at a time with a time gap in between. Alternatively use the flow control pin as per the documentation to signal the Arduino when it's OK to send data.

my boss want all this data for the RFID CARD send to other arduino using xbee
Card UID: 23 7F 8C 16
Card SAK: 08
PICC type: MIFARE 1KB
Sector Block 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 AccessBits
15 63 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
14 59 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
58 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
13 55 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
53 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
12 51 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
11 47 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
10 43 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
42 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
9 39 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
8 35 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
7 31 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
6 27 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
5 23 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
4 19 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
3 15 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
2 11 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
1 7 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
4 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
0 3 00 00 00 00 00 00 FF 07 80 69 FF FF FF FF FF FF [ 0 0 1 ]
2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 0 0 0 ]
0 23 7F 8C 16 C6 08 04 00 62 63 64 65 66 67 68 69 [ 0 0 0 ]

"I made a mistake, I was putting the wrong command MFRC522Debug::PICC_DumpToSerial(mfrc522, Serial3, &(mfrc522.uid)); // send to Arduino 2 , so it's working now. But I can't find a way for the data to show in both serial communications without losing data." , i tried using millis, but still losing data one way o another.

still , there is no any form to show the rfid data in both serial, is show me good in serial 3 but in serial 1 is like
15 63 PCD_Authenticate() failed: Timeout in communication.
14 59 PCD_Authenticate() failed: Timeout in communication.
13 55 PCD_Authenticate() failed: Timeout in communication.
12 51 PCD_Authenticate() failed: Timeout in communication.
11 47 PCD_Authenticate() failed: Timeout in communication.
10 43 PCD_Authenticate() failed: Timeout in communication.
9 39 PCD_Authenticate() failed: Timeout in communication.
8 35 PCD_Authenticate() failed: Timeout in communication.
7 31 PCD_Authenticate() failed: Timeout in communication.
6 27 PCD_Authenticate() failed: Timeout in communication.
5 23 PCD_Authenticate() failed: Timeout in communication.
4 19 PCD_Authenticate() failed: Timeout in communication.
3 15 PCD_Authenticate() failed: Timeout in communication.
2 11 PCD_Authenticate() failed: Timeout in communication.
1 7 PCD_Authenticate() failed: Timeout in communication.
0 3 PCD_Authenticate() failed: Timeout in communication.
i already used milis and delay and still losing communication

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.