A simple Arduino library for DFRobot's ID01 UHF RFID reader, which otherwise has no publicly available drivers.
The sample code provided on the wiki page for this product only covers two command sequences, and does not actually tell you how to read RFID tags. Furthermore, the manual is complete indecipherable garbage. I spent a few days parsing it and wrote a driver based off of it, but when I went to test it I found that absolutely nothing worked the way the manual said it would. The only thing I could do successfully was read tags in the module's default mode, however nowhere was the format of the output documented.
This Arduino library provides only the bare minimum functionality to read tags with the ID01 module. Without needing to send any commands to the module, it will always start up in "continuous read" mode, spitting out tag IDs that it has read. This lightweight library simply parses these tags and verifies their checksums, providing an easy-to-use API for obtaining tag IDs.
This repository includes:
- The library, consisting of
- A sample sketch,
To use the library:
.hfiles to your sketch directory, or install them somewhere the Arduino IDE can find them.
#include RfidReader.hto the preamble of your sketch.
RfidReaderobject on the
Streamcorresponding to the UART where the RFID module is connected. This can be either a
beginon the serial device if necessary; the default baud rate is 9600.
Set up a 12-byte buffer to store tag ID's in.
readTagIdmethod, passing it your buffer as a parameter. The method returns
trueif a read a tag; the tag will have been placed into your buffer. If it returns
false, no tag has been read.
The provided sample sketch gives an example of this usage.
- The sample sketch uses
Serial1as the connection to the RFID module. This assumes an Arduino Due or Mega (or some other Arduino with multiple hardware UARTs).
readTagIdfunction will consume all available input from the UART when it is called. As a result, it will return the most recent tag ID that has been seen since the last time it was called.
- The library verifies checksums and frame formats internally, and keeps a fixed-size circular buffer. As a result, it should be robust to any acute serial errors.
For the sake of completeness, here is a description of the tag ID format used by the ID01:
- A tag is sent in a 17-byte frame.
- The frame begins with start sequence
- The ID, 12 bytes, follows.
- After the ID, there is one more byte of
- Next, a 1-byte checksum. The sum of all 16 bytes read so far, modulu
0xff, should be
- Finally, a trailer byte
The content of this repository is released under the MIT License; see accompanying
LICENSE file for details.