Skip to content

HMI Door Lock

Smart HMI Door Lock with Passcode | Arduino Tutorial

In this project, you will learn how to make an HMI door lock using Arduino. This HMI door lock project allows you to unlock a door with a passcode, making it a simple and practical Arduino-based security solution for your DIY electronics projects.


Introduction

Hi friends, in this project I’m going to show you how to make an HMI door lock using Arduino. The Human Machine Interface (HMI) is a very user-friendly interface that allows you to interact with the system using a touchscreen display. By combining Arduino with an HMI, we can design a simple yet effective electronic door lock system that works with a passcode.

This project is great for learning about:

  • Arduino serial communication

  • Relay switching

  • Using an HMI for user input

  • Transistor-based relay driving

At the end of this project, you will have a fully functional door lock that can be controlled by entering a password on the HMI.


Applications

  • Home and office door locking

  • Smart lockers and cabinets

  • Security access control

  • Industrial machinery interlocks


 Materials for the Project

ComponentQuantityDescriptionBuy Link
Arduino Nano1Main microcontroller boardBuy Here
HMI Display (Nextion)1Human Machine Interface (HMI) touch screenBuy Here
5V Relay Module1Single channel relay for switching lockBuy Here
BC547 Transistor1NPN transistor for relay drivingBuy Here
1N4148 Diode1Flyback diode to protect transistorBuy Here
Resistor 1K1Base resistor for BC547Buy Here
2-Pin Terminal Blocks2For power and relay output connectionsBuy Here
5V Power Supply1Power source for Arduino and relayBuy Here
Jumper WiresAs req.For connectionsBuy Here
Breadboard / PCB1For assembling the circuitBuy Here

Useful Tools 

ToolQuantityPurpose / NotesClick & Buy
Soldering Iron Kit1For making permanent connectionsClick & Buy
Solder Wire (60/40, 0.8mm)1Electrical solderingClick & Buy
Wire Stripper & Cutter1Stripping jumper wiresClick & Buy
Mini Screwdriver Set1For module and relay terminal screwsClick & Buy
Multimeter1Testing voltages and continuityClick & Buy
Hot Glue Gun (optional)1Securing components in placeClick & Buy
Small Pliers1Holding and bending wiresClick & Buy
Heat Shrink Tubing Set1Insulating exposed wiresClick & Buy

 


Circuit Diagram Explanation

The wiring of this HMI door lock project is straightforward:

  1. Arduino & Power:

    • Arduino provides the 5V and GND reference for all components.

    • A 2-pin terminal block is connected to supply external power if needed.

  2. HMI Connections:

    • VCC → 5V of Arduino

    • GND → GND of Arduino

    • TX → D2 (Arduino)

    • RX → D3 (Arduino)
      This allows serial communication between Arduino and the HMI display.

  3. Relay Driver Circuit:

    • A BC547 transistor drives the relay coil.

    • Pin 2 (Base) is connected through a 1K resistor to Arduino D4.

    • Pin 3 (Emitter) goes to GND.

    • Pin 1 (Collector) connects to one side of the relay coil.

    • The other side of the relay coil is connected to 5V.

    • A 1N4148 diode is placed across the relay coil to suppress back EMF.

  4. Relay Output Wiring:

    • COM and N.O. (Normally Open) terminals of the relay connect to the door lock system (electromagnetic lock or solenoid).

This way, when the correct password is entered on the HMI, Arduino activates the relay through the BC547 transistor, unlocking the door.

Download Circuit Diagram 

HMI Door Lock Circuit Diagram 
9/16/2025

Step-by-Step Guide

Step 1: Setup Arduino and Power

  • Place the Arduino on a breadboard or PCB.

  • Connect a 2-pin terminal block for power input (5V and GND).

Step 2: Connect the HMI Display

  • Connect VCC to 5V and GND to GND.

  • Connect TX of HMI → D2 of Arduino.

  • Connect RX of HMI → D3 of Arduino.

Step 3: Build Relay Driver Circuit

  • Insert BC547 transistor on the board.

  • Connect Emitter (pin 3) → GND.

  • Connect Base (pin 2) → Arduino D4 via a 1K resistor.

  • Connect Collector (pin 1) → Relay coil.

  • Connect the other relay coil pin → 5V.

  • Place 1N4148 diode across relay coil (Anode → transistor, Cathode → 5V).

Step 4: Relay Output Wiring

  • Connect COM terminal → Lock supply line.

  • Connect N.O. terminal → Door lock device.

Step 5: Upload Code

  • Write Arduino code that:

    • Reads passcode input from HMI.

    • Compares with stored password.

    • If correct → activates relay for a few seconds (door unlocks).

    • If wrong → relay stays off.

Step 6: Test the Project

  • Power up the circuit.

  • Upload the code to Arduino.

  • On HMI screen, enter the passcode.

  • Relay should click and unlock the door if the passcode is correct.

Arduino Code     


Working Principle HMI Door Lock

  • The HMI provides a user-friendly interface to enter a password.

  • Arduino receives the serial data and checks against a pre-stored password.

  • If it matches, Arduino drives the BC547 transistor → activates the relay → unlocks the door.

  • A diode protects the transistor from back EMF generated by the relay coil.


Advantages HMI Door Lock

  • Simple and cost-effective

  • Can be modified with multiple passwords

  • Easy to expand with fingerprint or RFID modules

  • Low power consumption


Possible Improvements

  • Add EEPROM storage to save password permanently.

  • Use solenoid lock instead of relay-controlled lock for more reliability.

  • Add a buzzer for wrong password attempts.

  • Use Wi-Fi or Bluetooth for remote unlocking.


FAQs HMI Door Lock

1. Can I use any HMI display for this project?

Yes, you can use Nextion or similar HMI modules. Just make sure the voltage levels match Arduino.

2. Can I change the passcode without reprogramming Arduino?

Yes, if you add EEPROM storage in the code, you can save a new passcode from the HMI interface.

3. Can this circuit drive an electric strike lock?

Yes, but you may need a higher current relay depending on the lock specification.

4. What happens if the power goes off?

The door will lock by default since the relay will be de-energized.

5. Is this project safe for a real home door?

It is suitable for learning and small projects. For real security, commercial-grade locks with encryption are recommended.

 

Leave a Reply

Your email address will not be published. Required fields are marked *