Eastron SDM230 Modbus

Hi all,

I’m trying to get my SDM230 Modbus to work with ESPhome and have followed the guide here

But I am struggling to get it to work.

here is my config:

esphome:
  name: solar-power
  friendly_name: Solar Power
  platform: ESP8266
  board: nodemcuv2


# Enable logging
logger:
  baud_rate: 0

# Enable Home Assistant API
api:
  encryption:
    key: "********************************************"

ota:
  password: "********************************"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Solar-Power Fallback Hotspot"
    password: "************"

captive_portal:

uart:
  rx_pin: D1
  tx_pin: D2
  baud_rate: 9600
  stop_bits: 1

sensor:
  - platform: sdm_meter
    phase_a:
      current:
        name: "SDM230M Current"
      voltage:
        name: "SDM230M Voltage"
      active_power:
        name: "SDM230M Power"
      power_factor:
        name: "SDM230M Power Factor"
      apparent_power:
        name: "SDM230M Apparent Power"
      reactive_power:
        name: "SDM230M Reactive Power"
      phase_angle:
        name: "SDM230M Phase Angle"
    frequency:
      name: "SDM230M Frequency"
    total_power:
      name: "SDM230M Total Power"
    import_active_energy:
      name: "SDM230M Import Active Energy"
    export_active_energy:
      name: "SDM230M Export Active Energy"
    import_reactive_energy:
      name: "SDM230M Import Reactive Energy"
    export_reactive_energy:
      name: "SDM230M Export Reactive Energy"
    update_interval: 60s

I have D1 to A+ and D2 to B-
the Baud rate is 9600 on both the esp device and the SDM230

1 Like

I got it working today.

For anyone else finding this here is what I did:

I first ordered a TTL to RS485-485 to Serial UART Adapter.

I then switched to an ESP32 board (not that this matters)

When trying on the tx rx (GPIO1 and GPIO3) pins i just kept getting errors, finally I switched to pins 16 & 17 and for some reason it works

esphome:
  name: solar-power
  friendly_name: Solar Power

esp32:
  board: nodemcu-32s
  framework:
    type: arduino
    version: 2.0.6

# Enable logging
logger:
  baud_rate: 0


# Enable Home Assistant API
api:
  encryption:
    key: "*************************************"

ota:
  password: "*****************************"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Solar-Power Fallback Hotspot"
    password: "**********"

captive_portal:

switch:
  - platform: restart
    name: ${friendly_name} Restart
    
web_server:
  port: 80

time:
  - platform: homeassistant
    id: homeassistant_time

#serial port
uart:
  id: mod_uart
  tx_pin: GPIO17
  rx_pin: GPIO16
  baud_rate: 9600
  stop_bits: 1

      
modbus:
  send_wait_time: 500ms
  uart_id: mod_uart
  id: mod_bus

modbus_controller:
  - id: SDM230M
    modbus_id: mod_bus
    address: 1
    setup_priority: -10
    update_interval: 5s

sensor:
  # General
#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} AvgFreq
#    register_type: read
#    address: 0x0046
#    value_type: FP32
#    unit_of_measurement: Hz
#    state_class: "measurement"
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total System Power
#    register_type: read
#    address: 0x0034
#    value_type: FP32
#    unit_of_measurement: W
#    state_class: "measurement"
#    device_class: "power"
#    accuracy_decimals: 3

  - platform: modbus_controller
    modbus_controller_id: SDM230M
    name: ${friendly_name} Total Active Energy
    register_type: read
    address: 0x0156
    value_type: FP32
    unit_of_measurement: kWh
    state_class: "total_increasing"
    device_class: "energy"
    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Average Line to Neutral Voltage
