From 3972594f1b85a028d69813e6fafda4aa7c9c69b8 Mon Sep 17 00:00:00 2001 From: Jason Antman Date: Fri, 28 Nov 2025 06:59:50 -0500 Subject: [PATCH 1/4] Add standalone ESPHome hardware test configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created a standalone, non-networked ESPHome configuration for testing all Machine Access Control hardware components without requiring the MAC server or network connectivity. Hardware Test Configuration (hardware-test.yaml): - Completely standalone operation (no WiFi, API, or OTA) - Tests all hardware components: * 16x2 I2C LCD display (PCF8574) * Wiegand RFID reader with card present sensor * Oops button and LED * Relay output * WS2812 NeoPixel status LED - RFID-controlled relay (ON when card inserted, OFF when removed) - Oops button toggles oops LED independently - Idle display shows uptime and WiFi MAC address simultaneously - Status LED color coding: Blue (idle), Green (card present), Yellow (card removed), Red (oops button pressed) ESPHome 2025.11.2 Compatibility Fixes: - Removed deprecated 'rmt_channel' parameter from esp32_rmt_led_strip (auto-assigned in newer ESPHome versions) - Updated MAC address retrieval to use get_mac_address_pretty() instead of deprecated esp_efuse_mac_get_default() - Maintained esp-idf framework to match production configuration Display Format (16x2 LCD): - Line 1: "Up HH:MM:SS" (uptime counter) - Line 2: MAC address without colons (e.g., "AABBCCDDEEFF") - Updates every second when idle - Shows RFID codes, button states during events Documentation (hardware-test.md): - Complete test procedures for each component - Status LED color reference table - Troubleshooting guide - Success criteria checklist - Serial console monitoring instructions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- esphome-configs/2024.6.4/hardware-test.md | 198 +++++++++++++++ esphome-configs/2024.6.4/hardware-test.yaml | 255 ++++++++++++++++++++ 2 files changed, 453 insertions(+) create mode 100644 esphome-configs/2024.6.4/hardware-test.md create mode 100644 esphome-configs/2024.6.4/hardware-test.yaml diff --git a/esphome-configs/2024.6.4/hardware-test.md b/esphome-configs/2024.6.4/hardware-test.md new file mode 100644 index 0000000..6499374 --- /dev/null +++ b/esphome-configs/2024.6.4/hardware-test.md @@ -0,0 +1,198 @@ +# Hardware Test Procedure + +This document describes the standalone hardware test configuration for the Machine Access Control system. + +## Purpose + +The `hardware-test.yaml` ESPHome configuration provides a **standalone, non-networked** test environment for validating all hardware components without requiring the MAC server or network connectivity. All diagnostics are performed locally on the device. + +## Hardware Components Tested + +- **16x2 LCD Display** (I2C PCF8574 on GPIO22/23) +- **Wiegand RFID Reader** (D0: GPIO16, D1: GPIO4) +- **Card Present Sensor** (GPIO18) +- **Oops Button** (GPIO32 input with pullup) +- **Oops LED** (GPIO5 output) +- **Relay Output** (GPIO33) +- **NeoPixel Status LED** (GPIO27 WS2812) + +## Flashing the Test Config + +```bash +# From the esphome-configs/2024.6.4/ directory +esphome run hardware-test.yaml +``` + +On first flash, you'll need to connect via USB. Subsequent updates can use ESPHome's web interface if you temporarily enable WiFi. + +## Test Procedures + +### 1. Power-On Test + +**Expected Behavior:** +- LCD displays: `MAC:` followed by the WiFi MAC address (e.g., `AA:BB:CC:DD:EE:FF`) +- Status LED: Solid **BLUE** +- Relay: OFF +- Oops LED: OFF + +**Verification:** +- ✅ LCD is readable and shows MAC address +- ✅ Status LED is lit blue +- ✅ All outputs are off + +--- + +### 2. Idle Display Cycling + +**Expected Behavior:** +Every 5 seconds when idle (no card present), the LCD cycles between: +1. `MAC:` + MAC address +2. `Uptime:` + time in `HH:MM:SS` format + +**Verification:** +- ✅ Display automatically cycles every 5 seconds +- ✅ Uptime increments correctly +- ✅ Status LED remains blue + +--- + +### 3. RFID Reader Test + +**Procedure:** +1. Present an RFID card/fob to the reader + +**Expected Behavior:** +- LCD displays: `RFID:` followed by the tag code (e.g., `0001234567`) +- **Relay: Turns ON** (you should hear/see it click) +- Status LED: Solid **GREEN** +- Card present sensor activates + +**Verification:** +- ✅ LCD shows the RFID code +- ✅ Relay energizes (LED on relay board lights up) +- ✅ Status LED is green +- ✅ RFID code is logged to serial console + +--- + +### 4. Card Removal Test + +**Procedure:** +1. With card inserted, remove the RFID card + +**Expected Behavior:** +- LCD displays: `Card Removed` for 2 seconds +- **Relay: Turns OFF** +- Status LED: Brief **YELLOW** flash (500ms), then returns to **BLUE** +- Display returns to cycling between MAC and uptime after 2 seconds + +**Verification:** +- ✅ Relay de-energizes immediately +- ✅ Yellow flash is visible +- ✅ Display returns to normal cycling + +--- + +### 5. Oops Button Test + +**Procedure:** +1. Press the oops button (momentary press) + +**Expected Behavior:** +- **Oops LED: Toggles ON** (first press) or **OFF** (second press) +- LCD displays: `OOPS! LED: ON` or `OOPS! LED:OFF` +- Status LED: **RED** while button is held, returns to previous color on release + +**Verification:** +- ✅ Oops LED toggles with each press +- ✅ LCD shows current LED state +- ✅ Status LED turns red during press +- ✅ Status LED returns to blue (idle) or green (card present) after release + +**Note:** The oops button does NOT affect the relay. The relay is only controlled by card insertion/removal. + +--- + +### 6. Combined Test + +**Procedure:** +1. Insert RFID card (relay ON, green LED) +2. Press oops button (toggle oops LED, red LED while held) +3. Release oops button (status LED returns to green) +4. Remove card (relay OFF, yellow flash, return to blue) + +**Verification:** +- ✅ All components respond correctly in combination +- ✅ Status LED returns to appropriate color based on system state +- ✅ No unexpected behavior or crashes + +--- + +## Status LED Color Reference + +| Color | Meaning | When Active | +|-------|---------|-------------| +| **Blue** | Idle/Ready | No card present, system waiting | +| **Green** | Card Present | RFID card inserted, relay active | +| **Yellow** | Card Removed | Brief flash when card is removed | +| **Red** | Oops Button | While oops button is held down | + +## Serial Console Monitoring + +Connect via USB and monitor at 115200 baud to see detailed logs: + +``` +[INFO] [BOOT] WiFi MAC Address: AA:BB:CC:DD:EE:FF +[INFO] [BOOT] Hardware test initialized +[INFO] [TAG] Received RFID tag: 0001234567 +[INFO] [CARD] Card inserted +[INFO] [CARD] Card removed +[INFO] [OOPS] Oops button pressed - toggling LED +``` + +## Troubleshooting + +### LCD shows nothing +- Check I2C connections (SDA: GPIO22, SCL: GPIO23) +- Verify LCD I2C address is 0x27 +- Adjust LCD contrast potentiometer if present + +### RFID not reading +- Check wiegand connections (D0: GPIO16, D1: GPIO4) +- Verify card present wire on GPIO18 +- Check serial logs for wiegand errors + +### Relay not clicking +- Verify relay connection on GPIO33 +- Check relay power supply +- Listen for click sound or check relay LED + +### Status LED not lighting +- Check NeoPixel connection on GPIO27 +- Verify WS2812 LED is powered +- Try different brightness levels + +### Oops LED not working +- Check GPIO5 connection +- Verify LED polarity (if direct connection) +- Check for current-limiting resistor if needed + +## Success Criteria + +All tests pass when: +- ✅ LCD displays all information correctly +- ✅ RFID codes are read and displayed +- ✅ Relay turns ON with card, OFF without card +- ✅ All four status LED colors function correctly +- ✅ Oops button toggles oops LED reliably +- ✅ Card present sensor detects insertion/removal +- ✅ Display cycling works in idle mode +- ✅ No crashes or unexpected resets + +## Notes + +- This configuration is **completely standalone** - no WiFi or network required +- All state changes are logged to the serial console +- The MAC address displayed is the **WiFi interface** MAC (even though WiFi is disabled) +- Uptime resets to 00:00:00 on every reboot +- The configuration uses **no external files** or secrets diff --git a/esphome-configs/2024.6.4/hardware-test.yaml b/esphome-configs/2024.6.4/hardware-test.yaml new file mode 100644 index 0000000..9c09120 --- /dev/null +++ b/esphome-configs/2024.6.4/hardware-test.yaml @@ -0,0 +1,255 @@ +# ESPHome Hardware Test Configuration +# +# This is a standalone configuration for testing the machine access control hardware +# without any network connectivity. All testing is done locally on the device. +# +# Hardware components tested: +# - PCF8574 16x2 I2C character LCD (SDA: GPIO22, SCL: GPIO23) +# - Wiegand RFID reader (D0: GPIO16, D1: GPIO4, Card Present: GPIO18) +# - Oops button (GPIO32 with internal pullup) +# - Oops button LED (GPIO5) +# - Output relay (GPIO33) +# - WS2812 NeoPixel status LED (GPIO27) + +substitutions: + device_name: "hardware-test" + +esphome: + name: ${device_name} + friendly_name: Hardware Test + on_boot: + # Priority 600: Get MAC address early + - priority: 600 + then: + - lambda: |- + std::string mac_pretty = get_mac_address_pretty(); + // Remove colons to fit on 16-char display + id(mac_address) = ""; + for (char c : mac_pretty) { + if (c != ':') id(mac_address) += c; + } + ESP_LOGI("BOOT", "WiFi MAC Address: %s", mac_pretty.c_str()); + + # Priority -100: Initialize display and LED after everything is ready + - priority: -100 + then: + - delay: 1s + - lambda: |- + id(display_content) = (std::string)"Up 00:00:00\n" + id(mac_address); + ESP_LOGI("BOOT", "Hardware test initialized"); + # Set status LED to blue (idle/ready) + - light.turn_on: + id: status_led + brightness: 100% + red: 0% + green: 0% + blue: 100% + +esp32: + board: esp32dev + framework: + type: esp-idf + +# Enable logging via USB serial only +logger: + level: DEBUG + +# NO WiFi, NO API, NO OTA - completely standalone operation + +globals: + - id: display_content + type: std::string + restore_value: false + max_restore_data_length: 34 + initial_value: '"Hardware Test\nStarting..."' + - id: rfid_tag + type: std::string + restore_value: false + max_restore_data_length: 34 + initial_value: '""' + - id: oops_led_state + type: bool + restore_value: false + initial_value: 'false' + - id: card_present_flag + type: bool + restore_value: false + initial_value: 'false' + - id: mac_address + type: std::string + restore_value: false + initial_value: '""' + +i2c: + sda: GPIO22 + scl: GPIO23 + frequency: 400kHz + +sensor: + - platform: uptime + name: Uptime + id: uptime_sensor + update_interval: 1s + - platform: internal_temperature + name: "Internal Temperature" + id: internal_temperature_c + update_interval: 15s + +binary_sensor: + # Card present sensor + - platform: gpio + pin: GPIO18 + name: "Card Present" + id: card_present + on_press: + then: + - lambda: |- + ESP_LOGI("CARD", "Card inserted"); + id(card_present_flag) = true; + on_release: + then: + - lambda: |- + ESP_LOGI("CARD", "Card removed"); + id(card_present_flag) = false; + id(rfid_tag) = ""; + id(display_content) = "Card Removed"; + - output.turn_off: relay_output + # Yellow flash for card removal + - light.turn_on: + id: status_led + brightness: 100% + red: 100% + green: 100% + blue: 0% + - delay: 500ms + # Return to blue (idle) + - light.turn_on: + id: status_led + brightness: 100% + red: 0% + green: 0% + blue: 100% + - delay: 1500ms + + # Oops button + - platform: gpio + pin: + number: GPIO32 + mode: + input: true + pullup: true + name: "Oops Button" + id: oops_button + filters: + - delayed_on: 10ms + on_press: + then: + - lambda: |- + ESP_LOGI("OOPS", "Oops button pressed - toggling LED"); + id(oops_led_state) = !id(oops_led_state); + if (id(oops_led_state)) { + id(oops_led).turn_on(); + id(display_content) = "OOPS! LED: ON"; + } else { + id(oops_led).turn_off(); + id(display_content) = "OOPS! LED:OFF"; + } + # Red status LED while button pressed + - light.turn_on: + id: status_led + brightness: 100% + red: 100% + green: 0% + blue: 0% + on_release: + then: + # Return to appropriate color based on card state + - if: + condition: + lambda: 'return id(card_present_flag);' + then: + # Green if card present + - light.turn_on: + id: status_led + brightness: 100% + red: 0% + green: 100% + blue: 0% + else: + # Blue if idle + - light.turn_on: + id: status_led + brightness: 100% + red: 0% + green: 0% + blue: 100% + +button: + - platform: restart + name: "Reboot ESP" + +output: + - platform: gpio + pin: GPIO33 + id: relay_output + - platform: gpio + pin: GPIO5 + id: oops_led + +light: + - platform: esp32_rmt_led_strip + rgb_order: RGB + pin: GPIO27 + num_leds: 1 + chipset: ws2812 + name: "Status LED" + id: status_led + restore_mode: ALWAYS_OFF + +wiegand: + - id: keypad + d0: GPIO16 + d1: GPIO4 + on_tag: + - lambda: |- + ESP_LOGI("TAG", "Received RFID tag: %s", x.c_str()); + id(rfid_tag) = x.c_str(); + id(display_content) = (std::string)"RFID:\n" + x; + # Turn relay ON when card scanned + - output.turn_on: relay_output + # Green status LED for card present + - light.turn_on: + id: status_led + brightness: 100% + red: 0% + green: 100% + blue: 0% + +display: + - platform: lcd_pcf8574 + dimensions: 16x2 + address: 0x27 + id: my_display + update_interval: 500ms + lambda: |- + it.print(id(display_content)); + +# Update idle display with uptime and MAC address +interval: + - interval: 1s + then: + - lambda: |- + // Only update display when idle (no card present and no recent events) + if (!id(card_present_flag) && id(rfid_tag).empty() && + id(display_content) != "Card Removed" && + id(display_content).find("OOPS") == std::string::npos) { + // Show uptime on line 1, MAC on line 2 + int seconds = (int)id(uptime_sensor).state; + int hours = seconds / 3600; + int minutes = (seconds % 3600) / 60; + int secs = seconds % 60; + char buf[34]; + snprintf(buf, sizeof(buf), "Up %02d:%02d:%02d\n%s", + hours, minutes, secs, id(mac_address).c_str()); + id(display_content) = buf; + } From 8dba1560739f4f4a115ca27f5e0bca1e065aa312 Mon Sep 17 00:00:00 2001 From: Jason Antman Date: Fri, 28 Nov 2025 07:02:30 -0500 Subject: [PATCH 2/4] Hardware test ESPHome config is for 2025.11.2 not 2024.6.4 --- esphome-configs/{2024.6.4 => 2025.11.2}/hardware-test.md | 0 esphome-configs/{2024.6.4 => 2025.11.2}/hardware-test.yaml | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename esphome-configs/{2024.6.4 => 2025.11.2}/hardware-test.md (100%) rename esphome-configs/{2024.6.4 => 2025.11.2}/hardware-test.yaml (100%) diff --git a/esphome-configs/2024.6.4/hardware-test.md b/esphome-configs/2025.11.2/hardware-test.md similarity index 100% rename from esphome-configs/2024.6.4/hardware-test.md rename to esphome-configs/2025.11.2/hardware-test.md diff --git a/esphome-configs/2024.6.4/hardware-test.yaml b/esphome-configs/2025.11.2/hardware-test.yaml similarity index 100% rename from esphome-configs/2024.6.4/hardware-test.yaml rename to esphome-configs/2025.11.2/hardware-test.yaml From 4e80ec66ec586e903f46f29762b37088401e7781 Mon Sep 17 00:00:00 2001 From: Jason Antman Date: Fri, 28 Nov 2025 07:08:23 -0500 Subject: [PATCH 3/4] ESPHome version compatibility fixes --- docs/source/hardware.rst | 4 +- .../2025.11.2/no-current-input.yaml | 376 ++++++++++++++++++ 2 files changed, 378 insertions(+), 2 deletions(-) create mode 100644 esphome-configs/2025.11.2/no-current-input.yaml diff --git a/docs/source/hardware.rst b/docs/source/hardware.rst index c61fe5c..3b3651b 100644 --- a/docs/source/hardware.rst +++ b/docs/source/hardware.rst @@ -125,7 +125,7 @@ The following table lists the components required for the Version 1 MCU hardware Wiring ++++++ -This is intended to work with `esphome-configs/2024.6.4/no-current-input.yaml `__. +This is intended to work with `esphome-configs/2025.11.2/no-current-input.yaml `__. .. image:: ../../hardware/v1_mcu/Hardware_v1.png :alt: Wiring diagram of system @@ -199,7 +199,7 @@ There is an example enclosure for the unit, 3D printed with a few laser cut part ESPHome Configurations ---------------------- -Example ESPHome configurations for various ESPHome versions and various hardware combinations can be found in the `esphome-configs/ directory of the git repo `__ broken down by ESPHome version. +Example ESPHome configurations for various ESPHome versions and various hardware combinations can be found in the `esphome-configs/ directory of the git repo `__ broken down by ESPHome version. New installations should always use the newest supported ESPHome version, as bug fixes and features are not backported to earlier versions of these configs. All of the example ESPHome configurations begin with a ``substitutions`` key, which contains a ``machine_name`` substitution. This must be set to the same name as used in the :ref:`configuration.machines-json` config file. If desired, you can override the ``esphome`` ``name`` and ``friendly_name`` values (though this is not recommended). diff --git a/esphome-configs/2025.11.2/no-current-input.yaml b/esphome-configs/2025.11.2/no-current-input.yaml new file mode 100644 index 0000000..d591d8a --- /dev/null +++ b/esphome-configs/2025.11.2/no-current-input.yaml @@ -0,0 +1,376 @@ +# This config expects the following hardware: +# +# - pcf8574 16x2 I2C character LCD connected with SDA on GPIO22 and SCL on GPIO23 +# - wiegand RFID reader connected with d0 on GPIO16, d1 on GPIO4, and card present on GPIO18 +# - oops button connected between GPIO32 and ground, no external resistors (internal pullup) +# - oops button LED connected directly to GPIO5 +# - output relay on GPIO33 +# - neopixel (clockless / 1-wire) output on GPIO27 +# +# And the following secrets in ESPHome's secrets.yaml: +# +# - ota_password - password for OTA updates +# - wifi_ssid +# - wifi_password +# - domain_name +# - mac_url - the full URL to the /api/machine/update endpoint of the machine-access-control server +# +# And the following substitutions: +# +# - machine_name - the machine name as configured in MAC and also the ESPHome device name; note these MUST match +# +substitutions: + machine_name: "esp32test" + +esphome: + name: ${machine_name} + friendly_name: ${machine_name} + +esp32: + board: esp32dev + framework: + type: esp-idf + +# Enable logging +logger: + level: DEBUG + +api: + # don't reboot just because ESPHome isn't connected + reboot_timeout: 0s + encryption: + key: !secret api_encryption_key + +ota: + password: !secret ota_password + platform: esphome + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + domain: !secret domain_name + reboot_timeout: "1min" + on_connect: + then: + - http_request.post: + url: !secret mac_url + request_headers: + Content-Type: application/json + json: |- + root["machine_name"] = App.get_name().c_str(); + root["oops"] = id(oops_button).state; + root["rfid_value"] = id(rfid_tag); + root["uptime"] = id(uptime_sensor).state; + root["wifi_signal_db"] = id(wifi_signal_db).state; + root["wifi_signal_percent"] = id(wifi_signal_percent).state; + root["internal_temperature_c"] = id(internal_temperature_c).state; + capture_response: true + on_response: + then: + - lambda: |- + json::parse_json(body, [](JsonObject root) -> bool { + if ( root["relay"]) { + ESP_LOGI("RELAY", "Turn relay on"); + id(relay_output).turn_on(); + } else { + ESP_LOGI("RELAY", "Turn relay off"); + id(relay_output).turn_off(); + } + std::string dcontent = root["display"]; + id(display_content) = dcontent; + id(my_display).print(dcontent); + if ( root["oops_led"]) { + ESP_LOGI("OOPS", "Turn oops LED on"); + id(oops_led).turn_on(); + } else { + ESP_LOGI("OOPS", "Turn oops LED off"); + id(oops_led).turn_off(); + } + auto call = id(status_led).turn_on(); + float brightness = root["status_led_brightness"]; + call.set_brightness(brightness); + call.set_rgb(root["status_led_rgb"][0], root["status_led_rgb"][1], root["status_led_rgb"][2]); + call.perform(); + return true; + }); + +globals: + - id: display_content + type: std::string + restore_value: False + max_restore_data_length: 34 + initial_value: '"Connecting to\nWiFi"' + - id: rfid_tag + type: std::string + restore_value: False + max_restore_data_length: 34 + initial_value: '""' + +http_request: + +i2c: + sda: GPIO22 + scl: GPIO23 + frequency: 400kHz + +sensor: + - platform: uptime + name: Uptime + id: uptime_sensor + update_interval: 5s + - platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB + name: "WiFi Signal dB" + id: wifi_signal_db + update_interval: 15s + entity_category: "diagnostic" + - platform: copy # Reports the WiFi signal strength in % + source_id: wifi_signal_db + name: "WiFi Signal Percent" + id: wifi_signal_percent + filters: + - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0); + unit_of_measurement: "Signal %" + entity_category: "diagnostic" + device_class: "" + - platform: internal_temperature + name: "esp32_internal_temperature" + id: internal_temperature_c + +binary_sensor: + - platform: gpio + pin: GPIO18 + name: "Card Present" + id: card_present + on_release: + then: + - lambda: ESP_LOGI("TAG", "RFID tag removed"); + - lambda: |- + id(rfid_tag) = ""; + id(display_content) = "Please insert\naccess card"; + id(my_display).print("Please insert\naccess card"); + - http_request.post: + url: !secret mac_url + request_headers: + Content-Type: application/json + json: |- + root["machine_name"] = App.get_name().c_str(); + root["oops"] = id(oops_button).state; + root["rfid_value"] = id(rfid_tag); + root["uptime"] = id(uptime_sensor).state; + root["wifi_signal_db"] = id(wifi_signal_db).state; + root["wifi_signal_percent"] = id(wifi_signal_percent).state; + root["internal_temperature_c"] = id(internal_temperature_c).state; + capture_response: true + on_response: + then: + - lambda: |- + json::parse_json(body, [](JsonObject root) -> bool { + if ( root["relay"]) { + ESP_LOGI("RELAY", "Turn relay on"); + id(relay_output).turn_on(); + } else { + ESP_LOGI("RELAY", "Turn relay off"); + id(relay_output).turn_off(); + } + std::string dcontent = root["display"]; + id(display_content) = dcontent; + id(my_display).print(dcontent); + if ( root["oops_led"]) { + ESP_LOGI("OOPS", "Turn oops LED on"); + id(oops_led).turn_on(); + } else { + ESP_LOGI("OOPS", "Turn oops LED off"); + id(oops_led).turn_off(); + } + auto call = id(status_led).turn_on(); + float brightness = root["status_led_brightness"]; + call.set_brightness(brightness); + call.set_rgb(root["status_led_rgb"][0], root["status_led_rgb"][1], root["status_led_rgb"][2]); + call.perform(); + return true; + }); + + - platform: gpio + pin: + number: GPIO32 + mode: + input: True + pullup: True + name: "oops" + id: oops_button + filters: + - delayed_on: 10ms + on_press: + then: + - lambda: ESP_LOGI("OOPS", "Oops button pressed"); + - lambda: |- + id(display_content) = "OOPS!"; + id(my_display).print("OOPS!"); + - http_request.post: + url: !secret mac_url + request_headers: + Content-Type: application/json + json: |- + root["machine_name"] = App.get_name().c_str(); + root["oops"] = id(oops_button).state; + root["rfid_value"] = id(rfid_tag); + root["uptime"] = id(uptime_sensor).state; + root["wifi_signal_db"] = id(wifi_signal_db).state; + root["wifi_signal_percent"] = id(wifi_signal_percent).state; + root["internal_temperature_c"] = id(internal_temperature_c).state; + capture_response: true + on_response: + then: + - lambda: |- + json::parse_json(body, [](JsonObject root) -> bool { + if ( root["relay"]) { + ESP_LOGI("RELAY", "Turn relay on"); + id(relay_output).turn_on(); + } else { + ESP_LOGI("RELAY", "Turn relay off"); + id(relay_output).turn_off(); + } + std::string dcontent = root["display"]; + id(display_content) = dcontent; + id(my_display).print(dcontent); + if ( root["oops_led"]) { + ESP_LOGI("OOPS", "Turn oops LED on"); + id(oops_led).turn_on(); + } else { + ESP_LOGI("OOPS", "Turn oops LED off"); + id(oops_led).turn_off(); + } + auto call = id(status_led).turn_on(); + float brightness = root["status_led_brightness"]; + call.set_brightness(brightness); + call.set_rgb(root["status_led_rgb"][0], root["status_led_rgb"][1], root["status_led_rgb"][2]); + call.perform(); + return true; + }); + +button: + - platform: restart + name: "Reboot ESP" + +output: + - platform: gpio + pin: GPIO33 + id: relay_output + - platform: gpio + pin: GPIO5 + id: oops_led + +light: + - platform: esp32_rmt_led_strip + rgb_order: RGB + pin: GPIO27 + num_leds: 1 + chipset: ws2812 + name: "StatusLED" + id: status_led + +wiegand: + - id: keypad + d0: GPIO16 + d1: GPIO4 + on_tag: + - lambda: ESP_LOGI("TAG", "received tag %s", x.c_str()); + - lambda: |- + id(rfid_tag) = x.c_str(); + id(display_content) = ((std::string) "TAG RX: " + x).c_str(); + id(my_display).print(((std::string) "TAG RX: " + x).c_str()); + - http_request.post: + url: !secret mac_url + request_headers: + Content-Type: application/json + json: |- + root["machine_name"] = App.get_name().c_str(); + root["oops"] = id(oops_button).state; + root["rfid_value"] = id(rfid_tag); + root["uptime"] = id(uptime_sensor).state; + root["wifi_signal_db"] = id(wifi_signal_db).state; + root["wifi_signal_percent"] = id(wifi_signal_percent).state; + root["internal_temperature_c"] = id(internal_temperature_c).state; + capture_response: true + on_response: + then: + - lambda: |- + json::parse_json(body, [](JsonObject root) -> bool { + if ( root["relay"]) { + ESP_LOGI("RELAY", "Turn relay on"); + id(relay_output).turn_on(); + } else { + ESP_LOGI("RELAY", "Turn relay off"); + id(relay_output).turn_off(); + } + std::string dcontent = root["display"]; + id(display_content) = dcontent; + id(my_display).print(dcontent); + if ( root["oops_led"]) { + ESP_LOGI("OOPS", "Turn oops LED on"); + id(oops_led).turn_on(); + } else { + ESP_LOGI("OOPS", "Turn oops LED off"); + id(oops_led).turn_off(); + } + auto call = id(status_led).turn_on(); + float brightness = root["status_led_brightness"]; + call.set_brightness(brightness); + call.set_rgb(root["status_led_rgb"][0], root["status_led_rgb"][1], root["status_led_rgb"][2]); + call.perform(); + return true; + }); + +display: + - platform: lcd_pcf8574 + dimensions: 16x2 + address: 0x27 + id: my_display + lambda: |- + it.print(id(display_content)); + +interval: + - interval: 10s + startup_delay: 30s + then: + - http_request.post: + url: !secret mac_url + request_headers: + Content-Type: application/json + json: |- + root["machine_name"] = App.get_name().c_str(); + root["oops"] = id(oops_button).state; + root["rfid_value"] = id(rfid_tag); + root["uptime"] = id(uptime_sensor).state; + root["wifi_signal_db"] = id(wifi_signal_db).state; + root["wifi_signal_percent"] = id(wifi_signal_percent).state; + root["internal_temperature_c"] = id(internal_temperature_c).state; + capture_response: true + on_response: + then: + - lambda: |- + json::parse_json(body, [](JsonObject root) -> bool { + if ( root["relay"]) { + ESP_LOGI("RELAY", "Turn relay on"); + id(relay_output).turn_on(); + } else { + ESP_LOGI("RELAY", "Turn relay off"); + id(relay_output).turn_off(); + } + std::string dcontent = root["display"]; + id(display_content) = dcontent; + id(my_display).print(dcontent); + if ( root["oops_led"]) { + ESP_LOGI("OOPS", "Turn oops LED on"); + id(oops_led).turn_on(); + } else { + ESP_LOGI("OOPS", "Turn oops LED off"); + id(oops_led).turn_off(); + } + auto call = id(status_led).turn_on(); + float brightness = root["status_led_brightness"]; + call.set_brightness(brightness); + call.set_rgb(root["status_led_rgb"][0], root["status_led_rgb"][1], root["status_led_rgb"][2]); + call.perform(); + return true; + }); From b938caf947ae35f9b5ee9463007e65c522c328e8 Mon Sep 17 00:00:00 2001 From: Jason Antman Date: Fri, 28 Nov 2025 07:17:44 -0500 Subject: [PATCH 4/4] hardware docs - add info on hardware test config --- docs/source/hardware.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/hardware.rst b/docs/source/hardware.rst index 3b3651b..0216917 100644 --- a/docs/source/hardware.rst +++ b/docs/source/hardware.rst @@ -125,7 +125,7 @@ The following table lists the components required for the Version 1 MCU hardware Wiring ++++++ -This is intended to work with `esphome-configs/2025.11.2/no-current-input.yaml `__. +This is intended to work with `https://github.com/jantman/machine-access-control/blob/main/esphome-configs/2024.6.4/no-current-input.yaml `__. Note that a standalone (non-networked) ESPHome configuration for verifying the operation of all hardware, along with instructions for using it, can be found in `https://github.com/jantman/machine-access-control/tree/main/esphome-configs/2025.11.2 `__. .. image:: ../../hardware/v1_mcu/Hardware_v1.png :alt: Wiring diagram of system