Intro
A keyless door lock is one of the most useful ESP32 projects for a home or small office. Tap an authorised card, and the door unlocks for a few seconds, then locks again on its own. This guide shows a simple version using an RC522 RFID reader, a relay module and a solenoid door lock.
How It Works
The RC522 reader scans the card and sends its ID to the ESP32 over SPI. The ESP32 compares it with a short list of authorised IDs stored in the program. If it matches, the ESP32 switches the relay on, the solenoid lock releases, and the buzzer gives a short beep. After a few seconds the relay switches off and the door locks again. An unknown card gets a different beep and stays locked.
Components Required
ESP32 development board; RC522 RFID reader module with a card and a tag; single-channel relay module; 12V solenoid door lock; active buzzer; 12V power supply for the lock; 5V USB supply for the ESP32; jumper wires and a breadboard.
Circuit Connections
RC522 SDA/SS to ESP32 GPIO5, SCK to GPIO18, MOSI to GPIO23, MISO to GPIO19, RST to GPIO22, VCC to 3.3V, GND to GND. Relay IN to ESP32 GPIO26, relay VCC to 5V, relay GND to GND. Buzzer positive to GPIO27 through a resistor, negative to GND. Solenoid lock wired through the relay contacts: 12V supply positive to relay COM, relay NO to one lock wire, other lock wire back to supply negative. Keep the 12V lock circuit separate from the ESP32 3.3V logic.
Build Steps
1. Wire the RC522 first and run a simple card-read test to confirm each card ID. 2. Add the relay and test it switching with a small load before connecting the lock. 3. Connect the solenoid lock through the relay, with its own 12V supply. 4. Add the buzzer and set one beep for access granted and a different pattern for denied. 5. Add your card IDs to the authorised list, upload, and test with both an authorised and an unknown card.
Troubleshooting
Reader not reading: check the SPI wiring and that the module gets 3.3V, not 5V. Relay clicks but lock does not move: check the 12V supply and the COM/NO wiring. Lock stays open: check that the program switches the relay off after its timer. Card works sometimes: keep reader wires short and away from the lock power wires.
Safety Note
The solenoid lock uses 12V. Never power it from the ESP32 pins, keep high-current wiring separate, insulate all joints, and test the lock with the door open first so nobody can be locked in or out by a wiring mistake.
Going Further
Once it works, try adding a second reader inside, an exit button, or a log of unlock times over serial. Keep a spare key or manual override — electronics should never be the only way into a room.



0 comments:
Post a Comment