EM18 RFID Reader Interface with AVR ATmega16/ATmega32.

EM18 RFID reader module used to read 125 kHz RFID card wirelessly for a very short distance. It is generally used in applications like attendance system, access management, tracking of goods, etc.

16.3k views1 min readUpdated Aug 9, 2023

Overview of RFID

EM18 RFID reader module is used to read RFID cards that work at 125 kHz.

When an RFID card comes in the range of the reader, the unique data in the card is received by the reader in the form of an RF signal.

The reader then transmits this data in byte form on its serial transmit pin.

This data can be read by a microcontroller using USART communication or can be viewed on the PC terminal.

For more information on EM18 RFID reader and how to use it, refer to the topic RFID Reader EM18  in the sensors and modules section.

For information on USART in ATmega 16 and how to use it, refer to the topic on USART in AVR Atmega16/ATmega32 in the ATmega inside section.                                        

EM18 RFID Reader
EM18 RFID Reader

 

Connection Diagram of RFID with ATmega16/32

Interfacing EM18 RFID Reader With ATmega 16/32
Interfacing EM18 RFID Reader With ATmega 16/32

 

Read RFID Tag and display on LCD16x32 using Atmega16/32

Read the RFID tags using an EM-18 RFID reader and send this data serially to the AVR ATmega16/ATmega32 microcontroller. Then, display the 12 Byte unique ID on the LCD16x2 display.  

RFID Reader Code for ATmega16/32

  • Initialize USART communication.
  • Initialize the LCD16x2 display.
  • Now, wait for 12-byte to receive and then display it on LCD16x2.

Program

/*
 * ATmega16_RFID_Project_File.c
 *
 * http://www.electronicwings.com
 */ 

#define F_CPU 8000000UL
#include <avr/io.h>
#include <string.h>
#include "USART_RS232_H_file.h"  /* add USART library */
#include "LCD16x2_4bit.h"  /* add LDC16x2 library */
#include <util/delay.h>

int main()
{
	char RFID[15];
	USART_Init(9600);  /* initialize USART with 9600 baud rate */
	lcdinit();  /* initialize LCD16x2 display */
	lcd_clear();
	lcd_gotoxy(0,0);  /* Set row and column position at 0,0 */		
	memset(RFID,0,15);
	lcd_print("RFID:");
	while(1)
	{	
		for (int i=0;i<12;i++)
		{
			RFID[i]=USART_RxChar();
		}
		_delay_us(10);
		lcd_gotoxy(0,1);
		lcd_print(RFID);  /* print 12 digit tag number on LCD */
	}  
}

 

Video of RFID reader using ATmega16/32

Components Used

Powered byMouser Electronics
  • ATmega 16

    ATmega 16

    556-ATMEGA16L-8PU

  • Atmega32

    Atmega32

    556-ATMEGA32-16PU

  • RFID Reader EM18

    RFID Reader EM18

    × 1

    EM18 RFID reader module is used to read 125 kHz RFID card wirelessly for a very short distance. It is generally used in applications like attendance system, access management, tracking of goods etc.

  • LCD16x2 Display

    LCD16x2 Display

    485-1447

Downloads

Comments3

Join the discussion — share a question or tip.

  • RJ
    rj5547884

    how can i print the card no. on lcd using usart interrupt. i tried to use interrupt but the random values started displaying on the lcd .please help me as soon as possible. if possible please provide the code using interrupt.

  • RJ
    rj5547884

    how can i print the card no. on lcd using usart interrupt. i tried to use interrupt but the random values started displaying on the lcd .please help me as soon as possible. if possible please provide the code using interrupt.

  • MA
    manishroshan2010

    the code is not working kindly explain the hardware part of this project because the prog and hardware part also doesn't match, though i have corrected my hardware still the code is not working.