Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How to design a hidden touch-based smart lock using a glass interface

By Ayush Jain October 29, 2025

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:


  • The road to ISM 2.0: Building a self-reliant chip ecosystem…

  • How to enable Wi-Fi provisioning in ESP32-based IoT products

  • Insight: How does a motion sensor or PIR sensor work?

  • What top AI chips are expected to launch in 2025?

  • What are the types of AI chips and how are…

  • How to design a distance meter using ESP32

  • How to build your own smart home

  • How ESP32 boards can communicate without a router or the…

  • How to troubleshoot common ESP32-CAM problems

  • How to build a fire alarm with SMS and WhatsApp…

  • How to manage data on ESP32 for IoT projects

Filed Under: Tutorials
Tagged With: ESP32, lock, sensors, Smart Sensors, Touchlock, tutorial
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

Submit a Guest Post

submit a guest post

EE TECH TOOLBOX

“ee
Tech Toolbox: Power Efficiency
Discover proven strategies for power conversion, wide bandgap devices, and motor control — balancing performance, cost, and sustainability across industrial, automotive, and IoT systems.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions.

  • Can anyone please help me with this single board computer?
  • Anyone successfully communicated to the BlueNRG-M0 module on the B-L4S5I-IOT01A board
  • How to Build an Audio Tone Control?
  • Current version of LTspice not working on Windows 11?
  • Addressable Latch in My Logic Project

RSS Electro-Tech-Online.com Discussions

  • Measuring controller current output with a meter
  • KiCad custom symbol definition correct approach
  • restarting this Christmas project
  • Anyone In The US Ordered From AliExpress Recently?
  • My Advanced Realistic Humanoid Robots Project

Featured Tutorials

Real Time Hardware Filter Design

  • Practical implementation of bandpass and band reject filters
    Practical implementation of bandpass and band reject filters
  • Practical application of hardware filters with real-life examples
    Practical application of hardware filters with real-life examples
  • A filter design example
    A filter design example
  • Types of filter responses
    Types of filter responses
  • What are the two types of hardware filters?
    What are the two types of hardware filters?
  • What are hardware filters and their types?
    What are hardware filters and their types?
More Tutorials >

Recent Articles

  • Posifa sensors improve low-flow accuracy in compact systems
  • Acopian releases low-profile power supplies rated to 900 W
  • Octavo Systems OSDZU-3 REF Development Platform
  • Same Sky adds enclosure design to its audio engineering capabilities
  • Waterproof SMA-to-MHF I LK assemblies introduced by Amphenol RF

EE ENGINEERING TRAINING DAYS

engineering
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
  • Guest Post Guidelines
  • Advertise
  • Subscribe