Arduino Mega 2560 with RFID reader RDM6300

Hello, im trying to read/write IDs with my 250kHz rfids (yes I have writable chips) but I dont know if Im doing things right for the serial connection, I cant seem to get it to work. Im using the RDM6300
RDM6300-RFID-Reader-Module

I am using the Arduino Mega 2560 with the TX from the rfid reader plugged into the 1 port on the Arduino. My code is

> uint8_t buffer[14];
uint8_t* buffer_at;
uint8_t* buffer_end = buffer + sizeof(buffer);
 
String checksum;
boolean tagfound = false;
 
void setup()
{
    Serial.begin(9600);
    Serial.println("Serial Ready");
 
    Serial1.begin(9600);
    Serial.println("RFID Ready");
}
 
void loop()
{
    if (Serial1.available()){
        delay(20);
        buffer_at = buffer;
 
        while ( buffer_at < buffer_end )
        {
            *buffer_at++ = Serial1.read();
        }
        tagfound = true;
        Serial1.end();
        Serial1.begin(9600);
    }
 
    if (tagfound){
        buffer_at = buffer;
        uint32_t result = 0;
 
        // Skip the preamble
        ++buffer_at;
        // Accumulate the checksum, starting with the first value
        uint8_t checksum = rfid_get_next();
        // We are looking for 4 more values
        int i = 4;
        while(i--)
        {
            // Grab the next value
            uint8_t value = rfid_get_next();
            // Add it into the result
            result <<= 8;
            result |= value;
            // Xor it into the checksum
            checksum ^= value;
        }
        // Pull out the checksum from the data
        uint8_t data_checksum = rfid_get_next();
 
        // Print the result
        Serial.print("Tag: ");
        Serial.print(result);
        if ( checksum == data_checksum )
            Serial.println(" OK");
        else
            Serial.println(" CHECKSUM FAILED");
        // We're done processing, so there is no current value
 
        tagfound = false;
    }
 
}
 
uint8_t rfid_get_next(void)
{
    // sscanf needs a 2-byte space to put the result but we
    // only need one byte.
    uint16_t hexresult;
    // Working space to assemble each byte
    static char byte_chars[3];
    // Pull out one byte from this position in the stream
    snprintf(byte_chars,3,"%c%c",buffer_at[0],buffer_at[1]);
    sscanf(byte_chars,"%x",&hexresult);
    buffer_at += 2;
    return static_cast<uint8_t>(hexresult);
}

I cant seem to get it to work and was hoping I could get some help! Thanks!

Schematics had been valuable. Then You can get advice instead of nasty guesses like this: Connect device Tx to reciever Rx and vise versa.

I have no schematic, that's the issue. I just winging it. Ill try this out and see if this does anything for me. I can also include the pinout for the Arduino if it would help. I don't really know exactly what serial communications I should be using.

There are a few hits arduino rdm6300 - Google Search. I would suggest that you try a few of them; if you find one that works, base your code on that.

Why have you implemented the below?

    Serial1.end();
    Serial1.begin(9600);

I would further sprinkle more Serial prints around to see at other places what is received. E.g. change

        while ( buffer_at < buffer_end )
        {
            *buffer_at++ = Serial1.read();
        }

to

        while ( buffer_at < buffer_end )
        {
            byte b = Serial1.read();
            Serial.print("received ");
            Serial.println(b, HEX);
            *buffer_at++ = b;
        }

What antenna have you attached? It needs to be tuned so that it resonates at your excitation frequency, otherwise nothing will work.

Have you read this?
https://microcontrollerslab.com/rdm6300-rdm630-rfid-reader-arduino-tutorial/

Say you have 1 char waiting in Serial1 (the second one is being clocked in at 9600 baud which is SLOW compared to the speed of the MCU). You then proceed to blindly read 14 bytes into your array. There is no guarantee any data will be available. If you want to do the entire read in a while() loop, you should check if Serial1.available() >= sizeof(buffer)

Yea ive tried every one of them I could find. Ive installed 4-5 different libraries trying to get something to work. Still cant seem to pin the problem down. I get no reading at all from the serial monitor.

I am using the stock antenna that comes with the RDM630. Supposed to pick up 125kHz cards.

1 Like

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