8051 – RFID Interfacing

In this tutorial we are going to see RFID interfacing with 8051. So in this tutorial we will use EM18 RFID Reader Module. Because it will give the data via serial communication. Before interfacing please have a look at How Does RFID Works?

Suggest to Read

Why EM18?

EM-18 RFID reader is one of the commonly used RFID reader to read 125KHz tags. It features low cost, low power consumption, small form factor and easy to use. It provides both UART and Wiegand26 output formats. It can be directly interfaced with microcontrollers using UART and with PC using an RS232 converter. Just power the module, and it will read any RFID card within range.

It will output the cards ID in a serial string, which can easily be read by any microcontroller. The spacing on the pins is 2.54 mm, which means the module will directly fit on a breadboard.

Features

  • 5V supply
  • 125kHz read frequency
  • EM4001 64-bit RFID tag compatible
  • 9600bps TTL and RS232 output
  • Magnetic stripe emulation output
  • 100mm read range

RFID Interfacing With 8051

Circuit Diagram

The full circuit diagram for interfacing RFID module to 8051 is shown below. The unique ID code in the RFID card is read by the circuit and displayed on the 16×2 LCD display.

LCD:

  • RS – P0.5
  • RW – P0.6
  • EN – P0.7
  • Data Lines – P2

EM18 (RFID Reader):

  • RFID Reader TX – P3.0

Programming

Programming Steps

  1. Initialize the LCD
  2. Initialize the Serial Communication (9600 BaudRate)
  3. Receive the 12 bytes and display it into the LCD Display

In this tutorial I’ve displayed the 12 bytes id. But you can play with that bytes. For example, You can verify the number. If it is matching you can run the motor.

Code

In this code i’m reading the unique id number using polling method. You can also try using serial interrupt.

You can try this code with hardware. If you have any doubt please ask us.

 

Download our new Android app. You can learn all Embedded Tutorials from your Android Phone easily.

Click Here to Download App!