#    register_type: read
#    address: 0x002A
#    value_type: FP32
#    unit_of_measurement: V
#    state_class: "measurement"
#    device_class: "voltage"
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Average Line Current
#    register_type: read
#    address: 0x002E
#    value_type: FP32
#    device_class: "current"
#    state_class: "measurement"
#    unit_of_measurement: A
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Sum Line Current
#    register_type: read
#    address: 0x0030
#    value_type: FP32
#    device_class: "current"
#    state_class: "measurement"
#    unit_of_measurement: A
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total System Power
#    register_type: read
#    address: 0x0034
#    value_type: FP32
#    unit_of_measurement: W
#    device_class: "power"
#    state_class: "measurement"
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total System VA
#    register_type: read
#    address: 0x0038
#    value_type: FP32
#    device_class: ""
#    state_class: "measurement"
#    unit_of_measurement: VA
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total System VAr
#    register_type: read
#    address: 0x003C
#    value_type: FP32
#    device_class: ""
#    state_class: "measurement"
#    unit_of_measurement: VAr
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total System Power Factor
#    register_type: read
#    address: 0x003E
#    value_type: FP32
#    device_class: "power_factor"
#    state_class: "measurement"
#    unit_of_measurement: ""
#    accuracy_decimals: 3

  - platform: modbus_controller
    modbus_controller_id: SDM230M
    name: ${friendly_name} Import Active Energy
    register_type: read
    address: 0x0048
    value_type: FP32
    unit_of_measurement: kWh
    state_class: "total_increasing"
    device_class: "energy"
    accuracy_decimals: 3

  - platform: modbus_controller
    modbus_controller_id: SDM230M
    name: ${friendly_name} Export Active Energy
    register_type: read
    address: 0x004A
    value_type: FP32
    unit_of_measurement: kWh
    state_class: "total_increasing"
    device_class: "energy"
    accuracy_decimals: 3
    


#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Neutral Current
#    register_type: read
#    address: 0x00E0
#    value_type: FP32
#    device_class: "current"
#    state_class: "measurement"
#    unit_of_measurement: A
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total Reactive Energy
#    register_type: read
#    address: 0x0158
#    value_type: FP32
#    unit_of_measurement: kVArh
#    state_class: "total_increasing"
#    device_class: "energy"
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Net kwh (Import - Export)
#    register_type: read
#    address: 0x018C
#    value_type: FP32
#    unit_of_measurement: kWh
#    state_class: "total_increasing"
#    device_class: "energy"

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total Import Active Power
#    register_type: read
#    address: 0x0500
#    value_type: FP32
#    unit_of_measurement: W
#    device_class: "power"
#    state_class: "measurement"
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total Export Active Power
#    register_type: read
#    address: 0x0502
#    value_type: FP32
#    unit_of_measurement: W
#    device_class: "power"
#    state_class: "measurement"
#    accuracy_decimals: 3

  # Power
  - platform: modbus_controller
    modbus_controller_id: SDM230M
    name: ${friendly_name} Phase 1 Power
    register_type: read
    address: 0x000C
    value_type: FP32
    unit_of_measurement: W
    device_class: "power"
    state_class: "measurement"
    accuracy_decimals: 3
    

  # Volts
  - platform: modbus_controller
    modbus_controller_id: SDM230M
    name: ${friendly_name} Phase 1 Voltage
    register_type: read
    address: 0x0000
    value_type: FP32
    unit_of_measurement: V
    device_class: "voltage"
    state_class: "measurement"
    accuracy_decimals: 3
    
    
  # Current
  - platform: modbus_controller
    modbus_controller_id: SDM230M
    name: ${friendly_name} Phase 1 Current
    register_type: read
    address: 0x0006
    value_type: FP32
    device_class: "current"
    state_class: "measurement"
    unit_of_measurement: A
    accuracy_decimals: 3

    
  # Apparent Power
  - platform: modbus_controller
    modbus_controller_id: SDM230M
    name: ${friendly_name} Phase 1 Apparent Power
    register_type: read
    address: 0x0012
    value_type: FP32
    device_class: ""
    state_class: "measurement"
    unit_of_measurement: VA
    accuracy_decimals: 3

    
  # Reactive Power
