SMART LOCK SYSTEM
// ESP32-S3 + NFC + QIACHIP 433MHz REMOTE — COMPLETE BUILD GUIDE
REV 2.0 // OFFICE DOOR
SYSTEM ARCHITECTURE
SCENARIO 1 — YOU ARRIVING AT THE OFFICE
📱 PHONE TAP
NFC sticker in case
PN532 READER
reads through door
ESP32-S3
checks UID match
RELAY
triggers motor wire
🔓 UNLOCKED
5 second window
SCENARIO 2 — SOMEONE KNOCKS, YOU'RE AT YOUR DESK
🔲 QIACHIP PRESS
slim white remote
QIACHIP RECEIVER
decodes EV1527
ESP32-S3
sees GPIO go HIGH
RELAY
triggers motor wire
🔓 UNLOCKED
5 second window
// INSIDE DOOR (HIDDEN)
  • 🧠 ESP32-S3 Dev Board THE BRAIN
  • 📡 PN532 NFC Module READS THROUGH DOOR
  • 📻 QIACHIP Receiver Module DECODES REMOTE
  • 5V Relay Module TRIGGERS LOCK
  • 🔋 5000mAh Li-Po Battery POWER SOURCE
  • 🔌 TP4056 + MT3608 CHARGE + BOOST
  • 🔌 USB-C Port on enclosure INSIDE — FOR CHARGING
// OUTSIDE DOOR (VISIBLE)
  • 🔢 Existing Touchscreen Lock UNCHANGED
  • 📱 Your Phone (NFC sticker) TAP TO UNLOCK
// YOUR DESK
  • 🔲 QIACHIP 4-Button Transmitter SLIM WHITE REMOTE
  • 📶 Range: ~656 ft / 200m THROUGH WALLS
  • Button A = Unlock 5 sec LET VISITOR IN
  • Button B = Unlock 30 sec MULTIPLE PEOPLE
  • Button C = Future use EXPANDABLE
  • Button D = Future use EXPANDABLE
// POWER SYSTEM
  • 🔌 USB-C charging port PLUG IN TO CHARGE
  • TP4056 charging module SAFE LI-PO CHARGE
  • 🔋 5000mAh Li-Po 2-4 WEEKS PER CHARGE
  • 📈 MT3608 boost converter 3.7V → 5V
⚠ IMPORTANT — LOCK INTEGRATION
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
ESP32-S3 3.3V GND GPIO21 SDA GPIO22 SCL GPIO16 RX GPIO17 TX 5V GND GPIO5 RELAY GPIO4 CH1 (Btn A) GPIO13 CH2 (Btn B) GND GPIO41 SCK GPIO42 WS PN532 NFC VCC GND SDA SCL I2C MODE QIACHIP RECEIVER VCC (5V) GND CH1 OUT (Button A) CH2 OUT (Button B) CH3 OUT (Button C) CH4 OUT (Button D) EV1527 decoded internally A→GPIO4 B→GPIO13 5V RELAY VCC GND IN (signal) COM NO → TO LOCK MOTOR LOCK MOTOR Motor + Motor - (existing lock wires) parallel POWER SYSTEM TP4056 (charger) USB-C IN → Li-Po MT3608 (boost) 3.7V → 5V out 5000mAh Li-Po main battery 5V — ALL COMPONENTS MOUNTED INSIDE DOOR / WALL ENCLOSURE —
PIN REFERENCE TABLE
FROMPINTOPINWIRE COLORPURPOSE
PN532 NFCVCC ESP32-S33.3V RED Power
PN532 NFCGND ESP32-S3GND BLACK Ground
PN532 NFCSDA ESP32-S3GPIO21 BLUE I2C Data
PN532 NFCSCL ESP32-S3GPIO22 YELLOW I2C Clock
QIACHIP ReceiverVCC ESP32-S35V RED Power (needs 5V not 3.3V)
QIACHIP ReceiverGND ESP32-S3GND BLACK Ground
QIACHIP ReceiverCH1 OUT ESP32-S3GPIO4 ORANGE Button A → Unlock 5 sec
QIACHIP ReceiverCH2 OUT ESP32-S3GPIO13 PURPLE Button B → Unlock 30 sec
RelayVCC ESP32-S35V RED Power
RelayGND ESP32-S3GND BLACK Ground
RelayIN ESP32-S3GPIO5 PURPLE Trigger Signal
RelayCOM + NO Lock MotorMotor Wires WHITE Parallel with motor
MT36085V OUT ESP32-S35V 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
DOOR 1.5" - 2" HOLLOW WOOD OUTSIDE public side INSIDE your office EXISTING LOCK touchscreen exterior LOCK INTERIOR battery + motor existing wire PN532 NFC flat against door facing outward reads through hollow door ✓ 📱 PHONE NFC sticker tap here ESP32 ENCLOSURE • ESP32-S3 • QIACHIP receiver • 5V relay • Li-Po battery • TP4056 charger • MT3608 boost ⬡ USB-C port (faces inside office) mounted on wall beside door i2c relay QIACHIP TRANSMITTER slim white remote on your desk ~656ft range RF 433MHz signal 🔌 USB-C PORT — INTERIOR SIDE LEGEND NFC signal (through door) Relay wire to lock motor RF wireless signal Existing lock wiring
✓ 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.ino C++ / 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 ─────────────────────────────────────────
#define RELAY_PIN     5    // Relay → lock motor
#define SDA_PIN       21   // PN532 SDA
#define SCL_PIN       22   // PN532 SCL

