Introduction: RFID NFC ARDUINO ACCESS TERMINAL
RFID NFC 13,65Mhz ARDUINO ACCESS TERMINAL - TIMBRATURE
- I needed an access control system for my office, able to log an NFC tag into a mysql database and/or in a text file.
This is a major revision of a previsious version I published some time ago. - I had a spare Aduino Mega and a Ethernet shield at home, so, with a few more components I have been able to build an access control system for my office.
- The board uses two rfid modules, 1 used as log IN, 1 used as log OUT.
- Bonus! - All the main parameters are configurable via json config file (IP, subn, gat, DNS, Ntp server, operation etc.)
- Superbonus! Want more? If you have a 3d printer, I included also a box enclosure for the project :)
Bill of material
- Arduino Mega 2560 r3
- W5100 ethernet shield with microSD
- 2 x rc522 rfid modules
- RTC DS1307 clock module
- LCD display (16,2) (SPI or I2c, as I included both connection methods)
- microSD card
- a couple of leds with 1k resistors
- A php server with mysql database (not needed if you only use SD card to store the data)
Database and MicroSD log can be separately enabld/disabled.
If the db log is enabled, it will log the record into the database.
- I put a php process page into the webserver which will process the db log requests.
At first, it will check for the presence of the tag into a "users" table.
The table contains infact known users and their relative tags (this check could be disabled). - If microSD log is enabled a record will be added to a text file (The the date and time, the tag, in or out operation.
- I added also a lcd to make the things easier for the users. It simply displays clock time and the operazions done. When the access is recorded, a green led will flash for few seconds and a buzzer will play a short tone with increasing pitch. The lcd will show a short ok message for few seconds.
- If some errors occur (as lan not working, or the tag is unknown), a red led will flash instead, and the tone played will have a decreasing pitch. The lcd will show also a short error message for few seconds.
- Also, to manage the microSD log, I added a couple more of green/red led blinks after the db blinks.
A twice beep tone will be played in this case. Either here it will be increasing tone freq for an ok operation.. otherwise the two small tones will be decreasing in frequencies.
Check readme.txt for more tech infos.
// ***************************************************************
Step 1: Here's the Code -
Take care of the code.
I spent several hours programming the board.
Of corse there's still a lot to optimize and improve, so please, if you enjoy, let me know if you liked this project.
I attached some files (some extensions of them must be renamed as I wasn't able to directly upload the files).
What I included
- arduino.ino is the core code of the project. I tried my best to keep the code readable.
- A sql script to create the database. It's a sample, based on my needs, but the entire code could be changed.
For istance, I used two tables: a users table, where I managed to upload and record all the users and the tags. If you enable the user_check on the code, this table will be searched for the user existance. The timbrature table is where the records are stored. I included here a server timestamp column, the rfid, the operation, as IN or OUT (1=IN 0=OUT), the sede (which can be used for futher stuff). A sort of textual string is also added, which contains all this datas. - The config.jsn file - (be careful at the name & extension. SD library accepts only 8 chars and extension of 3 chars). It contains all the parameters that can be modified. When you change something here, the new value will be stored in the eeprom, so it won't be lost. Once stored, the json config file is not need anymore. Its use is intended only for updates. So, just put it in the microSD root, the config will be elaborated at the boot.
- timbratura.php is the server side code that will manage to store the record into the database. I could have put this stuff into the arduino code, but I needed it for some additional private purposes. So it could be to you, to transfer the code into arduino if needed ;)
- the timbr.txt attached shows an example of the data stored into the microSD card (when the microSD log function is enabled).
- libraries.zip - I included all the libraries used, so you don't need to search for them around.
Step 2: Enjoy the Project!
Merlino (the red) and Sibilla (the black) say "Hi" to you. They hope that you appreciated the project. So if you liked it, remember to let us know about it. It's always nice to know to be useful to someone.
Bye, Paolo