PIC16F877A – RFID Interfacing

In this tutorial we are going to see RFID Interfacing with PIC16F877A. 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.


  • 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 PIC16F877A

Component Required

  • EM18 Module
  • LCD Module
  • PIC16F877A Development Board

Circuit Diagram

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

RS – RC0
RW – RC1
EN – RC2
Data Lines – Port B

EM18 (RFID Reader):

RFID Reader TX – RC7

rfid interfacing with pic16f877a


Programming Steps

  • Initialize the LCD
  • Initialize the Serial Communication (9600 BaudRate)
  • 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.


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

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

0 0 vote
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Newest Most Voted
Inline Feedbacks
View all comments
February 8, 2018 1:52 AM

How can I recharge in RFID and how can message to respected person when there is low balance .

June 11, 2019 5:23 AM

This code only printing a string , if i show a card no response else some unwanted characters printing i am not yet get exact values

Would love your thoughts, please comment.x
%d bloggers like this: