|
ESP8266 Door Access Control System
|
Classes | |
| struct | BuzzerPattern |
| Describes a buzzer sound pattern. More... | |
Macros | |
| #define | POT_PIN A0 |
| Analog pin for potentiometer (admin servo control). | |
Enumerations | |
| enum class | AccessResult : uint8_t { AccessResult::Denied , AccessResult::Granted , AccessResult::Denied , AccessResult::Granted } |
| Access result enumeration. More... | |
| enum | BuzzerState { BUZZER_IDLE , BUZZER_ON , BUZZER_OFF } |
| Buzzer state enumeration. More... | |
Functions | |
| void | playPattern (const unsigned int *timings, uint8_t length) |
| Starts playing a buzzer pattern. | |
| void | updateBuzzer () |
| Advances the buzzer state machine. | |
| void | stopBuzzer () |
| Immediately stops any active buzzer sound. | |
| void | playLockSound () |
| Plays lock sound pattern. | |
| void | playUnlockSound () |
| Plays unlock sound pattern. | |
| void | playDeniedSound () |
| Plays denied-access sound pattern. | |
| void | playTapSound () |
| Plays keypad tap sound. | |
| static void | forceLock () |
| Forces the system into a locked idle state. | |
| void | callback (char *topic, byte *payload, unsigned int length) |
| MQTT message callback handler. | |
| void | setup () |
| Arduino setup function. | |
| void | loop () |
| Arduino main loop. | |
Variables | |
| WifiMqttClient | net |
| WiFi + MQTT client wrapper. | |
| constexpr char | WIFI_SSID [] = "Mathias2.4" |
| WiFi SSID. | |
| constexpr char | WIFI_PASS [] = "mrbombasticcallmefantastic" |
| WiFi password. | |
| constexpr char | MQTT_HOST [] = "maqiatto.com" |
| MQTT broker hostname. | |
| constexpr uint16_t | MQTT_PORT = 1883 |
| MQTT broker port. | |
| constexpr char | MQTT_USER [] = "hectorfoss@gmail.com" |
| MQTT username. | |
| constexpr char | MQTT_PASS [] = "potter" |
| MQTT password. | |
| constexpr char | DEVICE_ID [] = "door1" |
| Unique device identifier used in MQTT topics. | |
| constexpr uint8_t | RED_PIN = 4 |
| GPIO pin assignments. | |
| constexpr uint8_t | GREEN_PIN = 0 |
| constexpr uint8_t | BUZZER_PIN = 14 |
| constexpr uint8_t | SERVO_PIN = 13 |
| constexpr uint32_t | UNLOCK_TIME_MS = 5000 |
| Door unlock duration (ms). | |
| uint32_t | unlockUntil = 0 |
| Timestamp (ms) until which the door remains unlocked. | |
| bool | unlocked = false |
| Indicates whether the door is currently unlocked. | |
| AccessResult | accessGranted |
| Result of keypad PIN verification. | |
| bool | rfidAccess = false |
| Indicates whether RFID access was granted. | |
| Servo | lock_servo |
| Servo instance controlling the lock mechanism. | |
| bool | servoOpen = false |
| Indicates whether the servo is currently in the open position. | |
| uint8_t | servoAngle |
| Current servo angle (derived from potentiometer in admin mode). | |
| bool | adminServoControl = false |
| Enables direct servo control via potentiometer (admin mode). | |
| const unsigned int | deniedTimings [] |
| Denied access: single long beep. Extra long to scare. | |
| const unsigned int | lockTimings [] |
| Lock sound: long-long-long pattern. | |
| const unsigned int | unlockTimings [] |
| Unlock sound: short-short pattern. | |
| const unsigned int | beepTimings [] |
| Keypad tap sound: short beep. | |
| const unsigned int * | BuzzerPattern::timings |
| uint8_t | BuzzerPattern::length |
| BuzzerState | buzzerState = BUZZER_IDLE |
| Current buzzer state. | |
| BuzzerPattern | currentPattern = {nullptr, 0} |
| Currently active buzzer pattern. | |
| uint8_t | stepIndex = 0 |
| Index into the timing array. | |
| unsigned long | lastChange = 0 |
| Timestamp of last buzzer state change. | |
This firmware runs on an ESP-based Arduino-compatible board and implements the final actuator stage of the access control system.
Hardware components:
Functional responsibilities:
This node does not make access decisions itself; it only reacts to authenticated results produced by the RFID and keypad nodes.
| #define POT_PIN A0 |
|
strong |
| enum BuzzerState |
| void callback | ( | char * | topic, |
| byte * | payload, | ||
| unsigned int | length ) |
MQTT message callback handler.
Handles:
| topic | MQTT topic string. |
| payload | Raw payload bytes. |
| length | Payload length. |
Definition at line 308 of file esp3.ino.
|
static |
| void loop | ( | ) |
| void playDeniedSound | ( | ) |
| void playLockSound | ( | ) |
| void playPattern | ( | const unsigned int * | timings, |
| uint8_t | length ) |
| void playTapSound | ( | ) |
| void playUnlockSound | ( | ) |
| void setup | ( | ) |
| void stopBuzzer | ( | ) |
| void updateBuzzer | ( | ) |
| AccessResult accessGranted |
| bool adminServoControl = false |
| const unsigned int beepTimings[] |
| BuzzerState buzzerState = BUZZER_IDLE |
| BuzzerPattern currentPattern = {nullptr, 0} |
| const unsigned int deniedTimings[] |
|
constexpr |
| unsigned long lastChange = 0 |
| Servo lock_servo |
| const unsigned int lockTimings[] |
|
constexpr |
|
constexpr |
| WifiMqttClient net |
|
constexpr |
| bool rfidAccess = false |
| uint8_t servoAngle |
| bool servoOpen = false |
| const unsigned int* BuzzerPattern::timings |
|
constexpr |
| bool unlocked = false |
| const unsigned int unlockTimings[] |
| uint32_t unlockUntil = 0 |
|
constexpr |