(... continued from part 1)
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...)