Before wiring the relay, open the interior panel and use a multimeter to find the motor wires. When you enter a valid code, those wires go from 0V to ~6V. That's where your relay connects — in parallel with the motor, so the lock still works completely normally on its own.
✓ TIP — NFC THROUGH DOOR
Your door is hollow wood/composite so NFC signals pass straight through. Mount the PN532 reader flat against the interior surface of the door, facing outward. Phone tap range will be 1-3cm through the door — tell people to tap near the lock area.
COMPLETE WIRING DIAGRAM
PIN REFERENCE TABLE
FROM
PIN
TO
PIN
WIRE COLOR
PURPOSE
PN532 NFC
VCC
ESP32-S3
3.3V
RED
Power
PN532 NFC
GND
ESP32-S3
GND
BLACK
Ground
PN532 NFC
SDA
ESP32-S3
GPIO21
BLUE
I2C Data
PN532 NFC
SCL
ESP32-S3
GPIO22
YELLOW
I2C Clock
QIACHIP Receiver
VCC
ESP32-S3
5V
RED
Power (needs 5V not 3.3V)
QIACHIP Receiver
GND
ESP32-S3
GND
BLACK
Ground
QIACHIP Receiver
CH1 OUT
ESP32-S3
GPIO4
ORANGE
Button A → Unlock 5 sec
QIACHIP Receiver
CH2 OUT
ESP32-S3
GPIO13
PURPLE
Button B → Unlock 30 sec
Relay
VCC
ESP32-S3
5V
RED
Power
Relay
GND
ESP32-S3
GND
BLACK
Ground
Relay
IN
ESP32-S3
GPIO5
PURPLE
Trigger Signal
Relay
COM + NO
Lock Motor
Motor Wires
WHITE
Parallel with motor
MT3608
5V OUT
ESP32-S3
5V IN
RED
Main Power
⚠ RELAY WIRING NOTE
Wire the relay COM and NO terminals in PARALLEL with your lock's motor wires — do NOT cut the existing wires. Use a multimeter in voltage mode, enter a valid code on your lock, and find the pair that jumps to ~6V. That's the motor pair. Use small wire taps or a terminal block to connect without cutting.
PHYSICAL ROUTING DIAGRAM
✓ MOUNTING TIPS
Mount the PN532 flat against the interior door surface with double-sided foam tape — the foam helps with slight positioning adjustment. The ESP32 enclosure mounts on the wall right beside the door with two small screws or heavy-duty double-sided tape. Run the 4-wire I2C cable from the NFC reader to the enclosure along the door edge, tucked into the gap between door and frame.
⚠ RELAY WIRE ROUTING
The relay wires to the lock motor are the only wires that go INTO the lock mechanism itself. Keep these short — 6 to 12 inches. Use a small drill bit to make a clean entry hole into the lock interior panel if needed, or route through an existing gap.
COMPLETE UNIFIED SKETCH
✓ BEFORE UPLOADING
1. Install Arduino IDE + ESP32-S3 board package. 2. Install library: Adafruit PN532 (Library Manager). 3. No extra library needed for QIACHIP — it outputs simple HIGH/LOW signals directly to GPIO pins. 4. Run the UID reader sketch first to find your NFC sticker UID, then paste it below. 5. You may need to pair the QIACHIP transmitter to receiver first — hold the receiver's learn button until LED flashes, then press your remote button.
smart_lock.inoC++ / Arduino
// ═══════════════════════════════════════════════════════════
// SMART LOCK SYSTEM — ESP32-S3
// Unlock methods: NFC tap | QIACHIP remote buttons
//
// HOW QIACHIP WORKS:
// The receiver decodes the EV1527 signal itself.
// When you press a button, the matching CH pin goes HIGH.
// No RF library needed — just read GPIO like a button.
// ═══════════════════════════════════════════════════════════#include<Wire.h>#include<Adafruit_PN532.h>// ── PIN DEFINITIONS ─────────────────────────────────────────#defineRELAY_PIN5// Relay → lock motor#defineSDA_PIN21// PN532 SDA#defineSCL_PIN22// PN532 SCL// QIACHIP receiver channel output pins
// Each pin goes HIGH when that button is pressed#defineQIACHIP_CH14// Button A → unlock 5 seconds#defineQIACHIP_CH213// Button B → unlock 30 seconds#defineQIACHIP_CH314// Button C → future use#defineQIACHIP_CH427// Button D → future use// ── UNLOCK DURATIONS ────────────────────────────────────────#defineUNLOCK_SHORT5000// Button A — 5 sec (single visitor)#defineUNLOCK_LONG30000// Button B — 30 sec (group/delivery)// ── YOUR AUTHORIZED NFC CARD UIDs ───────────────────────────
// Run uid_reader.ino first, tap your phone sticker,
// copy the hex values from Serial Monitor and paste here.uint8_t authorizedCards[][7] = {
{0xAB, 0xCD, 0xEF, 0x12}, // 📱 Your phone sticker
{0x34, 0x56, 0x78, 0x90}, // 🔵 Spare card
};
uint8_t cardLengths[] = {4, 4};
int numCards = 2;
// ── OBJECTS ──────────────────────────────────────────────────
Adafruit_PN532 nfc(SDA_PIN, SCL_PIN);
// ── STATE ────────────────────────────────────────────────────bool isUnlocked = false;
unsigned long unlockTime = 0;
unsigned long unlockDuration = 0;
// Track last button state to detect rising edge (press, not hold)bool lastCH1 = false;
bool lastCH2 = false;
// ════════════════════════════════════════════════════════════voidsetup() {
Serial.begin(115200);
Serial.println("\n\n══ SMART LOCK BOOTING ══");
// Relay — LOW = lockedpinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, LOW);
// QIACHIP channel pins — INPUT, reads HIGH when button pressedpinMode(QIACHIP_CH1, INPUT);
pinMode(QIACHIP_CH2, INPUT);
pinMode(QIACHIP_CH3, INPUT);
pinMode(QIACHIP_CH4, INPUT);
Serial.println("✓ QIACHIP receiver ready");
// NFC setup
Wire.begin(SDA_PIN, SCL_PIN);
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (!versiondata) {
Serial.println("❌ PN532 not found — check wiring");
while (1);
}
nfc.SAMConfig();
Serial.println("✓ NFC reader ready");
Serial.println("══ SYSTEM READY ══\n");
}
// ════════════════════════════════════════════════════════════voidloop() {
checkNFC();
checkQIACHIP();
checkLockTimeout();
}
// ── NFC CHECK ────────────────────────────────────────────────voidcheckNFC() {
uint8_t uid[7];
uint8_t uidLength;
bool cardFound = nfc.readPassiveTargetID(
PN532_MIFARE_ISO14443A, uid, &uidLength, 100
);
if (cardFound) {
Serial.print("📡 NFC UID: ");
for (int i = 0; i < uidLength; i++) {
Serial.print(uid[i], HEX); Serial.print(" ");
}
Serial.println();
if (isAuthorizedNFC(uid, uidLength)) {
Serial.println("✓ NFC ACCESS GRANTED");
unlock(UNLOCK_SHORT);
} else {
Serial.println("✗ NFC ACCESS DENIED");
}
delay(1000);
}
}
// ── QIACHIP BUTTON CHECK ─────────────────────────────────────
// Reads HIGH/LOW from receiver output pins.
// Uses edge detection so holding the button doesnt
// repeatedly unlock — only the initial press counts.voidcheckQIACHIP() {
bool ch1 = digitalRead(QIACHIP_CH1);
bool ch2 = digitalRead(QIACHIP_CH2);
// Button A pressed (rising edge)if (ch1 && !lastCH1) {
Serial.println("🔲 QIACHIP Button A — unlock 5 sec");
unlock(UNLOCK_SHORT);
}
// Button B pressed (rising edge) — longer for groupsif (ch2 && !lastCH2) {
Serial.println("🔲 QIACHIP Button B — unlock 30 sec");
unlock(UNLOCK_LONG);
}
lastCH1 = ch1;
lastCH2 = ch2;
}
// ── UNLOCK ───────────────────────────────────────────────────voidunlock(unsigned long duration) {
digitalWrite(RELAY_PIN, HIGH);
isUnlocked = true;
unlockTime = millis();
unlockDuration = duration;
Serial.print("🔓 UNLOCKED for ");
Serial.print(duration / 1000);
Serial.println("s");
}
// ── AUTO RELOCK ───────────────────────────────────────────────voidcheckLockTimeout() {
if (isUnlocked && (millis() - unlockTime >= unlockDuration)) {
digitalWrite(RELAY_PIN, LOW);
isUnlocked = false;
Serial.println("🔒 RELOCKED");
}
}
// ── NFC AUTH ─────────────────────────────────────────────────boolisAuthorizedNFC(uint8_t *uid, uint8_t uidLength) {
for (int i = 0; i < numCards; i++) {
if (uidLength == cardLengths[i] &&
memcmp(uid, authorizedCards[i], uidLength) == 0) {
return true;
}
}
return false;
}
UID READER SKETCH (run this first)
uid_reader.inoRun once to find your NFC UIDs
#include<Wire.h>#include<Adafruit_PN532.h>
Adafruit_PN532 nfc(21, 22);
voidsetup() {
Serial.begin(115200);
Wire.begin(21, 22);
nfc.begin();
nfc.SAMConfig();
Serial.println("Tap your NFC card or phone sticker...");
}
voidloop() {
uint8_t uid[7]; uint8_t uidLen;
if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLen, 500)) {
Serial.print("UID (copy into main sketch): {");
for (int i = 0; i < uidLen; i++) {
Serial.print("0x"); Serial.print(uid[i], HEX);
if (i < uidLen - 1) Serial.print(", ");
}
Serial.println("}");
delay(2000);
}
}
PARTS LIST
ESP32-S3 Dev Board
main microcontroller / brain
~$10
PN532 NFC Module
I2C mode, reads through hollow door
~$8
QIACHIP 433MHz Kit
slim white 4-button remote + mini receiver
~$12
5V Relay Module
single channel, wires to lock motor
~$5
NFC Stickers (10 pack)
NTAG213, one goes in your phone case
~$5
5000mAh Li-Po Battery
3.7V, 2-4 weeks per charge
~$12
TP4056 USB-C Module
safe Li-Po charging circuit
~$4
MT3608 Boost Converter
3.7V battery → 5V for ESP32
~$3
USB-C Panel Mount Port
mounts on enclosure side
~$5
Multimeter
essential for finding motor wires
~$15
Jumper Wires + Breadboard
for prototyping before final mount
~$8
Project Enclosure Box
ABS plastic, mounts beside door
~$10
GRAND TOTAL
~$93
BUILD PHASES
1
ORDER PARTS + SETUP ARDUINO IDE
Order everything from parts list (Amazon delivers fastest)
Tap your phone sticker — copy the UID printed to Serial Monitor
Paste your UID into the main sketch authorized list
3
PAIR QIACHIP REMOTE TO RECEIVER
Power the QIACHIP receiver module (5V + GND from ESP32)
Hold the receiver's small LEARN button until the LED flashes rapidly
Press any button on the white transmitter — LED will flash to confirm pairing
Wire CH1 output to GPIO4, CH2 to GPIO13 on ESP32
Upload main sketch — pressing Button A should trigger relay immediately
No code needed to decode — receiver does it all for you
4
FIND LOCK MOTOR WIRES
Open interior lock panel (2 screws)
Set multimeter to DC voltage mode
Probe wire pairs while entering a valid code on keypad
Find pair that jumps from 0V to ~6V on unlock — those are your motor wires
Do NOT cut — use wire taps or small terminal block to connect
5
CONNECT RELAY + TEST FULL SYSTEM
Wire relay module to ESP32 (3 wires)
Wire relay COM + NO in parallel with lock motor wires
Upload main sketch — test NFC tap and RF fob both unlock
Verify lock still works normally via touchscreen keypad
6
ASSEMBLE POWER SYSTEM + MOUNT
Wire TP4056 → Li-Po → MT3608 → ESP32 power chain
Install USB-C panel mount port on enclosure side
Mount NFC reader flat against interior door surface (foam tape)
Mount enclosure on wall beside door
Tuck wires neatly along door edge
Charge up and enjoy your smart lock!
✓ GOLDEN RULE
Test each phase completely before moving to the next. Getting NFC reading on the bench before touching the lock means if something goes wrong you know exactly where the problem is. Never skip a phase!