Reading a 125 kHz RFID Module Reliably: Serial Frames and Presentation Events
A serial RFID module can make a tabletop game recognise a token or let a classroom exhibit select a recorded explanation. The first demonstration often looks easy: present a tag and print the received characters. The more interesting work begins when a tag remains in place, a message arrives in several pieces or the controller restarts halfway through a transmission.
PMD Way's 125 kHz EM4100 RDM6300 RFID reader is a useful example of a module with an external antenna and a TTL UART output. Its listing specifies 5 V operation and 9600 baud. Confirm the supplied revision's connector arrangement and output protocol before connecting it; similar-looking RFID boards can use different interfaces.
Keep the electrical interface separate from the message format
Descriptions such as “TTL level RS232 format” can be misleading. Asynchronous serial framing does not make a TTL signal electrically compatible with a conventional RS232 port. Use the appropriate UART interface and voltage compatibility, not a passive cable to a computer's RS232 connector.
The store identifies this module's I/O as 5 V. Before connecting its transmit output to a 3.3 V controller, check the controller's input limits and use appropriate level translation where required. Connect the reader's transmit signal to the controller's receive input, with the documented common reference. Do not assume an unused receive terminal must be connected for a read-only application.
Make the first test with a known compatible tag and short, clearly labelled wiring. Keep power disconnected while checking connector orientation. A successful power LED does not establish that the UART pins are correctly connected.
Capture bytes before interpreting identifiers
Log a short capture in hexadecimal, with timestamps if practical. A plain text terminal can hide control characters and make a complete message appear to contain only the identifier. Preserve the original capture so later parser changes can be checked against the same evidence.
Seeed Studio's RDM-family UART documentation describes 9600 baud, eight data bits, no parity and one stop bit. Its documented message contains a start byte 0x02, ten ASCII hexadecimal data characters, two ASCII checksum characters and an end byte 0x03. That is fourteen transmitted bytes. This is a reference format to compare with the supplied module, not proof that every RDM-labelled board is identical.
For that format, the ten data characters represent five binary bytes. The checksum is the exclusive-OR of those five decoded bytes; it is not the exclusive-OR of the ten ASCII character codes. Seeed's linked RDM630 specification illustrates this distinction. Establish the format from documentation and a capture before writing application logic around it.
Build a parser that tolerates real serial delivery
A receive function may return one byte, several bytes or part of the next frame. The boundary between software reads is not a boundary between RFID messages. Keep a small persistent parser state rather than assuming that every call receives a complete identifier.
- Wait for the documented start marker.
- Collect the expected number of characters into a bounded buffer.
- Reject characters that cannot occur in the documented data or checksum fields.
- Check the end marker, then decode and verify the checksum.
- Pass only a complete, valid identifier to the application.
- Reset the parser after success, invalid input or an incomplete-message timeout.
For the illustrated format, a new start marker arriving in a damaged partial frame can provide a useful resynchronisation point because that control byte cannot be an ASCII hexadecimal digit. Make this a deliberate rule for the verified protocol. Do not apply it blindly to binary protocols in which marker values may also occur inside payloads.
Keep separate counters for checksum failures, unexpected characters and incomplete frames. A single “reader failed” message hides useful clues. A rising incomplete-frame count during animation or audio playback may indicate that software is not servicing the receive buffer promptly enough.
Keep the rest of the program responsive
Read available serial data frequently while allowing display updates, buttons and other tasks to proceed. Arduino's Serial.available reference describes checking buffered received data. Available bytes are not necessarily a complete application message.
Avoid lengthy blocking waits after a successful scan. The Arduino Blink Without Delay example demonstrates elapsed-time scheduling that can also support parser timeouts and display messages. Choose timeout values from observed message timing and the application's needs; do not confuse a serial-frame timeout with the much longer interval used to decide that an operator has finished presenting a tag.
Separate valid reads from user actions
Suppose a museum token starts a sound clip. Ten valid reads of the same stationary token should not necessarily restart that clip ten times. Keep transport validation separate from the application's decision about what a read means.
| Condition | Possible application response |
|---|---|
| First valid identifier while idle | Start the associated activity once. |
| Same identifier received again | Refresh observation time without restarting the activity. |
| Different valid identifier | Apply the documented change-token policy. |
| No valid message for a chosen interval | Show an uncertain or idle state, according to tested reader behaviour. |
Silence is not automatically a reliable tag-removal signal. Some readers report repeatedly, while others report primarily when a tag approaches. Characterise your module by holding a tag still, withdrawing it and presenting it again. If it does not provide dependable presence information, use a deliberate confirmation button or a timed interaction rather than claiming continuous presence detection.
Test the parser without repeatedly moving a tag
Save several known-good captures as test inputs. Feed them to the parser as one complete message, one byte at a time and irregular fragments. The resulting identifier should be the same. Then remove a byte, alter a checksum digit, insert irrelevant characters and concatenate several messages.
The important outcome is controlled recovery: damaged input should not trigger an activity, and a subsequent valid frame should still be recognised. Also restart the controller with a tag already present and check that the experience is understandable to an operator.
Record the module revision, tag type, electrical interface, serial settings and observed repeat behaviour alongside the software. The RFID reader collection includes different reader approaches; choose one whose documented behaviour fits the interaction. Reliable RFID projects depend as much on clear event handling as on successfully receiving the first identifier.