Arduino Projects    |   Raspberry Pi  |     Electronic Circuits   |   Electronics Reference Design Library  |   AVR    |    PIC    |    8051    |    Electronic Projects

How to interface RFID with AVR microcontroller (ATmega16)

Summary

Developed By: 
Akshay Daga
Knowingly or unknowingly the RFID technology is used by us in our day to day life. The most familiar example is seen in MNCs, schools and offices for daily attendance or automatic door opening system. The RFID contains two parts, namely, tag and receiver modem. When an RFID tag comes in the range of receiver, the tag gets activated and transmits its unique identification code to the receiver module.
 
The output of the RFID receiver is the unique ID in either serial (RS232) or wiegand format. Most of the receivers are equipped with additional hardware to send the extracted code in the above format, which can then be used by digital signal processors. This article shows the interfacing of ATmega16 with RFID.
 
Interface RFID | RFID Interfacing with AVR Microcontroller (ATmega16)

Description

The RFID module used here gives a 12 byte unique ID of a particular tag in serial RS232 logic level format. Hence a level converter MAX232 is used in between RFID receiver module and microcontroller. The connections of RFID module and ATmega16 are shown in thecircuit diagram. The ground pin of MAX232 and serial output of RFID module is made common.  A cross cable connection is set up between the RFID module and the MAX232 by connecting transmitter pin of one to the receiver pin of the other and vice versa as shown in the circuit diagram.
 
Note: In case the output of the RFID module is in TTL format, there is no need of MAX232. In such a case the output of the RFID module can be directly given to the microcontroller.
 
Pin 2 of max 232
Pin 3 of RFID modem
Pin 3 of max 232
Pin 2 of RFID modem
Pin 5 ground pin of max 232
Pin 5 ground of RFID modem
 
Code description
In order to understand the code for RFID (given below) which is interfaced with ATmega16, one must have a basic knowledge of serial communication and LCD. The serial data from RFID module can be taken by microcontroller either by polling or by using serial interrupt concepts. (To understand the difference between them, refer to tutorial on Interrupts) This article explores the interfacing of RFID module with AVR microcontroller (ATmega16) using the polling technique. The code described here keeps monitoring the serial input till it receives all the twelve bytes from the RFID module.
 
Receiving 12 byte serial interrupt data by polling method:
Steps to receive twelve byte serial data
        i.            Initialize USART in read mode.
       ii.            Get a 12 byte string (RFID card no.)

void getcard_id(void) // Function to get 12 byte ID no. from rfid card
{
for(i=0;i<12;i++) 
{
card[i]= usart_getch(); // receive card value byte by byte
}
return;
}
      iii.            Display that 12 byte data on LCD.

void LCD_display(void) // Function for displaying ID no. on LCD
{
for(i=0;i<12;i++)
{
LCD_write(card[i]); // display card value byte by byte
}
return;
}

Also see RFID interfacing with AVR using interrupts.

Circuit Diagram

Video

Code

This Code is only visible to Registered users. Please Login/Register

 

Components

MAX232 | IC MAX232
MAX232
 
The MAX232 IC is used to convert the TTL/CMOS logic levels to RS232 logic levels during serial communication of microcontrollers with PC. The controller operates at TTL logic level (0-5V) whereas the serial communication in PC works...
16 x 2 LCD | 16x2 Character LCD Module
LCD

 

LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. These modules are preferred over seven segments...

ATmega16 AVR Microcontroller
ATmega16
 
ATmega16 is an 8-bit high performance microcontroller of Atmel’s Mega AVR family with low power consumption. Atmega16 is based on enha...

Browse 4m+ Electronic Products


 
Pick the right product for your next design project with "Mouser Store". Mouser Electronics brings broadest range of semiconductors and electronic components from over 500 industry leading suppliers. 
 
Mouser specializes in the rapid introduction of new products and technologies for design engineers and buyers that includes semiconductors, interconnects, passives, and electro-mechanical components. Providing the best possible service with the flexibility of not requiring a minimum order and same-day shipping, Mouser has it all.
 
 
 
 
When you need the right part right now, think of Mouser
 
Thank you
Team EG

 

Inexpensive, Simple, Easy-to-Use Microcontroller Boards By Texas Instruments

Starting at $9.99 Buy Now

Starting at $17.00 Buy Now

Starting at $12.99 Buy Now

Starting at $12.99 Buy Now

 

You are here