HOME

PROJECTS

TUTORIALS

C FUNCTIONS

PROGRAMS

PRODUCTS

VIDEOS

COMPANY

SPANISH

                 

  RFID, RC522, SPI module connected to Bolt 18F2550, with visualization of data in mobile smartphone.

Author: Moises Melendez Reyes

 

 

 

RFID-SPI SYSTEM WITH DISPLAY OF DATA ON MOBILE PHONE

 

RFID-SPI SYSTEM WITH DISPLAY OF DATA ON LAPTOP WITH BLUETOOTH LINK

 

RFID-SPI SYSTEM WITH DISPLAY OF DATA ON LAPTOP WITH USB-SERIAL CABLE

 

OVERVIEW:

The so called Syncronous Periferal Interface (SPI) protocol has become a popular technique to transmit information between 2 microcontroller devices at a a high speed, and short distances.

On the other hand, with the emergence of smartphones, which already have their own operating system, it is possible to develop applications using Bluetooth for the wireless links between mobile devices and microcontrollers.

In this project, a Samsung Galaxy mobile is used as a receiver and display of the RFID data. The connection between an MF522 RFID read-write device, (or RC522 RFID), with operating frequency of 13.56 MHz, SPI interface, and a Bolt 18F2550 system is described. The system can be used in the following applications: access control, attendance control, public transportation, parking of vehicles, electronic payment systems, inventory control, and many others.

See here a tutorial over the SPI interface

 

THE ISO-14443A S50 TAGS:

The MF522 RFID read-write device receives information from an RFID ISO-14443A tag, CARD-TAG-MF1S503. These tags are sold in presentation of card or keychain. In this project, a keychain tag (blue color) was used, as shown in the picture above. This card contains an EEPROM with 1 Kb of available space for data. Complete documentation over the ISO-14443A tags here:

CARD-TAG-MF1S503.pdf

APPLICATION-NOTE-ISO-14443A-S50.pdf

 

THE BLUETOOTH LINK:

To establish communication between the microcontroller and the mobile, a bluetooth module HC-06 with serial port, which allows the transmission of RFID data received by the Bolt board to the mobile phone is used. This link, which is a Class 2 in the Bluetooth standard, can operate up to a distance of 10 meters.

 

TESTING THE SYSTEM:

To test the system, you must assemble the test equipment as shown in the photos above. Its functioning in any of the modes -explained in the following paragraphs- requires that the proper firmware had been previously loaded to the Bolt system.

In all cases, you must bring the tag at an aproximate distance of 5 cms from the MF522 device and remain in that position until you receive a confirmation on the mobile phone. The summary of the system working in each mode is as follows:

Reading the tag: the user brings the tag (blue key) near to MF522 device. At that time, automatically and through SPI communication, the system reads part or all of the EEPROM memory of the tag. This information is sorted, tabulated and transmitted to the serial port in Bolt board, which has already inserted a HC-06 Bluetooth module. The information is transmitted wirelessly from the Bolt system to the mobile phone, where the user can see it.

Erasing data tag: the user brings the tag near to MF522 device. On the mobile phone you will see confirmation of the erasing each sector of the entire EEPROM.

Writing new data to the tag: the user brings the tag near to MF522 device. Automatically, the system will write the new data to the EEPROM of tag, sending confirmation to the mobile phone.

 

BLUETERM APPLICATION FOR THE MOBILE PHONE:

To display the data read from the RFID tag, the mobile phone must run the application called 'Blueterm', compatible with the Android operating system, which is a terminal emulator application which allows you to send or receive ASCII strings through the Bluetooth link already built into the phone (this application is equivalent to the 'Hyperterminal' software for Windows). This program is free and can be directly downloaded to your mobile phone from the Google Play website.

To properly configure the Bluetooth functionality in your mobile as well as the BlueTerm program, please go to this link

 

CONECTION BETWEEN THE BOLT 18F2550 BOARD AND THE MF522, RC522 RFID-SPI CARD:

As shown in the figure above, the Bolt card connects to an external wall transformer, which provides the overall system power. To feed the MF522 RFID card, a 3.3 volt regulator is used. The data transfer between the card and the MF522 Bolt is performed using an interface with the SPI standard. The diagram of connections between the two systems is shown in the figures below:

 

To connect both systems, use color cables to identify all signals:

 

AVAILABLE FIRMWARE FUNCTIONS:

The firmware functions developed for Bolt system include: reading the serial number of the card or tag, reading the entire EEPROM of tag either in hexadecimal or ASCII format (64 sectors, 4 blocks per sector 768 locations of read/write ), erasing the EEPROM memory, and writing new ASCII text data in the tag.

These functions provide a general basis by which programmers can develop specialized RFID applications aimed at solving specific problems. The programs were developed using the C18 compiler and MPLAB IDE tools.

 

1. READING DATA FROM THE TAGS EEPROM:

For a general system test, the following program for the Bolt 18F2550 system was developed . This program allows the use of 3 functions, selected by the dip switches on the Bolt card.

*** IMPORTANT *** For the data to be neatly in the screen of your mobile, you need to configure the program 'BlueTerm' as shown in the attached photos, to replace all received CR characters with CRLF. If you omit this step, the characters will appear superimposed and impossible to read.

Open on your mobile the BlueTerm app and choose the following options:

On the menú 'Preferences', option 'Incoming End of Line CR character'

 

And now choose option 'Replace with CRLF'

 

To read data from the tag's EEPROM, download the complete MPLAB-IDE-C18 project here:  MFRC522-C18-5.zip. You must load the .hex file to your Bolt board and move the dip switches accordingly to the desired function. The reset button must be pushed to activate any of the functions.

Position of dip switches SW1..SW4

Function performed

Comments

SW1=ON, the rest OFF showSerialNumber( ) When the tag is near the RFID module, sends to mobile the serial number of the tag.
SW2=ON, the rest OFF readDataHEX( ) When the tag is near the RFID module, sends to mobile the whole contents of the EEPROM memory of tag (1 Kb) in hexadecimal format.
SW3=ON, the rest OFF readDataASCII( ) When the tag is near the RFID module, sends to mobile the whole contents of the EEPROM memory of tag (1 Kb) in ASCII format.

Example of data read from the RFID tag and transmitted to the user on his mobile phone, running BlueTerm application. Data of the EEPROM can be modified using the firmware for Bolt described in point 3.

Reading the tag's serial number:

Reading the tag's EEPROM information in hexadecimal format:

Reading the tag's EEPROM information in ASCII codes:

 

2. TO ERASE ALL EPROM MEMORY:

Additionally, to erase the memory of the TAG, the following firmware is used. Load the hex file from the following folder to Bolt system.

 To completely erase the EEPROM memory of tag: PROJECT-C18-MPLAB-RFID-CLEAR-TAG.zip

 

3. TO WRITE NEW DATA INTO THE TAGS EEPROM:

Writing new data to the tag requires the user interaction with the MPLAB and C18 compiler tools and modifying the text and then compile the program and load it into the Bolt system, which will send this new data to the MF522 and then to the tag. Please read the instructions described in the source program .c included in the following folder to modify the new data you wish to write to the tag.

To write new data into the EEPROM of tag: PROJECT-C18-MPLAB-RFID-WRITE-EEPROM-TAG.zip

Summary of erase and write funtions:

Function:

Comments:

clearTagsMemory( ) To erase the tag memory (1 Kb), bring it near the MF522 device until you see the confirmation in mobile.
writeTagBlockMemory( ) With this function you may write on 1 sector (16 bytes) of the EEPROM tag memory. Please follow instructions given in the source .c file of the MPLAB project. You must bring the tag near the MF522 or RC522 module to write the new data and wait for confirmation on your mobile phone.

 

OTHER RFID RECOMMENDED LINKS:

MF522 RFID module connected to Bolt 18F2550, with visualization of data in mobile smartphone.

 The easiest way to manage RFID: an UART serial port interface

Low cost school attendance RFID system, using an Excel spreadsheet.

The functioning of an RFID 13.56 ISO-14443A S50 read/write tag