This project presents a discreet, pattern-based locking mechanism that transforms selected glass panes into hidden touch sensors. No visible technology. No physical keys. A simple tap on the correct sequence activates an ESP32 with a relay and bare PCB pieces to unlock the door.
The challenge
The primary challenge was the door’s design: a decorative panel made entirely of colored glass panes framed in wood. There were no flat surfaces to install keypads, card readers, or fingerprint modules. Drilling into the frame to run wiring would have damaged the structure and its aesthetic.
With surveillance cameras nearby, placing visible codes or tags on the surface was not an option. The goal was to develop a locking system that remained completely hidden and seamlessly integrated into the design.
The invisible smart lock solution
Conventional smart locks rely on visible access methods such as keypads, RFID cards, or biometric scanners. But what if a door provides no space for these components, meaning no flat surface, frame for mounting, or area for the exposed hardware? This was the exact problem posed by the glass-paneled door that required secure, touchless entry without altering its appearance or structure.
The design principle
The solution was to turn the door into the interface. Instead of adding external components, bare PCB pieces were placed behind three selected glass panes, converting them into analog touch plates. These plates connect directly to an ESP32, which reads touch signals through its analog GPIOs.
When the user taps the panes in a specific sequence (for example, 1 → 2 → 3), the system unlocks the door using a relay. The PCB plates detect subtle changes in analog voltage caused by touch, even through glass, without relying on vibration, pressure, or visible sensors.
How it works
Each glass pane is connected to a separate analog input on the ESP32:
- Pane 1 → GPIO 34
- Pane 2 → GPIO 35
- Pane 3 → GPIO 32
These inputs act as capacitive-like sensors. When a user touches a pane, the analog value shifts slightly, allowing the ESP32 to detect contact through the glass.
The microcontroller monitors for a three-step pattern: 1 → 2 → 3.
If the correct sequence is entered within the set time window, the ESP32 activates a relay connected to GPIO 2, unlocking the door.
The hardware
The algorithm
The code
1. The initialization
int val1 = 0, val2 = 0, val3 = 0;
Declares three integer variables (val1, val2, val3) to store analog readings from the touch sensors, initializing them to 0.
int relay = 2;
Declares an integer variable named relay and assigns it the value 2. This represents the digital pin connected to the relay module that controls the lock.
int threshold = 30;
Declares an integer variable named threshold and sets it to 30. This value is used to determine sensitivity when detecting touch input.
int delayTime = 500;
Declares an integer variable named delayTime and sets it to 500 milliseconds. This delay helps debounce touch inputs.
int patternStep = 0;
Declares an integer variable named patternStep and initializes it to 0. This variable tracks the user’s current position in the unlock sequence.
void setup() {…}
This function runs once at the start of the program.
pinMode(34, INPUT); pinMode(35, INPUT); pinMode(32, INPUT);
Configures digital pins 34, 35, and 32 as input pins for the touch sensors.
pinMode(relay, OUTPUT);
Sets the relay pin (digital pin 2) as an output to control the locking mechanism.
Serial.begin(9600);
Initializes serial communication at a baud rate of 9600 for debugging.
Code working flow chart.
2. The main loop
void loop() {…}
This function runs continuously after the setup() function.
val1 = analogRead(34); val2 = analogRead(35); val3 = analogRead(32);
Reads analog values from the touch sensors connected to pins 34, 35, and 32. The readings are stored in the variables val1, val2, and val3 for further processing.
3. Unlocking the pattern logic
switch (patternStep) {…}
A switch statement manages the unlock sequence based on the value of the patternStep variable.
Case 0:
if (val1 > threshold) {…}
Checks if the value from the first touch sensor (val1) is greater than the threshold. If true, it means the first pane has been touched.
patternStep = 1;
Advances patternStep to 1, marking the first step in the sequence.
delay(delayTime);
Applies a short delay to debounce the sensor input.
break;
Exits the current case.
Case 1:
if (val2 > threshold) {…}
Checks if the value from the second touch sensor (val2) exceeds the threshold.
patternStep = 2;
Advances patternStep to 2.
delay(delayTime);
Adds a delay for stability.
break;
Exits the current case.
Case 2:
if (val3 > threshold) {…}
Checks if the value from the third touch sensor (val3) is greater than the threshold.
digitalWrite(relay, HIGH);
Activates the relay, unlocking the door.
delay(2000);
Keeps the relay active (door unlocked) for two seconds.
digitalWrite(relay, LOW);
Deactivates the relay to relock the door.
patternStep = 0;
Resets patternStep to 0, ready for the next unlock sequence.
break;
Exits the current case.
else if (val1 > threshold || val2 > threshold) {…}
If the third sensor is not touched but either the first or second sensor is activated, the pattern resets.
patternStep = 0;
Resets the sequence when the pattern is broken.
delay(delayTime);
Applies a short delay.
break;
Exits the case.
delay(100);
Adds a brief delay to prevent the ESP32 from running the loop too quickly.
You can complete the code inside the folder: Smart Lock
Conclusion
This project demonstrates a discreet, non-invasive smart lock system designed for doors with no available mounting surfaces. It is more than a workaround for key access; it redefines the concept of interaction itself. Instead of adding visible technology, the design allows the door to become the interface.
You may also like:
Filed Under: Tutorials






















Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.