commit a8e1515d3a34d7e7491bd822511dc6dabc3d93ad Author: Amir Date: Tue Aug 18 00:06:06 2026 +0200 Upload files to "/" diff --git a/README.md b/README.md new file mode 100644 index 0000000..569d904 --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +# Home Assistant Green Smart UPS Monitor + +## Overview +This project provides a DIY Uninterruptible Power Supply (UPS) with smart monitoring for a Home Assistant Green (HAG) hub. It leverages an ESP32-H2 microcontroller utilizing the Thread protocol to relay mains power status and battery levels back to Home Assistant. + +By using the "Hardware Cutoff" configuration, the system avoids the need for relays. It strictly relies on the HW-465C UPS module's internal low-voltage cutoff to power down the HAG, allowing the HAG to automatically reboot when grid power restores the 12V rail. + +## Core Components +* **Home Assistant Green:** The main smart home hub (Load). +* **ESP32-H2 Super Mini:** Acts as the Thread end-device sensor node. +* **SLZB-MR5U:** Serves as the OpenThread Border Router (OTBR) connecting the Thread network to Home Assistant. +* **HW-465C UPS Module:** 12V Step-up boost converter and battery charger. +* **2x 18650 Battery Cells:** Wired in parallel (1S2P). +* **MAX17043 I2C Fuel Gauge:** Monitors 1S battery state of charge (SoC). +* **EL817 Optocoupler:** Detects mains 5V presence safely. +* **Mini360 Buck Converter:** Steps down the 12V output to 5.0V for the ESP32. + +## Implementation & Wiring +The ESP32-H2 is powered via the Mini360 buck converter from the 12V output. This guarantees that when the HW-465C battery protection trips (~2.5V), the ESP32 cleanly loses power alongside the HA Green, preventing deep-discharge battery damage. + +### Power Path Connections +1. **5V Wall Charger** -> Connects to `IN+` / `IN-` on HW-465C. +2. **18650 Parallel Pack** -> Connects to `B+` / `B-` on HW-465C. +3. **HW-465C 12V Output** -> Splits to HA Green Barrel Jack **and** Mini360 `IN+` / `IN-`. +4. **Mini360 5.0V Output** -> Connects to ESP32-H2 `5V` and `GND` pins. + +### ESP32-H2 Super Mini Pinout Map +| Component | ESP32-H2 Pin | Description | +| :--- | :--- | :--- | +| **Mini360 (5V Power)** | `5V` & `GND` | Main power input for ESP32. | +| **MAX17043 (Fuel Gauge)** | `3V3` & `GND` | Power out to MAX17043 module. | +| **MAX17043 (I2C SDA)** | `GPIO 10` | I2C Data Line. | +| **MAX17043 (I2C SCL)** | `GPIO 11` | I2C Clock Line. | +| **EL817 (Outage Sensor)** | `GPIO 4` | Pull-up input for mains detection. Emitter connects to `GND`. | + +### Sensor Detection Logic (EL817) +* **Input Side:** 5V Mains (Before UPS) -> 330Ω Resistor -> EL817 Anode (Pin 1). Cathode (Pin 2) -> Mains GND. +* **Output Side:** EL817 Collector (Pin 4) -> ESP32 GPIO 4. EL817 Emitter (Pin 3) -> ESP32 GND. +* **Logic:** When 5V mains is active, the optocoupler pulls GPIO 4 to GND (LOW). ESPHome inverts this so `LOW` = `ON` (Mains present). + +## Network & Controls +* **Thread Protocol:** The ESP32 is configured in ESPHome using the `openthread` component. +* **End-Device Mode:** The `device_type` is set to `MTD` (Minimal Thread Device). This explicitly disables the router/repeater functionality, ensuring the module operates efficiently as an end-device node routing through the SLZB-MR5U. +* **Auto-Boot Operation:** Because there is no active software shutdown command sent to Home Assistant, the HA Green stays active until the battery triggers the physical HW-465C shutoff. Once mains voltage returns, the 12V rail steps up from 0V to 12V, initiating an automatic cold boot of the Home Assistant Green. \ No newline at end of file diff --git a/UPS enclosure lid.3mf b/UPS enclosure lid.3mf new file mode 100644 index 0000000..91fe338 Binary files /dev/null and b/UPS enclosure lid.3mf differ diff --git a/UPS enclosure.3mf b/UPS enclosure.3mf new file mode 100644 index 0000000..1602ea4 Binary files /dev/null and b/UPS enclosure.3mf differ diff --git a/hag_smart_ups_for_esphome.yaml b/hag_smart_ups_for_esphome.yaml new file mode 100644 index 0000000..a43dc85 --- /dev/null +++ b/hag_smart_ups_for_esphome.yaml @@ -0,0 +1 @@ +esphome: name: hag-ups-monitor esp32: board: esp32-h2-devkitm-1 variant: esp32h2 framework: type: esp-idf network: enable_ipv6: true # Thread configuration utilizing the SLZB-MR5U as the Border Router openthread: # MTD (Minimal Thread Device) disables the router/repeater role # to optimize the device for a battery-powered topology. device_type: MTD i2c: sda: GPIO10 scl: GPIO11 scan: true sensor: - platform: max17043 address: 0x36 battery_level: name: "UPS Battery Level" id: ups_battery_level icon: "mdi:battery" voltage: name: "UPS Battery Voltage" id: ups_battery_voltage icon: "mdi:battery-high" update_interval: 30s binary_sensor: - platform: gpio pin: number: GPIO4 mode: input: true pullup: true inverted: true name: "Mains Power Status" id: mains_power_status device_class: plug icon: "mdi:power-plug" \ No newline at end of file