April 1, 2012

Arduino RFID (part 2)

(... continued from part 1)

Just because the HR people loved something doesn't mean the management loved it. When the HR guys presented the Arduino RFID scanner connected to a PC with huge LCD TV's that displays employee photos to the management, the management people immediately asked, who watches the photos, and who watches the watchers?

Okay... back to the drawing board. I had previously hooked up my 16x2 character LCD display as a backup display in case the TV's blow up, I decided to take the idea further. I also decided since we're no longer going to use large LCD TV's, there's no point in hooking up a computer any more, and perhaps I could make the whole thing self-contained...

More importantly, being self-contained means I need connectivity directly from the Arduino, so I added an Ethernet Shield to the setup. The Ethernet Shield has a MicroSD slot that could be used to log data. In order to more clearly show whose card was scanned, I decided to not use the Mifare card's UID, but instead will write the employee name into the card. This way, the employee can see her name shown on the LCD display when she clocks in or out.

Of course, going standalone also means I need RTC and/or NTP. Using NTP seemed to be problematic at first (appears to be fixed in Arduino 1.0.1), and I also wanted my RFID box to be completely standalone, so I added a DS3232 module. The DS3232 would normally keep very accurate time, but a nightly housekeeping function would sync it with NTP if the NTP time is sufficiently similar to the RTC time. The housekeeping function also renews the DHCP lease.

When a card is successfully scanned, the current date and time, the card's UID, and the employee data stored on the card are saved to the MicroSD card. The employee data is then shown on the LCD display. The data is logged on the MicroSD card as plain text files, grouped into year directories and each day is separated into a single file. e.g. entries logged on April 1, 2012 would be saved in /2012/20120401.csv

Entries can be read off the MicroSD card by opening a web browser and going to http://[ip]/20120401 and the CSV file would be displayed in the web browser. I used the cheapest 4GB MicroSD card I could find, and by my calculation, it has enough storage for around 200 years or the Rapture, whichever comes first.

Special admin cards can be created by writing a special employee code to the card. When this card is scanned, pre-determined actions can be performed. In my case, I use the special cards to switch the RFID box from clock-in to clock-out and vice versa. Clock-in/out status are also shown on the LCD display in Thai by using custom characters, and the status is also stored into EEPROM. Because the 16x2 LCD has limited space, I chose to show the day of the week, the current time, and clock-in/out status on the top row. When a card is scanned, the employee name is shown on the bottom row.

After implementing the admin card function, I also added the clock-in/out status as well as the MAC address of the RFID box into the log. This is because we will actually have more than one reader, and it's necessary to differentiate whether the employee is clocking in or out, and at which reader.

In order to write employee data to the Mifare cards, I added some code to make the RFID box as a writer too. I haven't written a nice custom interface for Windows yet, so I'm only using a terminal program. Sending 'a' to the Arduino puts the RFID box into admin mode which allows initializing new Mifare cards and writing, reading, or deleting employee data from the Mifare cards.

(Continued in part 3...)

5 comments:

audio brisbane said...

Now that is an impressive show of ingenuity. I honestly would never have thought of something like that.

Anonymous said...

what happens when someone forgets to clock in or forgets to clock out? is there a user interface that HR uses?

FRiC said...

The Arduino RFID boxes simply gather RFID data from the employee cards. I have a "back end" application that pulls in the data regularly and stores them in a database. Part 3 (and maybe 4) will have more detail.

Dan said...

I have recently installed one 50 card arduino, SL018 access controller door opener. I have not implemented a PC interface, nor storage nor a real time clock.

I am very interested in your code and progress. I hope you can document it all.

I will be installing two more units and I would like additional features if possible.

One problem I encountered was that the door relase needed 12VAC and that switching this using a relay caused interference which caused the SL018 I2C interface to go a bit nuts and reset. I solved the problem by using a solid state relay with zero crossing detector. This elimated the spark which was causing the interference. The I2C interface is designed only for short lengths while commercial units use RS485 interfaces.

FRiC said...

Dan, interesting project! I thought about access control, but wasn't sure how I would go about implementing it. SSR would be the way to go.

I'm quite busy recently (see my most recent post) but I've already got a follow-up RFID post mostly written, and will post the source code too.