Build a contactless attendance checkpoint using an NFC badge scanner, a Python attendance processor, and a servo-operated 3D-printed entry gate. Tap your NFC badge, the gate opens, and your attendance is logged. Perfect for classrooms, makerspaces, or office entry points.
1. A user taps their NFC badge/card on the RYRR30d reader
2. The Xiao RP2040 reads the card's UID via UART and forwards it to the PC over USB Serial
3. A Python script receives the UID, checks it against a database, logs the attendance, and sends a command
4. The FireBeetle ESP32 P4 drives a servo motor to open/close the 3D-printed gate
5. The Python script maintains a CSV attendance log with timestamps and user information
REYAX RYRR30d NFC Reader — Technical SpecificationsThe REYAX RYRR30d is the heart of this NFC attendance system. It's a compact, reliable 13.56MHz NFC/RFID reader that communicates over UART (serial) at 9600 baud. This section covers technical specifications, operating principles, and integration guidelines.
RYRR30d Key Features- Frequency: 13.56 MHz (ISO14443A, ISO14443B, ISO15693 compatible)
- Reading Range: Up to 5 cm (adjustable via antenna tuning)
- Interface: UART serial @ 9600 baud (5V tolerant)
- Output Format: Hexadecimal UID string (e.g., A1B2C3D4)
- Power Supply: 5V DC @ ~100mA typical
- Operating Voltage: 4.5V–5.5V
Important: The RYRR30d communicates at 5V levels but is 3.3V tolerant on the RX pin. Always verify your microcontroller's TX output is at least 2.4V for reliable communication.
Where to Buy — Complete Module LinksAll components for this attendance system are readily available online. Below are direct purchasing links for each module.
If you’d like to buy this product, you can find it here: Buy Now
Also, you can check your local distributors
JUSTWAY 3D Printing Services — Professional Gate ManufacturingDon't 3D print the gate yourself — let JUSTWAY handle it! JUSTWAY specializes in high-quality 3D-printed parts for maker projects.
They provide: ✓ Professional SLA/FDM 3D printing with multiple material options ✓ Custom designs tailored to your space and requirements ✓ Fast turnaround: Standard parts in 3–5 business days ✓ Quality assurance: All parts tested before shipping ✓ Support: Design consultation and assembly guidance The JUSTWAY gate assembly is engineered for reliability and durability, with reinforced servo mounts and cable routing designed for easy assembly.
The RYRR30d communicates at 9600 baud over UART. The Xiao RP2040 reads UID data strings and forwards them to the PC via USB Serial.
he ESP32 P4 controls the servo motor (gate movement), status LEDs (green/red), and a buzzer for audio feedback.
- Servo Signal (PWM) → GPIO pin on ESP32 P4
- Servo Power (5V) → External 5V supply (servo draws 300mA+ during movement)
Three components work together: the Xiao RP2040 reads NFC tags, the Python script validates and logs attendance, and the ESP32 P4 controls the gate motor.
1. Xiao RP2040 NFC Reader CodeUpload this sketch to the Xiao RP2040. It reads NFC UIDs from the RYRR30d over UART and forwards them to the PC via USB Serial.
#include <Arduino.h>
#define RYRR30D Serial1
String lastUID = "";
unsigned long lastReadTime = 0;
const unsigned long DEBOUNCE_MS = 1500; // ignore same UID for 1.5 seconds
void setup() {
Serial.begin(115200); // USB to computer (Web Serial)
RYRR30D.begin(115200); // UART to RYRR30D (GP6=TX, GP7=RX)
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
// Configure RYRR30D for ISO14443A tags (your working mode)
RYRR30D.print("AT\r\n");
delay(100);
RYRR30D.print("AT+MODE=2\r\n");
delay(100);
RYRR30D.print("AT+CTYPE=1100000000000010\r\n");
delay(100);
Serial.println("NFC Reader Ready - debounced UID output");
}
void loop() {
if (RYRR30D.available()) {
String line = RYRR30D.readStringUntil('\n');
line.trim();
if (line.length() == 0) return;
// Check if this is a UID line
if (line.startsWith("+ISO14443A=")) {
String uid = line.substring(11); // extract UID
unsigned long now = millis();
// Debounce: only forward if UID changed or time elapsed
if (uid != lastUID || (now - lastReadTime) > DEBOUNCE_MS) {
lastUID = uid;
lastReadTime = now;
Serial.println(line); // forward to web
// Blink LED to confirm reading
digitalWrite(LED_BUILTIN, LOW);
delay(30);
digitalWrite(LED_BUILTIN, HIGH);
}
// else: silently ignore duplicate
} else {
// Forward any other messages (debug)
Serial.println(line);
}
}
}2. Python Attendance ServerRun on your PC. Listens for NFC UIDs, validates against users.json, logs attendance, and sends commands to the ESP32 P4 gate controller.
import serial
import time
RP2040_PORT = "COM3" # adjust to your XIAO RP2040 port
ESP32_PORT = "COM4" # adjust to your ESP32-P4 port
BAUD_RP2040 = 115200
BAUD_ESP32 = 115200
try:
rp2040 = serial.Serial(RP2040_PORT, BAUD_RP2040, timeout=1)
esp32 = serial.Serial(ESP32_PORT, BAUD_ESP32, timeout=1)
except Exception as e:
print(f"❌ Error opening ports: {e}")
exit(1)
print("✅ Bridge ready. Listening for NFC UIDs...\n")
while True:
try:
if rp2040.in_waiting:
uid = rp2040.readline().decode(errors="ignore").strip()
if uid:
print(f"📡 NFC UID from RP2040: {uid}")
if uid == "13BF172D":
print("🎯 Authorized tag detected → sending trigger to ESP32-P4")
esp32.write(b"HAPPY\n")
# Read ESP32 response
time.sleep(0.1)
while esp32.in_waiting:
response = esp32.readline().decode(errors="ignore").strip()
if response:
print(f"🤖 ESP32-P4 says: {response}")
else:
print("🚫 Unauthorized tag ignored")
except KeyboardInterrupt:
print("\n🛑 Bridge stopped by user.")
break
except Exception as e:
print(f"⚠️ Runtime error: {e}")
time.sleep(1)Upload to ESP32 P4. Controls servo motor, LEDs, and buzzer. Listens for commands from Python script over WiFi.
#include <ESP32Servo.h>
#define LED_PIN 3
#define SERVO_PIN 4
Servo gateServo;
int pos = 0;
void setup() {
Serial.begin(115200);
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
ESP32PWM::allocateTimer(0);
ESP32PWM::allocateTimer(1);
ESP32PWM::allocateTimer(2);
ESP32PWM::allocateTimer(3);
gateServo.setPeriodHertz(50);
gateServo.attach(SERVO_PIN, 1000, 2000);
gateServo.write(0); // closed
Serial.println("\n==============================");
Serial.println("🚀 ESP32-P4 Gate Controller");
Serial.println("==============================");
Serial.println("✅ Servo initialized on pin " + String(SERVO_PIN));
Serial.println("System ready. Waiting for trigger...\n");
}
void loop() {
if (Serial.available()) {
String cmd = Serial.readStringUntil('\n');
cmd.trim();
if (cmd == "HAPPY") {
runResponseCycle();
}
}
}
void runResponseCycle() {
Serial.println("\n🎉 Authorized tag detected! Triggering servo + LED response...\n");
// Servo sweep forward
for (pos = 0; pos <= 90; pos += 10) {
gateServo.write(pos);
delay(50);
}
// LED ON while gate open
digitalWrite(LED_PIN, HIGH);
delay(2000);
// Servo sweep backward
for (pos = 90; pos >= 0; pos -= 10) {
gateServo.write(pos);
delay(50);
}
digitalWrite(LED_PIN, LOW);
Serial.println("\n✅ Gate cycle complete.\n");
}Conclusion:This NFC attendance system is fast, local, and automatic. When a user taps their card, the RYRR30d reader instantly captures the badge ID and sends it to the Xiao RP2040, which validates the ID against your user list via a Python script running on your PC. If the badge is authorized, the script sends a command to the FireBeetle ESP32 P4, which controls the MG996R servo motor to open the gate. There's no cloud dependency, no subscriptions, and no delays — just tap, validate, and open. The complete system costs under $40 to build and works entirely offline. 🚀





Comments