Introduction
Creating a RFID door lock is one of the most rewarding starter projects for makers interested in IoT security, smart home automation, or STEM education. In this roadmap we’ll walk you through the hardware, wiring, and code needed to lock and unlock a door with a simple RFID tag. The guide is tailored for Amsterdam makers, but the same parts and steps work in New York, London, Berlin, and other tech hubs.
We’ll cover two popular microcontroller stacks:
- ESP32 (or ESP32‑S3) – Wi‑Fi enabled, perfect for remote monitoring.
- Arduino Uno / Arduino Nano – Classic, easy‑to‑program boards for beginners.
All components are available from Robotics Kits, our AI‑driven Build‑to‑Buy catalog that offers USD pricing, worldwide shipping, and China sourcing assistance. We’ll also compare buying the same items on Amazon so you can see the value of our curated kit.
What You Need
Core Components (common to both stacks)
- RFID Reader Module – MFRC522 13.56 MHz (compatible with most RFID tags).
- RFID Tags / Cards – 4 × 4 cm cards or key‑fob style tags.
- Solenoid Lock – 12 V DC, suitable for a standard door.
- Power Supply – 5 V USB for ESP32/Arduino, plus a 12 V supply for the lock (use a buck converter if needed).
- Breadboard & Jumper Wires – For prototyping.
- Diode (1N4007) – Protects the circuit from back‑EMF when the lock de‑energizes.
- Resistors – 10 kΩ pull‑up for the RFID reset pin.
ESP32 Stack
- ESP32‑DevKitC or ESP32‑S3 board (Wi‑Fi/BLE ready).
- Optional: OLED 0.96" I2C display for lock status.
Arduino Stack
- Arduino Uno or Arduino Nano.
- Optional: LED + Buzzer for local feedback.
> Tip: All of these parts are listed in the Robotics Kits catalog with AI‑generated BOMs that auto‑calculate shipping costs. You can also find them on Amazon, but Robotics Kits bundles them with a single checkout and provides a PDF wiring diagram.
Wiring the RFID Reader
Pin Mapping (MFRC522 → ESP32)
| MFRC522 Pin | ESP32 Pin | |-------------|-----------| | SDA (SS) | GPIO 5 | | SCK | GPIO 18 | | MOSI | GPIO 23 | | MISO | GPIO 19 | | IRQ | – (not used) | | GND | GND | | RST | GPIO 22 (with 10 kΩ pull‑up) | | 3.3V | 3.3V |
Pin Mapping (MFRC522 → Arduino Uno)
| MFRC522 Pin | Arduino Pin | |-------------|--------------| | SDA (SS) | 10 | | SCK | 13 | | MOSI | 11 | | MISO | 12 | | IRQ | – | | GND | GND | | RST | 9 | | 3.3V | 3.3V |
Connecting the Solenoid Lock
- Connect the positive lead of the lock to the 12 V supply.
- Place a 1N4007 diode across the lock terminals (cathode to positive) to suppress voltage spikes.
- Use a logic‑level MOSFET (e.g., IRLZ44N) controlled by a digital pin (GPIO 26 on ESP32, pin 8 on Arduino) to switch the lock on/off.
- Ground the MOSFET source to the common ground.
Programming the ESP32
We’ll use the Arduino IDE with the MFRC522 library. The same sketch works on Arduino Uno with minor pin changes.
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 22 // ESP32 reset pin
#define SS_PIN 5 // ESP32 SS (SDA) pin
#define LOCK_PIN 26 // MOSFET gate controlling solenoid
MFRC522 rfid(SS_PIN, RST_PIN);
void setup() {
Serial.begin(115200);
pinMode(LOCK_PIN, OUTPUT);
digitalWrite(LOCK_PIN, LOW); // lock closed
SPI.begin();
rfid.PCD_Init();
Serial.println("RFID Door Lock ready. Scan a tag...");
}
void loop() {
// Look for new cards
if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
return;
}
// Print UID
Serial.print("UID:");
for (byte i = 0; i < rfid.uid.size; i++) {
Serial.print(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(rfid.uid.uidByte[i], HEX);
}
Serial.println();
// Simple whitelist – replace with your own UID(s)
const byte authorizedUID[4] = {0xDE, 0xAD, 0xBE, 0xEF};
bool authorized = true;
for (byte i = 0; i < 4; i++) {
if (rfid.uid.uidByte[i] != authorizedUID[i]) authorized = false;
}
if (authorized) {
Serial.println("Access granted – unlocking");
digitalWrite(LOCK_PIN, HIGH); // energize solenoid
delay(3000); // keep door open 3 s
digitalWrite(LOCK_PIN, LOW);
Serial.println("Door locked again");
} else {
Serial.println("Access denied");
}
rfid.PICC_HaltA(); // stop reading
}Key points
- The sketch uses a hard‑coded UID as a simple whitelist. For production, store authorized IDs in EEPROM or a cloud database.
- The AI Build‑to‑Buy feature on Robotics Kits can generate a custom firmware template that includes your own UID list, saving you time.
Programming the Arduino Uno
Replace the ESP32 pin numbers with the Arduino mapping shown earlier. The code is identical; just change RST_PIN, SS_PIN, and LOCK_PIN definitions.
Testing and Troubleshooting
| Symptom | Likely Cause | Fix | |---------|--------------|-----| | RFID reader returns 0x00 UID | Wiring error or wrong voltage (use 3.3 V) | Re‑check connections, ensure pull‑up on RST pin | | Solenoid never activates | MOSFET not driven high enough | Use a logic‑level MOSFET or add a gate‑driver transistor | | Door stays unlocked after tag scan | Code missing digitalWrite(LOCK_PIN, LOW) | Verify the delay() and lock reset logic | | Random unlocks | UID comparison mismatch | Ensure the whitelist array matches the tag’s 4‑byte UID |
If you run into issues, the Robotics Kits AI Lab can analyze your wiring diagram and suggest corrections within seconds.
Where to Source Parts – Robotics Kits vs Amazon
- Robotics Kits bundles the MFRC522, solenoid, MOSFET, and optional OLED into a single Starter RFID Kit. The AI‑generated BOM includes USD pricing, estimated customs for Europe, and a one‑click checkout.
- Amazon often sells each component separately, which can lead to mismatched voltage levels (e.g., 5 V RFID modules that won’t work with ESP32’s 3.3 V logic). Shipping to the Netherlands may also incur higher fees.
- For makers in Amsterdam, Robotics Kits ships from a European warehouse, reducing delivery time to 2‑3 days, whereas Amazon’s standard shipping can take a week.
- Need a bulk order for a classroom? Robotics Kits offers STEM kits Europe discounts and a dedicated support line, something Amazon’s marketplace sellers rarely provide.
Next Steps and Expanding Your Project
- Add Wi‑Fi control: Use the ESP32 to report lock status to a Firebase dashboard or a local MQTT broker.
- Integrate sensors: Add a magnetic reed switch to detect door open/close, or a PIR motion sensor for occupancy detection.
- Combine with Raspberry Pi: Run a Python Flask server on a Pi to manage multiple locks across a smart home.
- Upgrade security: Replace the static UID whitelist with AES‑encrypted tokens stored on an ESP32‑S3 for higher security.
- STEM kits USA/EU: If you’re teaching a class, consider ordering a Robotics Kits Classroom Pack that includes multiple RFID kits, a curriculum PDF, and AI‑assisted grading tools.
Ready to Build?
Visit Robotics Kits today, generate your AI‑powered BOM, and have all the parts shipped to Amsterdam (or any city from New York to Berlin) in a single package. Start your RFID door lock project now and unlock the future of IoT!
Limitations
- This guide focuses on basic security; it is not suitable for high‑security access control without additional encryption and tamper‑resistance.
- Component availability may vary by region; always verify stock on the Robotics Kits catalog before ordering.
- The code example uses a hard‑coded UID for simplicity; production systems should implement secure credential storage.