Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Interfacing RFID with 8051 microcontroller (AT89C51) using serial interrupt- (Part 35/45)

By Himanshu Choudhary October 3, 2010

This topic covers the interfacing of RFID system with microcontroller through serial interrupt. An RFID system consists of a reader device and a transponder. A transponder or tag has a unique serial number which is identified by the reader. RFID tag is applied to products, individuals or animals to identify and track them through this number.

 
The interfacing has been done through AT89C51. The identification code of the tag is also displayed on a 16x2 LCD. The free source code for the program is available in C.

 

 


 

This topic covers the interfacing of RFID system with microcontroller through serial interrupt. An RFID system consists of a reader device and a Interfacing RFID with 8051transponder. A transponder or tag has a unique serial number which is identified by the reader. RFID tag is applied to products, individuals or animals to identify and track them through this number.

The interfacing has been done through AT89C51. The identification code of the tag is also displayed on a 16×2 LCD. The free source code for the program is available in C.

The RFID system interfaced with AT89C51 requires the controller to continuously scan the input from the RFID reader. In this topic, the program has been made more efficient by incorporating a serial interrupt.

Different RFID tags work on different frequencies. Here low frequency, 125 kHz, RFID tags have been used. These tags work within a range of 10 cm. When an RFID tag comes in this range, the reader detects it and sends a unique code of the tag serially. This serial code, consisting of 12 bytes, is received by the microcontroller.

In the program, Timer1 is configured for serial communication. (Refer Timer programming in 8051) The baud rate is set to 9600bps for data transmission. The LCD is initialized to display the code. When a card/tag comes in the proximity of RFID reader, the microcontroller reads the code and sends it to the LCD module.

 

The RFID system interfaced with AT89C51 requires the controller to continuously scan the input from the RFID reader. In this topic, the program has been made more efficient by incorporating a serial interrupt.

Different RFID tags work on different frequencies. Here low frequency, 125 kHz, RFID tags have been used. These tags work within a range of 10 cm. When an RFID tag comes in this range, the reader detects it and sends a unique code of the tag serially. This serial code, consisting of 12 bytes, is received by the microcontroller.

In the program, Timer1 is configured for serial communication. (Refer Timer programming in 8051) The baud rate is set to 9600bps for data transmission. The LCD is initialized to display the code. When a card/tag comes in the proximity of RFID reader, the microcontroller reads the code and sends it to the LCD module.

The serial interrupt is triggered on every reception of one byte of data. Since the identification code of transponder consists of 12 bytes, the flag is also generated 12 times to indicate the byte wise transfer of data. Whenever the serial code is generated by the reader, the interrupt is activated and the data is sent to the receiver pin of microcontroller.

A serial level converter is required for AT89C51 to receive these serial signals. IC MAX232 has been used for this purpose to interface the RFID reader with microcontroller. The circuit connections are as follows:

Receiver1 (R1) of MAX232 has been used for the serial communication. The receiver pin of RFID reader is connected to R1IN (pin13) of MAX232. R1OUT (pin 12) of MAX232 is connected to RxD (P3.0) of microcontroller.

RFID Reader
MAX232
AT89C51
Rx
R1 IN
R1 OUT
Rx
 
Pins 1-3 of port P1 (P1.0, P1.1 & P1.2 respectively) of AT89C51 are connected to the control pins 4-6 LCD. The unique identification code of RFID tag is displayed on the LCD.
 

 

Project Source Code

###

//Program to interface RFID with 8051 microcontroller (AT89C51) using serial interrupt
#include<reg51.h>
unsigned int data_out,command=0x80,temp;
sfr lcd_data_pin=0xA0;//p2 port
sbit rs=P1^0;    // Register select pin
sbit rw=P1^1;    // Read Write pin
sbit en=P1^2;    // Enable pin
unsigned char card_id[12];
unsigned char current_byte = 0;

void delay(unsigned int count)    //Function to provide delay
{
     int i,j;
     for(i=0;i<count;i++)
     for(j=0;j<1275;j++);
}
void lcd_command(unsigned char comm)   //Lcd command funtion
{
     lcd_data_pin=comm;
     en=1;
     rs=0;
     rw=0;
     delay(1);
     en=0;
}
void lcd_data(unsigned char disp)  //Lcd data function
{
     lcd_data_pin=disp;
     en=1;
     rs=1;
     rw=0;
     delay(1);
     en=0;
}
lcd_string(unsigned char *disp)     //Lcd string function 
{
     int x;
     for(x=0;disp[x]!=0;x++)
    {
         lcd_data(disp[x]);
    }
}
void lcd_ini()                  //Function to inisialize the LCD
{
    lcd_command(0x38);           
    delay(5);
    lcd_command(0x0F);        
    delay(5);
    lcd_command(0x80);
    delay(5);
} 

void display()        // Function to display the unique id
{
    unsigned char count;
    lcd_command(0xC1);        //Place cursor to second position of second line
    for(count=0;count<12;count++)
     { 
          lcd_data(card_id[count]);
      }
    current_byte=0;
}

void recieve() interrupt 4     Function to recieve data serialy from RS232 
{
          card_id[current_byte]=SBUF;
          RI=0;                // Reset the serial interrupt after recieving the byte
        current_byte++;    
}

void main()
{
    TMOD=0x20;                            //Enable Timer 1
    TH1=0XFD;
    SCON=0x50;
    TR1=1;
    EA=1;
    ES=1;                                // Trigger Timer 1
    lcd_ini();
    lcd_command(0x81);                    //Place cursor to second position of first line 
    lcd_string("UNIQUE CARD ID:");
    delay(200);
    while(1)
    {
        while(current_byte!=12);    
        display();
    }
}

###

 


Circuit Diagrams

Circuit-Diagram-Interfacing-RFID-8051-Microcontroller-AT89C51-Using-Serial-Interrupt

Project Components

  • AT89C51 Microcontroller
  • LCD
  • MAX232

Project Video


Filed Under: 8051 Microcontroller
Tagged With: 8051, interrupt, microcontroller, rfid, serial
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • How to improve the reliability of RS485 communication?
  • The Analog Gods Hate Me
  • Battery Deep Discharge – IC Workarounds?
  • Safe Current and Power Density Limits in PCB Copper(in A/m² and W/mÂł) simulation
  • Why so few Phase shift full bridge controllers?

RSS Electro-Tech-Online.com Discussions

  • Simple LED Analog Clock Idea
  • The Analog Gods Hate Me
  • Wideband matching an electrically short bowtie antenna; 50 ohm, 434 MHz
  • PIC KIT 3 not able to program dsPIC
  • Parts required for a personal project

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • Tria modules integrate edge AI processing with multi-core processors
  • pSemi introduces RF switch with 52 dBm PMAX,PEAK and 90-dBm IIP3 linearity
  • XP Power launches 1.3 kW power supply with 58.9 W/cmÂł density
  • How to enable Wi-Fi provisioning in ESP32-based IoT products
  • Amphenol RF introduces FAKRA to SMA adapters with 4 GHz operating frequency

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe