Component guide · Beginner · 3 min read
12V Solenoid Door and Cabinet Lock and Inclined Electromagnetic Lock

Wiring and Code
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
A 12 V solenoid lock has a slanted latch that retracts while the coil is powered, so the door opens, and springs back when power is off. It is fail-secure: it stays locked without power. Use a short pulse of a few seconds to unlock, since the coils are not rated for continuous on time. It pairs well with RFID or keypad projects.
Key specs at a glance
- Voltage
- 12 V DC
- Current
- About 0.6 to 1 A
- Type
- Fail-secure (locked when unpowered)
- On time
- A few seconds per unlock
- Latch
- Slanted bolt, closes automatically
- Mount
- Screw mount on cabinet or door
This part can carry many amps. Use wire thick enough for the current, put a fuse close to the battery, check that connectors are rated for the load and give drivers and motors room to cool. A short at these currents melts wires in seconds.
Models in this guide
These are alternatives. Pick the one that fits your project; you only need one.
Option 112V Electric Solenoid Door / Cabinet Lock₹367
Option 2DFRobot Inclined Electromagnetic Lock (FIT0624)₹738
What the 12V solenoid door lock is
A 12 V solenoid door lock is a latch bolt moved by an electromagnet. Power pulls the bolt in to unlock, and a spring pushes it back out when power stops.
Keep a mechanical override or backup for real doors, because a power failure keeps the lock closed.
12V solenoid door lock pinout
The pins on the 12V solenoid door lock and what each one does.
| Pin | Function |
|---|---|
| Red | +12 V |
| Black | Switched to ground |
- Red
- +12 V
- Black
- Switched to ground
Wiring the 12V solenoid door lock
Fit a 1N4007 across the coil. A 12 V 2 A supply covers the lock and logic via a buck converter.
| 12V solenoid door lock pin | Arduino Uno | ESP32 |
|---|---|---|
| Load + | 12 V supply + | 12 V supply + |
| Load - | MOSFET module OUT- (or relay NO) | MOSFET module OUT- |
| Module signal | D7 | GPIO 26 |
| GND | GND (shared with 12 V -) | GND |
- Load +
- Arduino Uno:
- 12 V supply +
- ESP32:
- 12 V supply +
- Load -
- Arduino Uno:
- MOSFET module OUT- (or relay NO)
- ESP32:
- MOSFET module OUT-
- Module signal
- Arduino Uno:
- D7
- ESP32:
- GPIO 26
- GND
- Arduino Uno:
- GND (shared with 12 V -)
- ESP32:
- GND
Example code
Replace the button with an RFID or keypad check for a real access project.
const int LOCK = 7, BTN = 2;
void setup() { pinMode(LOCK, OUTPUT); pinMode(BTN, INPUT_PULLUP); }
void loop() {
if (digitalRead(BTN) == LOW) {
digitalWrite(LOCK, HIGH);
delay(3000);
digitalWrite(LOCK, LOW);
}
}Setup and tuning
unlock with a 1 to 5 second pulse; the coil is not rated for continuous power.
the slanted bolt must slide into the strike plate freely, or it jams when the door closes.
use a MOSFET module or relay with a flyback diode across the coil.
use a 12 V supply that can deliver at least 1 A for the pull-in current.
keep a mechanical override or a battery backup for real doors.
What you need
Shop this list7 of 9 found in our store · ₹1,966
12V Electric Solenoid Door / Cabinet Lock: the part this guide covers12V Electric Solenoid Door / Cabinet Lock₹367
DFRobot Inclined Electromagnetic Lock (FIT0624): another version this guide coversDFRobot Inclined Electromagnetic Lock (FIT0624)₹738- Uno R3 development board: the controller used in the wiring tableFind this part
ESP32-WROOM-32 38-pin development board: for Wi-Fi logging and dashboardsESP32-WROOM-32 38-Pin Development Board₹389
MOSFET switch module (D4184 / LR7843): to switch or PWM it from a GPIOMOSFET Switch Module, Relay Replacement (D4184 / LR7843)₹39
5V relay module with optocoupler: to switch it from a microcontroller5V Relay Module with Optocoupler₹74- 1N4007 diode: flyback protection across the coil or motorFind this part
SMPS power supply in metal enclosure (5/12/24 V): a 12 V supplySMPS Power Supply, Metal Enclosure (5V / 12V / 24V)₹298Closest match, check the specs
RC522 RFID card reader module: to unlock with a cardRC522 RFID Reader Writer SPI Module with Card & Tag₹61
Alternatives and when to choose them
Common mistakes to avoid
- Keeping it powered for long periods so the coil burns out.
- Switching it without a flyback diode.
- Fitting it on a real door with no mechanical backup.
- Misaligning the strike plate so the bolt jams.
Frequently asked questions
Is a solenoid door lock fail-safe or fail-secure?
This type is fail-secure: it stays locked when power is lost.
Can I keep the lock powered to hold it open?
No. Pulse it for a few seconds only; long power overheats the coil.
Can I use it with an RFID reader?
Yes. An RFID or keypad project switches a MOSFET or relay to pulse the lock when the right card or code is used.
Should I use a relay or a MOSFET?
Either works; a MOSFET is silent. Always add a flyback diode across the coil.
What power supply does it need?
12 V DC that can deliver 1 A or more.
Parts for this guide
Projects that use it
Put this into practice: 4 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.



