Interfacing EM-18 μRFID reader Wiegand26 with Arduino UNO
The communications protocol used on a Wiegand interface is known as the Wiegand protocol. The original Wiegand format had one parity bit, 8 bits of facility code, 16 bits of ID code, and a trailing parity bit for a total of 26 bits.
RFID is Radio Frequency Identification. An RFID reader is used to read RFID tags (which contain certain unique data stored in a chip). An RFID reader and an RFID tag, both have a coil surrounding them. When an RFID tag is shown near an RFID Reader, it collects the unique tag data (a combination of digits and characters) from the RFID tag. Power the μRFID reader; when an RFID tag is shown near the reader, electromagnetic induction will take place between the coils and this powers the chip inside tag. This chip will send data electromagnetically to the reader. The reader will receive this electromagnetically transferred data and output is in Wiegand format. We can collect the data by interfacing GPIO pins using arduino.
Wiegand26 communication can be enabled by giving low value to the SEL pin of the reader. The Wiegand interface uses two data transmission pins usually called DATA0 and DATA1, alternately labeled “D0″ and “D1″ or “Data Low” and “Data High”. When no data is being sent, both DATA0 and DATA1 are pulled up to the “high” voltage level usually, 3.3 – 5.5 V DC. When a 0 is sent the DATA0 wire is pulled to a low voltage while the DATA1 wire stays at a high voltage. When a 1 is sent the DATA1 wire is pulled to a low voltage while DATA0 stays at a high voltage. The DSO output of D0 and D1 pins are shown below.
The output in this mode is based on the table below-Note:
E: Summed for even parity
O: Summed for odd parity
P: Parity(even or odd)
D: Data code for card
Interfacing μRFID reader Wiegand26 with Arduino Uno
Arduino Uno is an open source physical computing platform based on ATmega328 microcontroller and provides a development environment for writing software for the board. It can be used for a variety of projects.A Wiegand format compatible output obtained by reading data pins connected directly to Arduino. Make sure you connect Ground Pin of RFID reader to Ground Pin of Arduino.
Sample Code to read Wiegand26 data via Arduino UNO
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
#include <LiquidCrystal.h> // Header inclusion char Card_No[27]; char rfid_N0[27]="00000100000101100100010111"; int D0=4,D1=5,d0=1,d1=1,j=0; LiquidCrystal lcd(6, 7, 12, 11, 10, 9); void setup() { pinMode(D0, INPUT); // Initialize the digital pin as an input. pinMode(D1, INPUT); // Initialize the digital pin as an input. lcd.begin(16, 2); // Set up the LCD's number of columns and rows: lcd.setCursor(0,0); // Position the LCD cursor lcd.print("RFID Based Login"); // Print a message to the LCD. lcd.setCursor(0,1); // Position the LCD cursor lcd.print(" System "); Serial.begin(9600); // Initialize the serial communications: delay(4000); lcd.clear(); lcd.setCursor(0,0); lcd.print("Use your Tag to "); lcd.setCursor(0,1); lcd.print("Login "); } void loop() { while((d0&d1)) { // Intake of RFID_data to GPIO pin d0=digitalRead(D0); d1=digitalRead(D1); } if(d0==0&&d1==1) Card_No[j]='0'; // Sent '0' if(d1==0&&d0==1) Card_No[j]='1'; // Sent '1' j++; while(!(d0&d1)) { d0=digitalRead(D0); d1=digitalRead(D1); } if(j>=26) // Store the 26 character { lcd.clear(); lcd.setCursor(0,0); lcd.setCursor(0,0); lcd.print("Found "); delay(500); lcd.setCursor(0,0); lcd.print("ID: "); lcd.setCursor(3,0); for(j=0;j<=12;j++) // Save first 13 data { lcd.write(Card_No[j]); } lcd.setCursor(3,1); for(j=13;j<=25;j++) // Save last 13 data { lcd.write(Card_No[j]); } j=0;delay(2000); lcd.clear(); if(!strcmp(rfid_N0,Card_No)) // Matching found in read_data & card_id { lcd.setCursor(0,0); lcd.print("Login Succeeded "); delay(3000); lcd.clear(); lcd.print(" THANK YOU "); delay(2000); } else // No matching found in read_data & card_id { lcd.setCursor(0,0); lcd.print("Login Failed "); delay(3000); } lcd.setCursor(0,0); // Go for read data again lcd.print("Use your Tag to "); lcd.setCursor(0,1); lcd.print("Login "); } } |
Upload the program
Resources
- Software
- Data sheet
- Example Projects
- Interfacing μRFID reader TTL protocol with Arduino Uno
- Interfacing μRFID reader Wiegand26 with Arduino Uno
- Interfacing μRFID reader TTL protocol with AT89S52
- Interfacing μRFID reader Wiegand26 with AT89S52
How to Buy?
Support
Please share your ideas with us, visit our forum for discussion
Frequently Asked Questions(FAQ):
Q. What is the frequency range of μRFID reader?
Ans. The operating frequency range of RFID card is 125kHz.
Q. What are the protocols μRFID reader supported?
Ans. There are two supported protocols namely TTL Serial & Wiegand 26 as per the system design.