Skip to content

adithyarg/STM32-Smart-Factory-Access-Control

Repository files navigation

STM32 Smart Factory Access Control System

A complete employee access control system built with STM32F401RE featuring biometric touch sensor, keypad authentication, and visual feedback.

Features

  • 🔐 Secure Access Control - Employee ID validation with authorized personnel database
  • 📱 1.8" TFT Display - Real-time visual feedback with ST7735 driver
  • ⌨️ 4x3 Matrix Keypad - Numeric ID entry with # to submit, * to clear
  • 👆 Touch Sensor - Capacitive touch activation
  • 🚨 Audio Alerts - Different buzzer patterns for granted/denied access
  • 💡 LED Indicators - Green LED for access granted
  • 🔓 Relay Control - Automatic door lock/unlock (10-second timer)
  • 🚫 Security Alert - Continuous buzzer alarm for unauthorized access attempts

Hardware Requirements

  • MCU: STM32 Nucleo-F401RE
  • Display: 1.8" TFT LCD (128x160) ST7735 via SPI1
  • Keypad: 4x3 Matrix Keypad
  • Touch Sensor: Capacitive touch sensor (PC8)
  • LED: Green LED with 220Ω resistor (PC1)
  • Buzzer: Active buzzer (PA4)
  • Relay: 5V relay module for door lock (PB12)

Pin Configuration

Display (ST7735 - SPI1)

  • CS: PB6
  • DC: PA9
  • RST: PC7
  • SCK: PA5 (SPI1_SCK)
  • MOSI: PA7 (SPI1_MOSI)

Keypad (4x3 Matrix)

  • Rows (Output): R1=PA10, R2=PB15, R3=PB14, R4=PB13
  • Cols (Input): C1=PB3, C2=PC4, C3=PB5

Other Peripherals

  • Touch Sensor: PC8 (Input with pull-down)
  • Green LED: PC1 (Output)
  • Buzzer: PA4 (Output)
  • Relay: PB12 (Output)

Authorized Employees

Employee ID Name
1234 ADI
2005 GREY
2000 DEX

System Workflow

  1. Idle State: Display shows "TOUCH SENSOR TO START"
  2. Touch Activation: User touches capacitive sensor
  3. ID Entry: Enter employee ID using keypad (0-9)
    • Press # to submit
    • Press * to clear entry
  4. Verification: System validates ID against database
  5. Access Granted (Valid ID):
    • Green screen: "WELCOME [NAME]"
    • Green LED turns ON
    • 1-second buzzer beep
    • Relay unlocks door
    • Door remains unlocked for 10 seconds
    • Returns to idle state
  6. Access Denied (Invalid ID):
    • Red screen: "ACCESS DENIED"
    • Continuous buzzer alarm (until reset)
    • Door remains locked

Software Architecture

Core/
├── Inc/
│   ├── buzzer.h           - Buzzer control
│   ├── display_st7735.h   - ST7735 TFT driver
│   ├── keypad.h           - 4x3 keypad scanner
│   ├── led.h              - LED control
│   ├── relay.h            - Relay control
│   ├── simple_text.h      - Text rendering
│   ├── system_state.h     - State machine
│   └── touch.h            - Touch sensor
└── Src/
    ├── buzzer.c
    ├── display_st7735.c
    ├── keypad.c
    ├── led.c
    ├── main.c             - Main program
    ├── relay.c
    ├── simple_text.c
    ├── system_state.c     - Core logic
    └── touch.c

Building and Flashing

  1. Open project in STM32CubeIDE
  2. Build: Project → Build All (Ctrl+B)
  3. Flash: Run → Debug (F11)

State Machine

  • STATE_IDLE: Waiting for touch sensor activation
  • STATE_WAIT_ID: Accepting keypad input
  • STATE_VERIFY: Validating employee ID
  • STATE_UNLOCK: Door unlocked, access granted

Customization

Adding New Employees

Edit Core/Src/system_state.c:

static const Employee_t employees[] = {
    {"1234", "ADI"},
    {"2005", "GREY"},
    {"2000", "DEX"},
    {"YOUR_ID", "YOUR_NAME"}  // Add here
};

Changing Door Unlock Duration

Edit Core/Src/system_state.c:

// Wait 10 seconds (change to desired duration in milliseconds)
while (HAL_GetTick() - unlock_timer < 10000) {

Security Features

  • ✅ Employee ID validation
  • ✅ Visual feedback for all states
  • ✅ Audio alerts for access attempts
  • ✅ Continuous alarm for unauthorized access
  • ✅ Automatic door re-lock after timeout
  • ✅ Touch sensor activation prevents accidental triggers

Future Enhancements

  • RTC for timestamp logging
  • SD card for access log storage
  • WiFi connectivity (ESP32 integration)
  • RFID card reader support
  • Fingerprint sensor integration
  • Web dashboard for monitoring
  • Email/SMS notifications

License

MIT License - Feel free to use and modify for your projects!

Author

Built with ❤️ for factory security and access control applications


⭐ Star this repo if you find it useful!

About

stm32, embedded-systems, access-control, security, iot, factory-automation, st7735, tft-display, keypad, embedded-c, stm32f4, nucleo, door-lock, authentication

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages