In this we will learn how to control electronic appliances using RFID cards or you can say Electronic appliance control by RFID card in the easiest manner.
You can see here Pin Configuration of EM18 reader module, working of RFID system then circuit diagram then Arduino programming code and explanation.
For detail RFID system you can read these topics TECHNICAL SPECIFICATION, RFID SYSTEM, WORKING MECHANISM and Interfacing of EM18 RFID with Arduino
EM18 RFID PIN CONFIGURATION
EM-18 is a nine pin device. Among nine pins, 2 pins are not connected, so we basically have to consider seven terminals.
Pin Number |
Description |
VCC |
Connect to the positive of the power source. |
GND |
Connected to the ground. |
BUZZ |
Connect to BUZZER if used |
NC |
No Connection |
NC |
No Connection |
SEL |
SEL=1 then o/p =RS232 SEL=0 then o/p=WEIGAND |
TX |
DATA send through TX using RS232 communication |
DATA1 |
WEIGAND interface DATA HIGH pin |
DATA0 |
WEIGAND interface DATA LOW pin |
EM18 RFID WORKING MECHANISM
- When an RFID tag comes in the range of signal transmitted by the reader (10 cm for EM18), the transponder of the tag is hit by this signal.
- RFID tag induced power from the electromagnetic field which is generated by the reader.
- Then, the transponder converts that radio signal into usable power and after getting power, the transponder sends all the data/information it has stored in the chip, such as a unique ID to the RFID reader in the form of radio waves or RF signal.
- Then, RFID reader reads the data/unique ID (in the form of byte) & transmits it through serial Tx (transmit) pin from reader to Rx of microcontroller serially using UART communication.
There are various RFID readers available according to their frequency
ELECTRONIC APPLIANCE CONTROL BY RFID – CIRCUIT DIAGRAM
RFID ARDUINO CODE
// Defining LED pin #define led 3 // RFID TAG UNIQUE ID String s = "0200D844B729"; void setup() { Serial.begin(9600); pinMode(led, OUTPUT); } void loop() { if (Serial.available() > 0) { String st = Serial.readString(); if (s == st) { Serial.print(" Matched "); appliance(); } else { Serial.print(" Card Not Matched "); } delay(500); } } void appliance() { int bs = digitalRead(led); if (bs == HIGH) { digitalWrite(led, LOW); delay(500); } else if (bs == LOW) { digitalWrite(led, HIGH); delay(500); } }
PROGRAMMING CODE EXPLANATION
- Defining a led as 3
- Initialize String ‘s’ with the value read from previous code
- In void setup(), setting baud rate 9600 and pin 3 as output
- In void loop(), if serial data is present read and store it in the string ‘st’ and if the string ‘st’ is the same as the string ‘s’, print a message “matched” (can be changed) for the user on Serial monitor. As it is matched, call a user-defined function appliance() where
- We read the state of pin 3 where we connected led, if the state is read as HIGH means led is glowing then turn it ON & if the state is read as LOW means led is OFF then turn it ON.
- And if the string ‘st’ is different from the string ‘s’, show a message to user card not matched or unknown card
OUTPUT
Once you upload the code in Arduino, when you cross RFID TAG or slide near the RFID READER MODULE EM18 then LED will turn ON and if you again pass it through then it will turn OFF the LED. In both cases it confirms first the state of LED either ON or OFF through pin state either HIGH or LOW.
READ NEXT
RFID APPLICATION