La Estación RFID De Llaves es un sistema de control de acceso basado en ESP32 que lee tarjetas RFID para activar un servo motor y desbloquear puertas o cajas. El proyecto integra un módulo MFRC522 para la lectura sin contacto, un servo SG90 para el mecanismo de apertura, sensores magnéticos (YL-99 y KY-025) para monitoreo de estado, y conectividad WiFi para configuración remota.
Esta guía proporciona el diagrama de cableado completo, lista de componentes, firmware Arduino listo para cargar, y pasos de ensamblaje en protoboard. Los usuarios aprenderán a configurar la comunicación SPI con el lector RFID, calibrar el servo, implementar un portal WiFi de configuración segura con contraseña aleatoria, y diagnosticar el sistema mediante monitoreo serial de UIDs de tarjetas y estados de sensores.
Wiring diagram

Gather all the parts
Assemble it in 3 steps
1. Preparar la protoboard horizontal
Deja el ESP32 y los módulos fuera de la protoboard. Usa cables desde los pines rotulados a las columnas indicadas en MONTAJE.md. Verifica continuidad de los rieles sin alimentación.
2. Cablear lógica y LED
Distribuye 3V3 y GND. Conecta SPI y los sensores. Monta la resistencia entre E25 y E28; ánodo en D28 y cátodo en D29. El cable de GPIO26 llega a A25. Une A29 a GND.
- No conectes IRQ ni AO. El pulsador solo se cablea así si es de contacto seco.
3. Conectar la rama del servo
Mide la polaridad real en el adaptador, desconecta la fuente y lleva el positivo al riel exclusivo del servo, y el negativo a GND común. Si montas C1, respeta su polaridad. Alimenta la placa solo por USB.
- Nunca unir el positivo del barril a VIN, USB ni 3V3. Mantén el brazo sin carga en las primeras pruebas.
Review all connections
1. Connections between "rfid" and "ESP32"
2. Connections between "servo" and "ESP32"
3. Connections between "llave" and "ESP32"
4. Connections between "puerta" and "ESP32"
5. Connections between "boton" and "ESP32"
6. Connections between "r1" and "ESP32"
7. Connections between "led" and "ESP32"
8. Connections between "fuente" and "ESP32"
9. Connections between "c1" and "ESP32"
Deploy the firmware
#include <Arduino.h>
#include <SPI.h>
#include <MFRC522.h>
#include <WiFiManager.h>
constexpr int CS=4, RST=22, LED=26, KEY=33, DOOR=32, BUTTON=27, SERVO=25;
MFRC522 reader(CS,RST);
WiFiManager wifi;
void setup(){
Serial.begin(115200);
pinMode(LED,OUTPUT); digitalWrite(LED,LOW);
pinMode(SERVO,OUTPUT); digitalWrite(SERVO,LOW); // Sin pulsos: diagnóstico sin apertura
pinMode(KEY,INPUT); pinMode(DOOR,INPUT); pinMode(BUTTON,INPUT_PULLUP);
SPI.begin(18,19,23,CS); reader.PCD_Init(); reader.PCD_DumpVersionToSerial();
WiFi.mode(WIFI_STA); WiFi.begin(); wifi.setConfigPortalTimeout(120);
Serial.println("Diagnostico: mantener pulsador 2 segundos para configurar WiFi.");
}
void loop(){
static int key=-1, door=-1; static bool held=false, fired=false;
static uint32_t start=0;
int k=digitalRead(KEY), d=digitalRead(DOOR);
if(k!=key || d!=door){key=k;door=d;Serial.printf("YL99=%d KY025=%d\n",k,d);}
if(digitalRead(BUTTON)==LOW){
if(!held){held=true;start=millis();Serial.println("Pulsador LOW");}
if(!fired && millis()-start>=2000){
fired=true; char pass[16]; snprintf(pass,sizeof(pass),"LL-%08lX",(unsigned long)esp_random());
Serial.printf("Portal LlaveLink-Setup, clave %s\n",pass);
wifi.startConfigPortal("LlaveLink-Setup",pass);
}
}else {held=false;fired=false;}
if(reader.PICC_IsNewCardPresent() && reader.PICC_ReadCardSerial()){
Serial.print("UID diagnostico: ");
for(byte i=0;i<reader.uid.size;i++) Serial.printf("%02X",reader.uid.uidByte[i]);
Serial.println();reader.PICC_HaltA();reader.PCD_StopCrypto1();
}
digitalWrite(LED,WiFi.status()==WL_CONNECTED || (millis()%1000)<100);
delay(20);
}Remix this project
Make it yours in one click
Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.




