RFID-Based Smart Servo Lock System Using Arduino UNO R4 Wi-Fi

by rohanbarnwal in Circuits > Arduino

20 Views, 1 Favorites, 0 Comments

RFID-Based Smart Servo Lock System Using Arduino UNO R4 Wi-Fi

20251016_0903_RFID Smart Lock Demo_simple_compose_01k7nh64nbfp59gdzmksm1v8d8.png
IMG_7070.jpg

In a world where technology meets everyday life, security doesn't have to be complicated. This project - the RFID-Based Smart Servo Lock System - brings simple, secure, and smart access control to any physical space.

Whether it's a cupboard, drawer, toolbox, or cabinet, this system replaces traditional keys with an RFID card - making access faster, safer and futuristic.

I designed this project using an Arduino UNO R4 Wi-Fi, a servo motor, and a Power Bank for portability. All components are mounted openly on a 3D-printed base, creating a transparent design that showcases the wing and logic clearly. It's functional, educational, and visually appealing - perfect for makers, students and innovators.

Why You Should Make This Project

  1. Smart Access Control: Unlock your space with an authorized RFID card - no keys, no passwords.
  2. Hands-On Learning: Understand RFID Technology, servo motion control, and Arduino programming.
  3. Compact and Portable: Runs smoothly even from a simple power bank
  4. Customizable: Can be adapted for lockers, drawers, boxes or even doors.

How It Works

  1. System Star-Up:
  2. When powered on, the Arduino initializes the RFID reader and sets the servo at the locked position (150)
  3. Card Scanning:
  4. The MFRC522 RFID reader continuously scans for nearby RFID cards or tags
  5. Authentication:
  6. Once a card is detected, its unique ID (UID) is read and compare with the predefined authorized UID in the Arduino code,
  7. If Authorized:
  8. The servo rotates smoothly from 150 to 0 unlocking the latch.
  9. The system waits 5 seconds (keeping it unlocked).
  10. The servo then returns back to 150, re locking automatically.
  11. The system waits until the card is removed before accepting a new scan.
  12. If Unauthorized:
  13. The servo doesn't move.
  14. The serial monitor displays "UID NOT authorized."

Supplies

connection rfid.jpg
  1. Arduino UNO R4 Wi-Fi x1: Acts as the main controller; reads RFID data and drives the servo.
  2. MFRC522 RFID Reader Module x1: Detects and reads RFID cards UIDs
  3. Servo Motor x1: Mechanically locks and unlocks the system.
  4. Power Bank: Portable power supply for the Arduino and servo
  5. Jumper Wires (As Needed): For connections between the Arduino, RFID reader and servo motor.
  6. 3D-Printed Base Case: Holds the servo and board neatly, providing a transparent and sturdy setup.

Circuit Connections

MFRC522's Pin To Arduino UNO R4 Wi-Fi

  1. SDA To D10
  2. SCK To D13
  3. MOSI To D11
  4. MISO To D12
  5. RST To D9
  6. 3.3v To VCC
  7. GND To GND

Servo Motor's Pin To Arduino UNO R4 Wi-Fi

  1. Signal To D6
  2. GND To GND
  3. VCC To VCC

Step-by-Step Setup

Hardware Setup

IMG_7069.jpg
  1. Mount your Arduino UNO R4 Wi-Fi, RFID reader, and servo on a 3D printed base,
  2. Connect the wires as per the connection table.
  3. Power the Arduino through a Power Bank for mobility.

Software & Libraries

Install the following Arduino Libraries:

  1. MFRC522
  2. Servo

Replace the AUTH_UID in the code with you own RFID card's UID (check via serial monitor).

Upload the code to your Arduino.

// RFID-triggered servo: initial 150deg -> on scan move to 0deg, hold 5s, return to 150deg
// Requires MFRC522 (Miguel Balboa) and Servo libraries
// Servo signal on pin D6. RC522 wiring per comments below.

#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>

#define RST_PIN 9 // RC522 RST
#define SS_PIN 10 // RC522 SDA/SS
#define SERVO_PIN 6 // servo signal pin

// Authorized UID bytes (your card)
const byte AUTH_UID[4] = { 0x2A, 0x7E, 0x17, 0xB1 };

MFRC522 mfrc522(SS_PIN, RST_PIN);
Servo myServo;

const int initialPos = 150; // starting position (deg)
const int triggeredPos = 0; // position to move to when RFID read (deg)
const unsigned long holdTimeMs = 5000UL; // hold time at triggeredPos (ms)
const int stepDelay = 8; // ms delay between degree steps for smooth movement

void setup() {
Serial.begin(115200);
while (!Serial) { } // wait for Serial on some boards (harmless on others)

SPI.begin();
mfrc522.PCD_Init();

myServo.attach(SERVO_PIN);
myServo.write(initialPos); // place servo at initial position
Serial.println();
Serial.println("RFID -> Servo ready.");
Serial.print("Initial angle: ");
Serial.print(initialPos);
Serial.println(" deg");
Serial.println("Scan authorized card to trigger movement.");
}

