|
ESP8266 Door Access Control System
|
Functions | |
| void | callback (char *topic, byte *payload, unsigned int length) |
| MQTT message callback handler. | |
| void | setup () |
| Arduino setup function. | |
| void | reset_code () |
| Resets the PIN input buffer and index. | |
| void | publishTap () |
| Publishes keypad tap feedback via MQTT. | |
| 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. | |
| const byte | ROWS = 4 |
| Number of rows in the keypad matrix. | |
| const byte | COLS = 4 |
| Number of columns in the keypad matrix. | |
| char | keys [ROWS][COLS] |
| Logical keypad layout. | |
| byte | rowPins [ROWS] = {16, 5, 4, 0} |
| GPIO pins connected to keypad rows. | |
| byte | colPins [COLS] = {2, 14, 12, 13} |
| GPIO pins connected to keypad columns. | |
| Keypad | keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS) |
| Keypad instance handling scanning and debouncing. | |
| constexpr uint8_t | CODE_LENGTH = 4 |
| Required PIN length. | |
| char | input [CODE_LENGTH+1] = {0} |
| Input buffer for PIN digits. | |
| uint8_t | currentIdx = 0 |
| Current index into the PIN buffer. | |
| bool | kpEnabled = false |
| Indicates whether keypad input is currently enabled. | |
This firmware runs on an ESP-based Arduino-compatible board and implements the second stage of the access control system.
Hardware components:
Functional responsibilities:
The keypad is only active after successful RFID authentication, which is signaled asynchronously via MQTT.
| 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 141 of file esp2_keypad.ino.
| void loop | ( | ) |
Arduino main loop.
Handles:
Definition at line 256 of file esp2_keypad.ino.
| void publishTap | ( | ) |
Publishes keypad tap feedback via MQTT.
Sends the current PIN length after each valid keypress, allowing external systems to provide visual or audio feedback.
Definition at line 235 of file esp2_keypad.ino.
| void reset_code | ( | ) |
Resets the PIN input buffer and index.
Clears any partially entered PIN and prepares the buffer for new input.
Definition at line 224 of file esp2_keypad.ino.
| void setup | ( | ) |
Arduino setup function.
Initializes Serial output, WiFi connection, MQTT client, and topic subscriptions.
Definition at line 188 of file esp2_keypad.ino.
|
constexpr |
Required PIN length.
Definition at line 107 of file esp2_keypad.ino.
| byte colPins[COLS] = {2, 14, 12, 13} |
GPIO pins connected to keypad columns.
Order must match COLS definition. D4, D5, D6, D7
Definition at line 87 of file esp2_keypad.ino.
| const byte COLS = 4 |
Number of columns in the keypad matrix.
Definition at line 60 of file esp2_keypad.ino.
| uint8_t currentIdx = 0 |
Current index into the PIN buffer.
Definition at line 117 of file esp2_keypad.ino.
|
constexpr |
Unique device identifier used in MQTT topics.
Definition at line 52 of file esp2_keypad.ino.
| char input[CODE_LENGTH+1] = {0} |
Input buffer for PIN digits.
One extra byte is reserved for the null terminator.
Definition at line 114 of file esp2_keypad.ino.
Keypad instance handling scanning and debouncing.
Definition at line 102 of file esp2_keypad.ino.
Logical keypad layout.
Defines the character returned for each row/column intersection.
Definition at line 67 of file esp2_keypad.ino.
| bool kpEnabled = false |
Indicates whether keypad input is currently enabled.
This flag is controlled via MQTT messages from the access controller.
Definition at line 124 of file esp2_keypad.ino.
|
constexpr |
MQTT broker hostname.
Definition at line 43 of file esp2_keypad.ino.
|
constexpr |
MQTT password.
Definition at line 49 of file esp2_keypad.ino.
|
constexpr |
MQTT broker port.
Definition at line 45 of file esp2_keypad.ino.
|
constexpr |
MQTT username.
Definition at line 47 of file esp2_keypad.ino.
| WifiMqttClient net |
WiFi + MQTT client wrapper.
Definition at line 35 of file esp2_keypad.ino.
| byte rowPins[ROWS] = {16, 5, 4, 0} |
GPIO pins connected to keypad rows.
Order must match ROWS definition. D0, D1, D2, D3
Definition at line 80 of file esp2_keypad.ino.
| const byte ROWS = 4 |
Number of rows in the keypad matrix.
Definition at line 57 of file esp2_keypad.ino.
|
constexpr |
WiFi password.
Definition at line 40 of file esp2_keypad.ino.
|
constexpr |
WiFi SSID.
Definition at line 38 of file esp2_keypad.ino.