#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Phase 1 Reactive Power
#    register_type: read
#    address: 0x0018
#    value_type: FP32
#    device_class: ""
#    state_class: "measurement"
#    unit_of_measurement: VAr
#    accuracy_decimals: 3

    
  # Power Factor
 # - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Phase 1 Power Factor
#    register_type: read
#    address: 0x001E
#    value_type: FP32
#    device_class: "power_factor"
#    state_class: "measurement"
#    unit_of_measurement: ""
#    accuracy_decimals: 3

Hope this helps someone in the future

Hi @clarky860 what hardware are you using to do this?

I have an SMD230 in my consumer unit that feeds my solar inverter, but I would like to get all the readings from it directly in to HA as well.

Thanks

Hi Sorry for the late reply, I never got a notification that you had replied to me.

Im using an ESP32-WROOM-32 board

And TTL to RS485

1 Like

thank you for your code. i am looking for a long time to monitor my sdm230 in the HA dashboard

i will test them in a view weeks

i try your seting and don:t work .please help me with seting

Here it is again with the full code I have now after several updates to ESPHOME

  name: solar-power
  friendly_name: Solar Power

esp32:
  board: nodemcu-32s
  framework:
    type: arduino
    version: 2.0.6

# Enable logging
logger:
  baud_rate: 0


# Enable Home Assistant API
api:
  encryption:
    key: "YOUR KEY HERE IF YOU USE ONE"

ota:
  platform: esphome
  password: "YOUR PASSWORD HERE IF YOU USE ONE"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Solar-Power Fallback Hotspot"
    password: "PASSWORD"

captive_portal:

switch:
  - platform: restart
    name: ${friendly_name} Restart
    
web_server:
  port: 80

time:
  - platform: homeassistant
    id: homeassistant_time

#serial port
uart:
  id: mod_uart
  tx_pin: GPIO17
  rx_pin: GPIO16
  baud_rate: 9600
  stop_bits: 1

      
modbus:
  send_wait_time: 500ms
  uart_id: mod_uart
  id: mod_bus

modbus_controller:
  - id: SDM230M
    modbus_id: mod_bus
    address: 1
    setup_priority: -10
    update_interval: 2s

sensor:
  # General
#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} AvgFreq
#    register_type: read
#    address: 0x0046
#    value_type: FP32
#    unit_of_measurement: Hz
#    state_class: "measurement"
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total System Power
#    register_type: read
#    address: 0x0034
#    value_type: FP32
#    unit_of_measurement: W
#    state_class: "measurement"
#    device_class: "power"
#    accuracy_decimals: 3

  - platform: modbus_controller
    modbus_controller_id: SDM230M
    name: ${friendly_name} Total Active Energy
    register_type: read
    address: 0x0156
    value_type: FP32
    unit_of_measurement: kWh
    state_class: "total_increasing"
    device_class: "energy"
    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Average Line to Neutral Voltage
#    register_type: read
#    address: 0x002A
#    value_type: FP32
#    unit_of_measurement: V
#    state_class: "measurement"
#    device_class: "voltage"
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Average Line Current
#    register_type: read
#    address: 0x002E
#    value_type: FP32
#    device_class: "current"
#    state_class: "measurement"
#    unit_of_measurement: A
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Sum Line Current
#    register_type: read
#    address: 0x0030
#    value_type: FP32
#    device_class: "current"
#    state_class: "measurement"
#    unit_of_measurement: A
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total System Power
#    register_type: read
#    address: 0x0034
#    value_type: FP32
#    unit_of_measurement: W
#    device_class: "power"
#    state_class: "measurement"
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total System VA
#    register_type: read
#    address: 0x0038
#    value_type: FP32
#    device_class: ""
#    state_class: "measurement"
#    unit_of_measurement: VA
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total System VAr
#    register_type: read
#    address: 0x003C
#    value_type: FP32
#    device_class: ""
#    state_class: "measurement"
#    unit_of_measurement: VAr
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total System Power Factor
#    register_type: read
#    address: 0x003E
#    value_type: FP32
#    device_class: "power_factor"
#    state_class: "measurement"
#    unit_of_measurement: ""
#    accuracy_decimals: 3

  - platform: modbus_controller
    modbus_controller_id: SDM230M
    name: ${friendly_name} Import Active Energy
    register_type: read
    address: 0x0048
    value_type: FP32
    unit_of_measurement: kWh
    state_class: "total_increasing"
    device_class: "energy"
    accuracy_decimals: 3

  - platform: modbus_controller
    modbus_controller_id: SDM230M
    name: ${friendly_name} Export Active Energy
    register_type: read
    address: 0x004A
    value_type: FP32
    unit_of_measurement: kWh
    state_class: "total_increasing"
    device_class: "energy"
    accuracy_decimals: 3
    