void loop() {
// look for a new card
if (!mfrc522.PICC_IsNewCardPresent()) {
return;
}
if (!mfrc522.PICC_ReadCardSerial()) {
return;
}

// Print scanned UID
Serial.print("Scanned UID: ");
for (byte i = 0; i < mfrc522.uid.size; i++) {
if (mfrc522.uid.uidByte[i] < 0x10) Serial.print("0");
Serial.print(mfrc522.uid.uidByte[i], HEX);
if (i < mfrc522.uid.size - 1) Serial.print(":");
}
Serial.println();

// Only react if UID size is 4 and matches AUTH_UID
if (mfrc522.uid.size == 4) {
bool match = true;
for (byte i = 0; i < 4; i++) {
if (mfrc522.uid.uidByte[i] != AUTH_UID[i]) {
match = false;
break;
}
}

if (match) {
Serial.println("Authorized card detected. Moving servo 150 -> 0, hold 5s, return to 150.");
moveServoSmooth(initialPos, triggeredPos, stepDelay);
delay(holdTimeMs);
moveServoSmooth(triggeredPos, initialPos, stepDelay);
Serial.println("Movement complete. Waiting for card removal before next trigger.");

// Halt card & stop crypto
mfrc522.PICC_HaltA();
mfrc522.PCD_StopCrypto1();

// Wait until the card is removed to avoid immediate retrigger
while (mfrc522.PICC_IsNewCardPresent() || mfrc522.PICC_ReadCardSerial()) {
delay(100);
// clear any repeated read
if (mfrc522.PICC_IsNewCardPresent()) {
mfrc522.PICC_HaltA();
mfrc522.PCD_StopCrypto1();
}
}
Serial.println("Card removed. Ready.");
} else {
Serial.println("UID NOT authorized. Ignored.");
}
} else {
Serial.println("UID length not 4 bytes — ignored.");
}

// final cleanup and small debounce
mfrc522.PICC_HaltA();
mfrc522.PCD_StopCrypto1();
delay(150);
}

// Smooth servo movement helper: moves degree-by-degree and prints each angle to Serial
void moveServoSmooth(int fromDeg, int toDeg, int stepDelayMs) {
if (fromDeg == toDeg) {
myServo.write(fromDeg);
Serial.print("Angle: ");
Serial.print(fromDeg);
Serial.println(" deg");
return;
}

int step = (toDeg > fromDeg) ? 1 : -1;
for (int deg = fromDeg; deg != toDeg; deg += step) {
myServo.write(deg);
Serial.print("Angle: ");
Serial.print(deg);
Serial.println(" deg");
delay(stepDelayMs);
}
// final position
myServo.write(toDeg);
Serial.print("Angle: ");
Serial.print(toDeg);
Serial.println(" deg");
}

Testing

Open the Serial Monitor at 115200 baud.

Scan your RFID card:

  1. If authorized - Servo rotates to unlock - waits 5 seconds - return to lock.
  2. If unauthorized - No movement; access denied message printed.

Mounting

IMG_7071.jpg
11.png
22.png
333.png

Attack a locking Latch or hook to the servo horn.

Fix your setup in the desired location-cabinet, box, or door.

The 3D printed base keeps everything organized and on display.

Future Enhancements

  1. IoT Control: Add cloud or Blynk integration using the UNO R4's Wi-Fi.
  2. Buzzer or LED: For Audio/Visual feedback when unlocking
  3. Multiple Cards: Store several authorized UIDs in EEPROM for multi-user access.

Taking It to the Next Level - With JUSTWAY

Your breadboard prototype may function flawlessly - but to the untrained eye, it can look like a bundle of wires.

When its time to showcase your creation at a science fair, tech competition, or investor meeting, presentation matters as much as innovation.

That's where JUSTWAY transforms your project from DIY to pro-level.

JUSTWAY - The Future of Hardware Prototyping

JUSTWAY is more than a fabrication service - it's a maker's dream factory, where your concept evolves into a professional-grade prototype ready for real-world deployment

What JUSTWAY Offers

Rapid Prototyping: From CAD file to physical prototype in under 24 hours. Real-time tracking and instant online quotes make iteration faster than ever.

CNC Machining: Precision aluminum or stainless steel (6061/304) enclosures for strong, premium-looking devices.

Sheet Metal Fabrication: Laser-cut, CNC-bent, and powder-coated panels for durable, industrial-quality housings.

Injection Molding: perfect for scaling up - from your first prototype to full mass production

Urethane Casting: Ideal for small batches, presentation models, or early field testing.

3D Printing (SLA/ HP-PA12):

  1. SLA Resin: Transparent, perfect for showcasing internal electronics
  2. HP-PA12 Nylon: Strong, matte-finish for a sleek, stealthy look.

Pro Maker Tip:

Want your circuit to look futuristic?

  1. Use transparent SLA resin to proudly display your Arduino and LED lights
  2. Or go for matte black HP-PA12 for a stealth-engineered design that feels premium.

How to Get Started with JUSTWAY (4 Easy Steps)

Upload your CAD files at JUSTWAY.com.

Chooses your material & finish for a sleek, stealthy look.

Preview your 3D model in real-time before confirming

Place your order - transparent pricing, rapid delivery, zero hidden costs.


JUSTWAY-Turning Your Ideas into Reality

Whether you're a hobbyist, startup, or engineer, JUSTWAY bridges the gap between imagination and production.

From transparent display prototypes to sleek production-ready enclosure - JUSTWAY makes your project look as good as it performs.

Conclusion

The RFID-Based Smart Servo Lock System is an elegant fusion of security, simplicity, and technology.

It's easy to build fun to demonstrate, and adaptable to almost any setting - whether it's a workshop cupboard, school lab locker, or even a personal gadget case.

With Arduino UNO R4 Wi-Fi powering the logic, a servo motor handling motion, and a power bank making it portable - this project proves how accessible smart automation can be.

And when you're ready to take it beyond the prototype stage, JUSTWAY ensures your project not only works great but looks world-class.

Invent. Build. Secure. Showcase. - The future of DIY is smart, and it starts with you.