March 12, 2012

Arduino RFID (part 1)



This Arduino thing is addicting. Recently, we were looking for a new employee time attendance system (the old one went away with the flood) and since almost everything available locally is either garbage or overpriced (often both), I decided we should roll our own.

I've heard of the Stronglink SL018 while reading about Arduino libraries. The SL018 is a Mifare reader/writer module that uses I2C. It's available locally for cheap and someone had already written an Arduino library for it. The library had not been updated for 1.0 but I updated it by simply changing a few lines.

After hooking the SL018 module to my Arduino, I wrote a little sketch to send the Mifare card's UID to the connected computer over serial port. On the very first try, I discovered I could scan two cards simultaneously by holding the two cards slightly apart, as if holding playing cards. That's not very good for an employee attendance system. Fortunately, the SL018 has a TagSta[tus] pin that simply outputs LOW if a card is present, so I modified the sketch a little bit to ignore further readings unless the TagSta pin has been reset by removing the card.

The SL018 module also has a red user controllable LED, so I modified the sketch a bit more to make the LED light up if the same card is scanned for the second time without sending the data over the serial port. (This is because we have technophobic employees who don't trust anything electronic, and will stand in front of the reader and scan their cards hundreds of times, just to make sure the data is actually stored. I'm not making this up.)

On the computer end, I wrote a little demo program to receive the UID from the serial port, play a wav file, display a jpg image ("employee photo") using the UID as the filename, and record the UID along with the timestamp. I suggested that we could use large LCD TV's instead of a computer to display the employe photos, and the HR people loved the whole setup and idea.

(Continued in part 2...)