The following is a running log of the RFID Reader project

20161103_182912

Note: The intent of this post is not to provide a how to guide to building an RFID reader. I am just trying to give a quick snap shot of where the project is and provide some useful links to people working on similar projects.

It has been a while since I have worked on an electronics project. I thought now was better then ever, isn’t that always the case. To dive back into the mix I chose to do a project geared around RFID. This project offered a lot of learning opportunities and will form the foundation for any future project I might have that include an RFID reader. What I would like to present here is the current state of the project as for hardware and firmware.

The requirements for this project are pretty loose and as usual have been evolving over time. The short list is as followed:

  1. Be able to swipe an RFID card and have it compare the stored value on the card to stored values in device memory.
  2. Be able to store up to 10 users into device memory.
  3. Be able to provide a visual indication of whether or not a card matches a user stored in memory.
  4. Be stand alone, meaning does not require a computer to reprogram a user’s stored card/ID.
  5. Have some basic security measures to prevent just anyone from reprogramming the device.
  6. When a match is found, activate an output pin that will be connected to a relay in order to control stuff.

To meet these requirements the following hardware components were chosen:

  1. Arduino Uno
  2. Parallax RFID Reader #28140
  3. 16×2 Liquid Crystal Display
  4. Tactile Switches
  5. Assorted resistors
  6. Multi-turn Potentiometer
  7. Two LEDs (Green and Red)

I started off by putting together some basic hardware on a breadboard and focused on the major functional items. This was namely getting data from the reader to the Arduino Uno. Luckily Parallax provided a great code example that made this function pretty straight forward. At first I was connecting the reader to the Rx pin on the Arduino, but this would mean I had to unplug it every time I wanted to upload new code to the Uno. To overcome this issue and the limited serial interfaces of the Arduino Uno, I used the Software Serial library provided as part of the core Arduino libraries to set up a software Serial interface on two available digital pins.  It was very helpful having the reader on a different serial interface, as I could upload new code without modifying the connections and I could continue to use the normal serial interface of the Uno for trouble shooting/debugging.

With the RFID reader squared away, the next thing to tackle was reading existing users from EEPROM and comparing the resulting char array with the string provided by the RFID reader. This was pretty straight forward and did present much of a problem.

The final thing to tackle was the programming interface. To make this device stand alone, it needs to be able to be reprogrammed without uploading new firmware (so no hard coding users) or changed via say a serial interface. To accomplish this I chose to use a standard 16×2 LCD and a few buttons/switches. Effectively what I ended up with was a program button that connects to an interrupt pin (Digital Pin 3), and when pressed it will set a flag to put the device in programming mode. Once the programming mode button is pressed, the user is prompted for the master card. The master card is what ever user is programed in position one. It is possible to also to short another pin to use as a bypass in the event the master card is lost or stolen. Once a master card is read, the user is presented with a the option to scroll through (pressing the next button) until they reach the user they want to program. At that point, the enter button can be pressed to select the user being displayed. The final step in programming is to simply swipe a new card and it will be written to the memory location of the selected user. In the event a card is lost and the associated user position needs to be deleted, the idea is that the master card will be scanned into it’s place to over write the previous data. At any time during the programming event, if a user does not interact with the device it will timeout and go back to the ready to read state.

It didn’t take long to realize that the breadboard version of the project wasn’t robust enough. I decided to use a seedstudio protoshield (I had it lying around) to make a shield for the Arduino Uno. The forth button in this hardware version is to activate the bypass functionality. The final build will not include it. Another decision made at this stage of the build was to use hardware debouncing on the buttons. In the final build debouncing will be done in software.

20161103_182955

Overall all I feel pretty good about the current state of both the hardware and software, but of course there is already a list forming for improvements in the next hardware iteration. Some improve include:

  1. Add a real time clock, to allow for timestamped data logging
  2. Add an SD card for data logging
  3. Add a port expansion card to the LCD to free up some of the I/O pins
  4. Add a transistor to the LCD’s back light’s power to allow it to be turned off when not in use
  5. Consider implementing a sleep mode when the device is not in use for a while

The firmware for the current hardware version can be found on Github at the following link:

https://github.com/bradhenson/RFID_Henson

– Update 11/6/2016 –

The parts for the updated hardware version of the RFID Reader came in faster then I expected. I decided to devote some time this weekend to updating the project to take advantage of some significant hardware changes. The main goal was to add a data logging feature to the device, so I needed a real time clock and SD card reader.  A quick summary of the changes is:

  1. Added an Adafruit data logging shield (this included an SD card reader that uses SPI and a RTC that uses I2C)
  2. Purchased an enclosure from Adafruit, designed for an Uno, a single shield, and LCD
  3. Added a port expansion LCD backpack to free up some pins, uses I2C for communication to the Uno
  4. I used the prototyping area on the shield as a connection point for all the devices in the case.

In this hardware version I needed to use some none standard libraries to get things working properly. I ran into issues initially with the LCD backpack. The one I purchased a while back was a cheap ebay special, and required hunting down a library that would work. I ultimately came across http://arduino-info.wikispaces.com/LCD-Blue-I2C, which worked perfectly for my needs. The part that was messing me up was not removing the standard LiquidCrystal library all together and trusting that the new one would cover it. The library for the backpacks utilizing the PCF8574A chip can be downloaded here: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/NewliquidCrystal_1.3.4.zip.

I used the RTClib library provided on Adafruit’s website and had no issues getting things up and running after reviewing their provided documentation. Check out Adafruit’s website for information on the logging shield: https://learn.adafruit.com/adafruit-data-logger-shield

The amount of memory that the SD card reader requires was a bit surprising. Right off the back, this thing will eat up 50% of your available RAM. My original source code was already using up to 50% of the available 2k of RAM in the Uno, so something had to give. I found that every time I used the print function for writing to an LCD or Serial interface, it was causing the compiler to set aside a little memory space. To stop this from happening I found a good little write up by the Bald Engineer on how to use the macro F() to free up this assignment (https://www.baldengineer.com/arduino-f-macro.html). By following this little trick I got my memory usage down to around 16% before adding the SD card code to it.

Hardware Connections:

  • Arduino 4 to RFID Rx
  • Arduino GND to RFID GND
  • Arduino Digital pin 2 to RFID enable
  • Arduino +5V to RFID VCC pin.
  • Arduino Digital pin 5 used to supply a signal to the locking mechanism
  • Arduino Digital pin 5 has an LED connected to signal when this pin is HIGH
  • Arduino Digital pin 3 used to connect to a button for initiating programming mode
  • Arduino pin 8 used to connect to a button for ENTER
  • Arduino pin 6 used to connect to a button for NEXT
  • Arduino Analog pin 0 used to connect to a Green LED
  • Arduino Analog pin 1 used to connect to a Red LED
  • Arduino Analog pin 9 used for BYPASS
  • Arduino SDA and SCL (I2C) will go to the LCD Backpack
  • Arduino SDA and SCL (I2C) will also connect to the RTC via the shield
  • Arduino 10, 11, 12, 13 (SPI) connect tot he SD card reader via the shield

20161106_195802

20161106_195814

20161111_112408

20161111_112418

Code for this project can be found on my Github page. I branched off the first version to maintain the non-data logging code.

https://github.com/bradhenson/RFID_Henson/blob/master/RFID_HENSON.ino