#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Neutral Current
#    register_type: read
#    address: 0x00E0
#    value_type: FP32
#    device_class: "current"
#    state_class: "measurement"
#    unit_of_measurement: A
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total Reactive Energy
#    register_type: read
#    address: 0x0158
#    value_type: FP32
#    unit_of_measurement: kVArh
#    state_class: "total_increasing"
#    device_class: "energy"
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Net kwh (Import - Export)
#    register_type: read
#    address: 0x018C
#    value_type: FP32
#    unit_of_measurement: kWh
#    state_class: "total_increasing"
#    device_class: "energy"

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total Import Active Power
#    register_type: read
#    address: 0x0500
#    value_type: FP32
#    unit_of_measurement: W
#    device_class: "power"
#    state_class: "measurement"
#    accuracy_decimals: 3

#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Total Export Active Power
#    register_type: read
#    address: 0x0502
#    value_type: FP32
#    unit_of_measurement: W
#    device_class: "power"
#    state_class: "measurement"
#    accuracy_decimals: 3

  # Power
  - platform: modbus_controller
    modbus_controller_id: SDM230M
    name: ${friendly_name} Phase 1 Power
    register_type: read
    address: 0x000C
    value_type: FP32
    unit_of_measurement: W
    device_class: "power"
    state_class: "measurement"
    accuracy_decimals: 3
    

  # Volts
  - platform: modbus_controller
    modbus_controller_id: SDM230M
    name: ${friendly_name} Phase 1 Voltage
    register_type: read
    address: 0x0000
    value_type: FP32
    unit_of_measurement: V
    device_class: "voltage"
    state_class: "measurement"
    accuracy_decimals: 3
    
    
  # Current
  - platform: modbus_controller
    modbus_controller_id: SDM230M
    name: ${friendly_name} Phase 1 Current
    register_type: read
    address: 0x0006
    value_type: FP32
    device_class: "current"
    state_class: "measurement"
    unit_of_measurement: A
    accuracy_decimals: 3

    
  # Apparent Power
  - platform: modbus_controller
    modbus_controller_id: SDM230M
    name: ${friendly_name} Phase 1 Apparent Power
    register_type: read
    address: 0x0012
    value_type: FP32
    device_class: ""
    state_class: "measurement"
    unit_of_measurement: VA
    accuracy_decimals: 3

    
  # Reactive Power
#  - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Phase 1 Reactive Power
#    register_type: read
#    address: 0x0018
#    value_type: FP32
#    device_class: ""
#    state_class: "measurement"
#    unit_of_measurement: VAr
#    accuracy_decimals: 3

    
  # Power Factor
 # - platform: modbus_controller
#    modbus_controller_id: SDM230M
#    name: ${friendly_name} Phase 1 Power Factor
#    register_type: read
#    address: 0x001E
#    value_type: FP32
#    device_class: "power_factor"
#    state_class: "measurement"
#    unit_of_measurement: ""
#    accuracy_decimals: 3

Hope it helps

thx for configuration
unfortunatly don"t work

thx i fix the problem