ESP8266 Door Access Control System
Loading...
Searching...
No Matches
esp3.ino File Reference

Door actuator, buzzer, and LED controller with MQTT integration. More...

#include <Servo.h>
#include <ArduinoJson.h>
#include <WiFiMqttClient.h>
Include dependency graph for esp3.ino:

Go to the source code of this file.

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.
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.

Detailed Description

Door actuator, buzzer, and LED controller with MQTT integration.

Definition in file esp3.ino.