Skip to content

Instantly share code, notes, and snippets.

@unwiredtech
Last active October 10, 2024 20:22
Show Gist options
  • Save unwiredtech/fa0a8b893c49bcca52ebd642ba2cca38 to your computer and use it in GitHub Desktop.
Save unwiredtech/fa0a8b893c49bcca52ebd642ba2cca38 to your computer and use it in GitHub Desktop.
Home Assistant and Eastron Energy Meter Communication
esphome:
name: sdm230_modbus_reader
platform: ESP8266
board: nodemcuv2 # For NodeMCU v3
# Wi-Fi connection setup
wifi:
ssid: !secret wifi_ssid_iot
password: !secret wifi_password_iot
# Enable fallback hotspot in case Wi-Fi connection fails
ap:
ssid: "SDM230 Fallback Hotspot"
password: "AP_PASSWORD"
# Optional: static IP configuration
manual_ip:
static_ip: 192.168.0.118
gateway: 192.168.0.1
subnet: 255.255.255.0
# Enable OTA for wireless firmware updates
ota:
password: !secret ota_sdm230_password
# Enable logging
logger:
baud_rate: 0 # Disable logging over UART (useful for RS485)
switch:
- platform: gpio
pin: D2 # Connect both DE and RE to this pin
id: rs485_control
name: "RS485 DE/RE Control"
# UART configuration for RS485
uart:
tx_pin: D4 # GPIO2 on ESP8266 (TX) -- DI
rx_pin: D3 # GPIO0 on ESP8266 (RX) -- RO
baud_rate: 9600
parity: NONE
stop_bits: 1
# Modbus Controller Setup
modbus:
id: modbus1
uart_id: uart
flow_control_pin: rs485_control # Use the combined control pin
# Eastron SDM230M Sensor Readings
sensor:
- platform: modbus_controller
modbus_id: modbus1
id: voltage
name: "SDM230 Voltage"
address: 0x0000
unit_of_measurement: "V"
slave_id: 1 # SDM230 Modbus address
value_type: FLOAT # 32-bit floating point
accuracy_decimals: 1
- platform: modbus_controller
modbus_id: modbus1
id: current
name: "SDM230 Current"
address: 0x0006
unit_of_measurement: "A"
slave_id: 1 # SDM230 Modbus address
value_type: FLOAT # 32-bit floating point
accuracy_decimals: 2
- platform: modbus_controller
modbus_id: modbus1
id: power
name: "SDM230 Power"
address: 0x000C
unit_of_measurement: "W"
slave_id: 1 # SDM230 Modbus address
value_type: FLOAT # 32-bit floating point
accuracy_decimals: 2
- platform: modbus_controller
modbus_id: modbus1
id: energy
name: "SDM230 Total Energy"
address: 0x0048
unit_of_measurement: "kWh"
slave_id: 1 # SDM230 Modbus address
value_type: FLOAT # 32-bit floating point
accuracy_decimals: 2
# Imported Energy (Forward Active Energy)
- platform: modbus_controller
modbus_id: modbus1
id: imported_energy
name: "SDM230 Imported Energy"
address: 0x0048
unit_of_measurement: "kWh"
slave_id: 1 # SDM230 Modbus address
value_type: FLOAT # 32-bit floating point
accuracy_decimals: 2
# Exported Energy (Reverse Active Energy)
- platform: modbus_controller
modbus_id: modbus1
id: exported_energy
name: "SDM230 Exported Energy"
address: 0x004A
unit_of_measurement: "kWh"
slave_id: 1 # SDM230 Modbus address
value_type: FLOAT # 32-bit floating point
accuracy_decimals: 2
# Enable web server to access logs/config via a browser
web_server:
port: 80
auth:
username: !secret web_username
password: !secret web_password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment