Golang Door Control: Difference between revisions
Appearance
m Jferguson moved page RFID-Door-Control-Application to Golang Door Control |
No edit summary |
||
| Line 8: | Line 8: | ||
| notes = Runs on the Raspberry Pi above the shop door. | | notes = Runs on the Raspberry Pi above the shop door. | ||
}} | }} | ||
== Door Access Control System == | |||
The Door Access Control System is a Go-based application that manages physical door access using RFID badge authentication and keypad PIN entry. It runs on a Raspberry Pi | |||
connected to an Arduino Nano, integrating with a centralized member management API and an MQTT broker for real-time event notifications. | |||
=== Features === | |||
==== Multi-Factor Authentication ==== | |||
* '''RFID Badge Scanning''' — Supports both 34-bit and 26-bit Wiegand protocol readers for contactless identification. | |||
* '''PIN/Keycode Entry''' — Keypad input provides a second authentication factor (knowledge-based). | |||
* '''Active Account Verification''' — Only members marked as active in the system are granted access. | |||
==== Centralized Member Synchronization ==== | |||
* Periodically syncs the local user database from a remote member management API. | |||
* Member records include badge ID, name, hashed credentials, and active/admin status. | |||
* Local SQLite database is atomically rebuilt on each sync to ensure consistency. | |||
* Configurable sync interval (default: every 30 seconds). | |||
==== MQTT Event Notifications ==== | |||
* Publishes real-time door events (access granted, access denied, doorbell, startup) to an MQTT broker. | |||
* Supports remote unlock commands via a dedicated MQTT topic. | |||
* Configurable broker address, credentials, and topic names. | |||
==== Audit Trail ==== | |||
* Every authentication attempt (success or failure) is reported to the remote API with a timestamp, badge ID, and result reason. | |||
* Local logging to both console and file captures RFID scans, database updates, API communication, and error conditions. | |||
==== Hardware Integration ==== | |||
* Communicates with an Arduino Nano over serial (9600 baud) to control: | |||
** Door lock relay (3-second unlock duration) | |||
** LED indicator for user feedback | |||
** Audio buzzer for audible feedback | |||
** Doorbell relay | |||
* Automatic serial port reconnection if the USB device is disconnected. | |||
==== Doorbell Support ==== | |||
* A triple-press of the ESC key on the keypad triggers a doorbell notification, published via MQTT for integration with external alerting. | |||
==== Configuration ==== | |||
* Fully configurable via environment variables (prefixed with <code>RFID_</code>): | |||
** Serial port and baud rate | |||
** Log file and database file paths | |||
** Remote API URL and authentication key | |||
** MQTT broker address, credentials, and topics | |||
** API update interval | |||
* Supports <code>direnv</code> for streamlined development environments. | |||
==== Reliability ==== | |||
* Automatic reconnection on serial port loss (10-second retry interval). | |||
* Graceful error handling with detailed logging. | |||
* Designed for unattended operation, launched at boot via cron. | |||
==== Cross-Compilation ==== | |||
* Build targets for native, ARMv5, and ARM64 architectures via Makefile. | |||
=== Technology Stack === | |||
{| class="wikitable" | |||
|- | |||
! Component !! Technology | |||
|- | |||
| Language || Go | |||
|- | |||
| MQTT Client || Eclipse Paho | |||
|- | |||
| Database || SQLite3 | |||
|- | |||
| Serial I/O || jacobsa/go-serial | |||
|- | |||
| Configuration || kelseyhightower/envconfig | |||
|- | |||
| Microcontroller || Arduino Nano | |||
|- | |||
| RFID Protocol || Wiegand (34-bit / 26-bit) | |||
|} | |||
=== System Architecture === | |||
<pre> | |||
Wiegand Reader → Arduino Nano → (Serial) → Door Control App → SQLite DB | |||
↓ | |||
MQTT Broker (event notifications) | |||
↓ | |||
Remote API (member sync & audit logging) | |||
</pre> | |||
Latest revision as of 16:05, 16 March 2026
Golang Door Control |
|
|---|---|
| About | Local application that handles RFID & PIN input and door control |
| Hosted At | https://github.com/bseishen/golang_doorcontrol |
| Source | View Source |
| Language | GoLang |
| Contact | Joe Ferguson |
| Notes | Runs on the Raspberry Pi above the shop door. |
Door Access Control System
The Door Access Control System is a Go-based application that manages physical door access using RFID badge authentication and keypad PIN entry. It runs on a Raspberry Pi connected to an Arduino Nano, integrating with a centralized member management API and an MQTT broker for real-time event notifications.
Features
Multi-Factor Authentication
- RFID Badge Scanning — Supports both 34-bit and 26-bit Wiegand protocol readers for contactless identification.
- PIN/Keycode Entry — Keypad input provides a second authentication factor (knowledge-based).
- Active Account Verification — Only members marked as active in the system are granted access.
Centralized Member Synchronization
- Periodically syncs the local user database from a remote member management API.
- Member records include badge ID, name, hashed credentials, and active/admin status.
- Local SQLite database is atomically rebuilt on each sync to ensure consistency.
- Configurable sync interval (default: every 30 seconds).
MQTT Event Notifications
- Publishes real-time door events (access granted, access denied, doorbell, startup) to an MQTT broker.
- Supports remote unlock commands via a dedicated MQTT topic.
- Configurable broker address, credentials, and topic names.
Audit Trail
- Every authentication attempt (success or failure) is reported to the remote API with a timestamp, badge ID, and result reason.
- Local logging to both console and file captures RFID scans, database updates, API communication, and error conditions.
Hardware Integration
- Communicates with an Arduino Nano over serial (9600 baud) to control:
- Door lock relay (3-second unlock duration)
- LED indicator for user feedback
- Audio buzzer for audible feedback
- Doorbell relay
- Automatic serial port reconnection if the USB device is disconnected.
Doorbell Support
- A triple-press of the ESC key on the keypad triggers a doorbell notification, published via MQTT for integration with external alerting.
Configuration
- Fully configurable via environment variables (prefixed with
RFID_):- Serial port and baud rate
- Log file and database file paths
- Remote API URL and authentication key
- MQTT broker address, credentials, and topics
- API update interval
- Supports
direnvfor streamlined development environments.
Reliability
- Automatic reconnection on serial port loss (10-second retry interval).
- Graceful error handling with detailed logging.
- Designed for unattended operation, launched at boot via cron.
Cross-Compilation
- Build targets for native, ARMv5, and ARM64 architectures via Makefile.
Technology Stack
| Component | Technology |
|---|---|
| Language | Go |
| MQTT Client | Eclipse Paho |
| Database | SQLite3 |
| Serial I/O | jacobsa/go-serial |
| Configuration | kelseyhightower/envconfig |
| Microcontroller | Arduino Nano |
| RFID Protocol | Wiegand (34-bit / 26-bit) |
System Architecture
Wiegand Reader → Arduino Nano → (Serial) → Door Control App → SQLite DB
↓
MQTT Broker (event notifications)
↓
Remote API (member sync & audit logging)