228 lines
6.8 KiB
YAML
228 lines
6.8 KiB
YAML
# Energy Monitor — M5Stack Core 1 (ESP32, no PSRAM)
|
|
|
|
substitutions:
|
|
name: energymonitor
|
|
friendly_name: "Energy Monitor"
|
|
device_description: >-
|
|
ESP32-based power/energy monitor on an M5Stack Core 1 enclosure.
|
|
wifi_bssid: "" # leave blank to roam freely (MAC = "" → auto-scan)
|
|
min_chip_rev: "3.0"
|
|
|
|
esphome:
|
|
name: ${name}
|
|
friendly_name: ${friendly_name}
|
|
comment: ${device_description}
|
|
name_add_mac_suffix: false
|
|
min_version: 2024.6.0
|
|
includes: [] # add custom .h files here as needed
|
|
libraries: [] # add custom .cpp / .h / .c archives here as "name_of_lib"
|
|
project:
|
|
name: "custom.energymonitor"
|
|
version: "1.0"
|
|
|
|
esp32:
|
|
board: m5stack-core-esp32
|
|
framework:
|
|
type: esp-idf
|
|
advanced:
|
|
minimum_chip_revision: ${min_chip_rev}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# WiFi (same dual-network pattern as serverroom / livingroom configs)
|
|
# ---------------------------------------------------------------------------
|
|
network:
|
|
enable_ipv6: true
|
|
|
|
wifi:
|
|
# Primary network — change the SSID when you deploy to something specific.
|
|
ssid: "Voltage-legacy"
|
|
password: !secret voltage_legacy_psk
|
|
|
|
bssid: ${wifi_bssid}
|
|
|
|
power_save_mode: none # energy monitors usually stay awake
|
|
fast_connect: on
|
|
min_auth_mode: WPA2
|
|
|
|
# Fallback hotspot for initial setup / recovery
|
|
ap:
|
|
ssid: "Energy Monitor Fallback Hotspot"
|
|
password: !secret fallback_psk
|
|
|
|
captive_portal:
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Logging (INFO saves RAM — bump to DEBUG when troubleshooting)
|
|
# ---------------------------------------------------------------------------
|
|
logger:
|
|
level: INFO
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# API & OTA
|
|
# ---------------------------------------------------------------------------
|
|
api:
|
|
encryption:
|
|
key: !secret apikey
|
|
|
|
ota:
|
|
platform: esphome
|
|
password: !secret ota
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# I²C bus (default M5Stack Core 1 pins — SDA=GPIO21, SCL=GPIO22)
|
|
# Uncomment / change if you use a different board or wired an external bus.
|
|
# ---------------------------------------------------------------------------
|
|
i2c:
|
|
- id: bus_a
|
|
sda: 21
|
|
scl: 22
|
|
scan: true
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Display (M5Stack Core 1 built-in LCD — ili9xxx / M5STACK)
|
|
# Uncomment when the screen is ready to use.
|
|
# ---------------------------------------------------------------------------
|
|
# display:
|
|
# - platform: ili9xxx
|
|
# id: lcd_display
|
|
# model: M5STACK
|
|
# cs_pin: 5 # M5Stack Core 1 default
|
|
# dc_pin: 27 # M5Stack Core 1 default
|
|
# reset_pin: 33 # M5Stack Core 1 default
|
|
# invert_colors: true
|
|
# color_palette: 8BIT
|
|
# rotation: 0
|
|
|
|
#背光 / backlight — use GPIO32 on a stock M5Stack Core 1
|
|
# ---------------------------------------------------------------------------
|
|
# output:
|
|
# - platform: ledc
|
|
# pin: 32
|
|
# id: lcd_backlight
|
|
|
|
# light:
|
|
# - platform: monochromatic
|
|
# output: lcd_backlight
|
|
# name: "Backlight"
|
|
# id: backlight
|
|
# restore_mode: ALWAYS_ON
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Sensors — add the appropriate platform for your sensing hardware.
|
|
#
|
|
# Popular choices for energy monitoring:
|
|
# • SCT-013 or ACS712 → platform: adc (analog current/voltage sensor)
|
|
# • HLW8012 / BL0937 → platform: hlw8012 (AC power metering IC)
|
|
# • EMONLib-compatible → custom C++ component via 'includes:'
|
|
# ---------------------------------------------------------------------------
|
|
sensor:
|
|
# WiFi signal strength — useful for field diagnostics
|
|
- platform: wifi_signal
|
|
name: "WiFi Signalstärke"
|
|
update_interval: 60s
|
|
|
|
# ── Placeholder: HLW8012 (common AC power/energy module) ──────────
|
|
# Uncomment and wire if you use an HLW8012 / BL0937 module on SPI or UART.
|
|
# - platform: hlw8012
|
|
# sel_pin:
|
|
# number: GPIOXX
|
|
# inverted: true
|
|
# sel_runtime: 60s # pulse mode — how long to toggle SEL pin
|
|
# cf_pin: GPIOXX
|
|
# cf1_pin: GPIOXX
|
|
# update_interval: 2s
|
|
# voltage:
|
|
# name: "Spannung"
|
|
# id: voltage
|
|
# current:
|
|
# name: "Strom"
|
|
# id: current
|
|
# unit_of_measurement: A
|
|
# power:
|
|
# name: "Leistung"
|
|
# id: power
|
|
# unit_of_measurement: W
|
|
# energy:
|
|
# name: "Energie"
|
|
# id: energy_today
|
|
# unit_of_measurement: Wh
|
|
|
|
# ── Placeholder: M5Stack built-in ADC (GPIO36 / VP) ──────────────
|
|
# Uncomment and wire an external sensor to the analog input if needed.
|
|
# - platform: adc
|
|
# pin: GPIO36
|
|
# name: "Analog Eingang"
|
|
# id: analog_in
|
|
# attenuation: 12db # full range for the ESP32 ADC
|
|
# update_interval: 1s
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Text sensors — diagnostic / status helpers
|
|
# ---------------------------------------------------------------------------
|
|
text_sensor:
|
|
# Internal ESPHome version (helps with OTA version management)
|
|
- platform: template
|
|
name: "Firmware Version"
|
|
id: firmware_version
|
|
entity_category: diagnostic
|
|
disabled_by_default: false
|
|
|
|
on_boot:
|
|
then:
|
|
- text_sensor.template.publish:
|
|
id: firmware_version
|
|
state: !lambda 'return ESPHOME_VERSION;'
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Buttons (M5Stack Core 1 physical buttons — all active-LOW)
|
|
# ---------------------------------------------------------------------------
|
|
button:
|
|
# Reset WiFi credentials if needed
|
|
- platform: restart
|
|
name: "Restart"
|
|
id: device_restart
|
|
entity_category: config
|
|
|
|
- platform: safe_mode
|
|
name: "Safe Mode Reboot"
|
|
id: safe_mode_reboot
|
|
entity_category: config
|
|
|
|
# binary_sensor:
|
|
# Button A (left, GPIO39, active-LOW)
|
|
# - platform: gpio
|
|
# id: button_a
|
|
# pin:
|
|
# number: GPIO39
|
|
# inverted: true
|
|
# mode: INPUT_PULLUP
|
|
# name: "Button A"
|
|
# entity_category: diagnostic
|
|
|
|
# Button C (right, GPIO37, active-LOW)
|
|
# - platform: gpio
|
|
# id: button_c
|
|
# pin:
|
|
# number: GPIO37
|
|
# inverted: true
|
|
# mode: INPUT_PULLUP
|
|
# name: "Button C"
|
|
# entity_category: diagnostic
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# LEDs (M5Stack Core 1 built-in status LED on the back — GPIO2)
|
|
# ---------------------------------------------------------------------------
|
|
# light:
|
|
# - platform: binary
|
|
# id: internal_led
|
|
# name: "Status LED"
|
|
# entity_category: config
|
|
# output: gpiopin2
|
|
# restore_mode: ALWAYS_OFF
|
|
|
|
# output:
|
|
# - platform: gpio
|
|
# pin: 2
|
|
# inverted: true # stock LED is active-LOW
|
|
# id: gpiopin2
|