Arduino UNO RFID Reader with I2C LCD Display and Servo Control
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary of the Circuit
This circuit is designed to interface an Arduino UNO with an RFID-RC522 module, a 20x4 LCD display with I2C interface, and a Servomotor SG90. The Arduino UNO acts as the central processing unit, controlling the RFID reader for scanning tags, displaying information on the LCD, and driving the servomotor based on the RFID tags detected. The RFID-RC522 module is used for reading RFID tags, the LCD display shows the scanned tag's UID, and the servomotor is potentially used for a physical response, such as unlocking a mechanism.
Component List
Arduino UNO
- Microcontroller board based on the ATmega328P
- Provides digital I/O pins, analog inputs, and various power outputs
- Interfaces with other components via SPI and I2C protocols
LCD Display 20x4 I2C
- Alphanumeric liquid crystal display
- 20 characters by 4 lines display area
- I2C interface for communication, reducing the number of pins required for interfacing
RFID-RC522
- RFID reader/writer module
- Operates at 13.56 MHz for Near Field Communication (NFC)
- Interfaces with the Arduino UNO via SPI
Servomotor SG90
- Small and lightweight servo motor
- Provides precise control of angular position
- Powered directly from the Arduino UNO
Wiring Details
Arduino UNO
D10connected to RFID-RC522 SDAD13connected to RFID-RC522 SCKD11connected to RFID-RC522 MOSID12connected to RFID-RC522 MISOGNDconnected to GND of all componentsD9connected to RFID-RC522 RST3.3Vconnected to RFID-RC522 3.3V5Vconnected to Servomotor SG90 VCC and LCD Display VCCA4connected to LCD Display SDAA5connected to LCD Display SCLD3connected to Servomotor SG90 SIG
LCD Display 20x4 I2C
SDAconnected to Arduino UNO A4SCLconnected to Arduino UNO A5VCCconnected to Arduino UNO 5VGNDconnected to Arduino UNO GND
RFID-RC522
SDAconnected to Arduino UNO D10SCKconnected to Arduino UNO D13MOSIconnected to Arduino UNO D11MISOconnected to Arduino UNO D12IRQnot connectedGNDconnected to Arduino UNO GNDRSTconnected to Arduino UNO D93.3Vconnected to Arduino UNO 3.3V
Servomotor SG90
SIGconnected to Arduino UNO D3VCCconnected to Arduino UNO 5VGNDconnected to Arduino UNO GND
Documented Code
/*RFID tag scan code
* https://srituhobby.com
*/
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 9
#define SS_PIN 10
byte readCard[4];
byte a = 0;
LiquidCrystal_I2C lcd(0x27, 16, 2);
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
while (!Serial);
SPI.begin();
mfrc522.PCD_Init();
delay(4);
mfrc522.PCD_DumpVersionToSerial();
lcd.setCursor(2, 0);
lcd.print("Put your card");
}
void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return 0;
}
if ( ! mfrc522.PICC_ReadCardSerial()) {
return 0;
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Scanned UID");
a = 0;
Serial.println(F("Scanned PICC's UID:"));
for ( uint8_t i = 0; i < 4; i++) { //
readCard[i] = mfrc522.uid.uidByte[i];
Serial.print(readCard[i], HEX);
Serial.print(" ");
lcd.setCursor(a, 1);
lcd.print(readCard[i], HEX);
lcd.print(" ");
delay(500);
a += 3;
}
Serial.println("");
mfrc522.PICC_HaltA();
return 1;
}
The code provided is for the Arduino UNO and is responsible for initializing the RFID-RC522 module and the LCD display. It continuously checks for new RFID tags. When a tag is detected, it reads the UID and displays it on the LCD. The code also sends the UID to the serial monitor for debugging purposes.