// QIACHIP receiver channel output pins
// Each pin goes HIGH when that button is pressed
#define QIACHIP_CH1   4    // Button A → unlock 5 seconds
#define QIACHIP_CH2   13   // Button B → unlock 30 seconds
#define QIACHIP_CH3   14   // Button C → future use
#define QIACHIP_CH4   27   // Button D → future use

// ── UNLOCK DURATIONS ────────────────────────────────────────
#define UNLOCK_SHORT  5000  // Button A — 5 sec (single visitor)
#define UNLOCK_LONG   30000 // 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;

// ════════════════════════════════════════════════════════════
void setup() {
  Serial.begin(115200);
  Serial.println("\n\n══ SMART LOCK BOOTING ══");

  // Relay — LOW = locked
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW);

  // QIACHIP channel pins — INPUT, reads HIGH when button pressed
  pinMode(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");
}

// ════════════════════════════════════════════════════════════
void loop() {
  checkNFC();
  checkQIACHIP();
  checkLockTimeout();
}

// ── NFC CHECK ────────────────────────────────────────────────
void checkNFC() {
  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.
void checkQIACHIP() {
  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 groups
  if (ch2 && !lastCH2) {
    Serial.println("🔲 QIACHIP Button B — unlock 30 sec");
    unlock(UNLOCK_LONG);
  }

  lastCH1 = ch1;
  lastCH2 = ch2;
}

// ── UNLOCK ───────────────────────────────────────────────────
void unlock(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 ───────────────────────────────────────────────
void checkLockTimeout() {
  if (isUnlocked && (millis() - unlockTime >= unlockDuration)) {
    digitalWrite(RELAY_PIN, LOW);
    isUnlocked = false;
    Serial.println("🔒 RELOCKED");
  }
}

// ── NFC AUTH ─────────────────────────────────────────────────
bool isAuthorizedNFC(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.ino Run once to find your NFC UIDs
#include <Wire.h>
#include <Adafruit_PN532.h>

Adafruit_PN532 nfc(21, 22);

void setup() {
  Serial.begin(115200);
  Wire.begin(21, 22);
  nfc.begin();
  nfc.SAMConfig();
  Serial.println("Tap your NFC card or phone sticker...");
}

void loop() {
  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)
  • Install Arduino IDE from arduino.cc
  • Add ESP32-S3 board package (File → Preferences → Board Manager URL)
  • Install libraries: Adafruit PN532, RCSwitch (Library Manager)
2
GET NFC READING WORKING ON BENCH
  • Wire PN532 to ESP32-S3 on breadboard (4 wires)
  • Upload UID reader sketch
  • 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!