members
Basics: Project 002c RFID RC522 module, LEDs, LCD2004 i2C module, active piezo buzzer, DS1307 Real T
of Acoptex.com in UNO
Basics: Project 002c
Project name: RFID RC522 module, LEDs, LCD2004 i2C module, active piezo buzzer, DS1307 Real Time Clock (RTC) module - simple Time Attendance System
Tags: Arduino, Arduino Uno, RFID RC522 module, LED, MFRC522 RFID reader, LEDs, LCD2004 i2C module, active piezo buzzer, simple Time Attendance System, DS1307 Real Time Clock (RTC) module
Attachments: DumpInfosketch, library1, library2, Rfidsimplesketchtimeatsketch, library
In this project, you needed these parts :
1.Aruduino Uno R3 (you can also use the other version of Arduino)
2.MFRC522 13.56Mhz IC or RFID RC522 module with tags 1 pc
3.Arduino IDE ( you can download it from here )
4.Jumper cables M-M, F-M
5. LED 2 pc
6. Resistor 2 pc (220 Ohm)
7. Breadboard 1 pc
8. LCD 2004 I2C module (or LCD2004 + I2C Driver module)1 pc
9. Active piezo buzzer 1 pc
10. DS1307 Real Time Clock (RTC) module 1pc
11. Lithium Ion battery LIR2032 3.6 VDC or CR12203VDC or CR2032 3VDC (depends on battery holder and module) 1pc
General
We will learn how to connect MFRC522 RFID Reader, LEDs, active piezo buzeer, DS1307 Real Time Clock (RTC) module and LCD2004 I2C module to Arduino board and use them as simple Time Attendance System.
Understanding the DS1307 Real Time Clock (RTC) module
You can read more about it here.
Understanding the LCD 2004 I2C module
You can read more about it here.
Understanding a piezo buzzer
You can read more about it here.
Understanding the MFRC522 RFID Reader
RFID, or Radio Frequency Identification, is a system for transferring data over short distances (typically less than 6 inches). Often only one of the two devices needs to be powered, while the other is a passive device. This allows for easy use in such things as credit cards, identify people, to make transactions, key fobs, and pet collars as there is no need to worry about battery life. The downsideis that the reader and the information holder (ie credit card) must be very close, and can only hold small amounts of data.
There are cheap RFID modules that can read and write Mifare's tags and being sold at several web stores, like eBay and included with many "starter kits" nowadays. Simply search RFID-RC522 (MF-RC522). The microcontroller and card reader uses SPI for communication (chip supports I2C and UART protocols but not implemented on library). The card reader and the tags communicate using a 13.56MHz electromagnetic field. (ISO 14443A standart tags).
For example, you can use an RFID system to open a door - only the person with the right information on his card is allowed to enter. An RFID system uses:
- tags attached to the object to be identified, in this example we have a keychain and an electromagnetic card. Each tag has his own identification (UID).
- two-way radio transmitter-receiver, the reader, that send a signal to the tag and read its response.
More information about RFID here.
Signals and connections of the LCD 2004 I2C module
As you can see on the back of LCD 2004 I2C module there 4 connections: GND (-), VCC (+5V), Serial Data Line (SDA) (Arduino Uno SDA or Analog pin A4) and Serial Clock Line (SCL) (Arduino Uno SCL or Analog pin A5).
Signals and connections of the DS1307 Real Time Clock (RTC) module
GND - ground pin.
VCC - power supply pin 5V or 3.3V.
SDA - I2C interface data pin.
SCL - I2C interface clock pin.
Signals and connections of active piezo buzzer
Active piezo buzzer pin marked with (+) sign should be connected to Arduino Uno board digital pin which sends a signal, the other pin of active piezo buzzer should be connected to Arduino Uno board GND.
Signals and connections of LED
The operating voltage of the LED is 1.8V and the operating current is 10mA-20mA. The Arduino Uno board can supply 5V or 3.3V power. We will use 5V for this project, so the minimum resistance of the current limiting resistor should be (5 V to 1.8 V)/20 = 160 Om. The 220 Om offered in the kit is suitable and you can also choose other resistors that meet the condition. The larger the resistance is, the dimmer the LED will get.
Signals and contacts of RFID RC522
The MFRC522 RFID reader works at 3.3V and it can use SPI or I2C communication. The library we’re going to use to control the RFID reader only supports SPI, so that’s the communication protocol we’re going to use.
GND - ground pin.
SDA - I2C interface data pin.
CLK (or SCK) (Serial Clock) - The clock pulses which synchronize data transmission generated by the master
MOSI (or DI or SI or CMD) (Master Out Slave In) - The Master line for sending data to the peripherals
MISO (or DO or SO) (Master In Slave Out) - The Slave line for sending data to the master
IRQ - interrupt pin. Not in use
RST - reset pin.
3.3V - power supply pin 3.3V.
Wiring
Cautions:
- On the Arduino many of the pins are not swappable. Because RFID module uses the SPI bus, who’s pins cannot be moved around, pins 11, 12, 13 must remain as shown. RST and IRQ are user specified.
- RFID module is NOT a 5 volt powered device. You MUST power it with 3.3 volts. If you do not, you risk overheating the RFID. Most Arduino boards include a 3.3V supply pin which can be used to power the RFID module.
- Different Arduino boards have different SPI pins. If you’re using another Arduino board, check the Arduino SPI documentation.
RFID RC522 module pin Arduino Uno
SDA Digital pin 10
SCK Digital pin 13
MOSI Digital pin 11
MISO Digital pin 12
IRQ Not in use
GND GND
RST Digital pin 9
3.3V 3.3V
LCD 2004 I2C module and DS1307 Real Time Clock (RTC) module use I2C communication. This means that they communicate with the Arduino using just 2 pins. For Arduino Uno - Serial Data Line (SDA) (Arduino Uno SDA or Analog pin A4) and Serial Clock Line (SCL) (Arduino Uno SCL or Analog pin A5).
If you’re using other Arduino board rather than the Uno, check out what are their SCL and SDA pins.
- Nano: SDA (A4); SCL(A5)
- MEGA: SDA (20); SCL(21)
- Leonardo: SDA (20); SCL(21)
The following picture shows the needed connections with the Arduino Uno
Step by Step instruction
- Do wiring. As in this project there are 3.3V and 5V modules, make sure that you wire them in correct way - check the recommend voltage before powering the circuit. We suggest you to wire one module at a time.
- Open Arduino IDE.
- Plug your Adruino Uno board into your PC and select the correct board and com port
- Find your LCD2004 I2C address. Each device has an I2C address that it uses to accept commands or send messages. Load the sketch over at http://playground.arduino.cc/Main/I2cScanner and follow the instructions to use it. By opening up the Serial monitor window after you upload the sketch, Arduino will scan the address range looking for a reply. Even though the documentation said it was 0x27, this scanner can detect different (in our case 0x3F).
- Modify the sketch in attachments above (you can use the sketch below too): the line LiquidCrystal_I2Clcd (0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE) (See part marked bold).
- First we need to read data from a RFID tag. Verify and upload the DumpInfosketch to your Arduino Uno. Open serial monitor at 9600 bps. When you put an RFID tag next to the RFID reader, you will see a bunch of numbers pop out.
- This is the information that you can read from the RFID tag, including the card UID. The information is stored in the memory that is divided into segments and blocks. You have 1024 bytes of data storage divided into 16 sectors and each sector is protected by two different keys, A and B. Write down your UID card as you will need it later.
- Modify Rfidsimplesketchaccesssketch in the line if (content.substring(1) == “YOUR CARD UID”) type the UID of your card or tag you have written previously, define check in time.
- Verify and upload the Rfidsimplesketchtimeatsketch to your Arduino Uno. Open serial monitor at 9600 bps.
- When you put an RFID tag next to the RFID reader, you will see number of RFID tag/card and status. It will be in Serial monitor and on LCD screen. You will also see the status with the green/red LED. If the user is late or the card is not valid, the red LED lights up; if the user is on time, the green LED lights up.
Code
The following lines create variables to define the check in time hour and minute. In this case, we’re defining the check in hour to 16h50m. You can change the check in time by changing these values:
// Define check in time
const int checkInHour = 16;
const int checkInMinute = 50;
You also need to create variables to hold the user’s check in hour. These variables will save the hour a certain UID tag was read. The following variables hold the check in hour and the check in minute.
//Variable to hold user check in
int userCheckInHour;
int userCheckInMinute;
It also saves the user check In hour and minute in the following variables for further comparison with the predefined check in time.
userCheckInHour = now.hour();
userCheckInMinute = now.minute();
The verifyCheckIn() function simply compares the user check in time with the predefined check in hour and gives feedback accordingly.
If the user is late or the card is not valid, the red LED lights up; if the user is on time, the green LED lights up.
Summary
We have learnt how to connect MFRC522 RFID Reader, LEDs, active piezo buzeer, DS1307 Real Time Clock (RTC) module and LCD2004 I2C module to Arduino board and use them as simple Time Attendance System.
Libraries:
- All libraries attached on the begining of the project description.
- MFRC522 library. Download, unzip and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. You can read about it here.
- SPI library included in Arduino IDE.
- Wire library included in Arduino IDE.
- RTClib library. Download, unzip and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. You can read about it here.
- We have used the library - NewliquidCrystal_1.3.4.zip which we downloaded, unzipped, changed the name of folder to LiquidCristal and added to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. If you have LiquidCristal folder in this location already - delete this folder and copy folder, which was made by you, to this location.
Sketch:
- See attachment on the begining of this project
Other projects of Acoptex.com










Viewed: 3379 times