Modbus communication SDM72 energy meter

Yes i use SDM72D-M
It works fine with SDM620, but i cant get it to work with SDM72

I have the same SDM72D-M, strange you also can’t get it to work. I ordered an SDM630 to check if that one works.

it works fine with sdm630

Just got my SDM630, works immediately.
I also see simular behaviour on both the SD630-SDM72 when measuring the differential voltage between A/B.
So it seems like the RS485/modbus of my SDM72 is still working fine, maybe the addresses are different.

Will investigate this further when i have some more time, for now the SDM630 will be used.

heeeyyy mine is working now, with the SDM72 :slight_smile:

1 Like

you need to change custom command to
custom_command: [ 0x2, 0x4, 0x00, 0x48,0x00, 0x02]

I see you have 0x02 as the first command, is your SDM set at address 2?

Hi guys, I have a 630 and 72 I can’t get them to work… Can you please share your configurations and what you adjusted manually?
image
I have this converter. Which converters are you using? I connected the RX from the ESP to TX of the converter. B- to B- of the meter.
Nothing shows up on the UART.
Down below is my minimal example. I set the stop bits to 2 manually in the meter. Messed around with different values, nothing seems to work.

Converter RX LED is blinking every 3 seconds so signal is coming through. Does the converter need the same Ground as the ESP? The ESP is connected independently via a USB power brick and a microUSB cable.


logger:
    # level: DEBUG
    baud_rate: 0
  
  web_server:
    port: 80
  
  
  uart:
    tx_pin: GPIO1
    rx_pin: GPIO3
    baud_rate: 9600
    stop_bits: 2
    debug:
  
  
  sensor:
    - platform: sdm_meter
      frequency:
        name: "Sdm630 Frequency"
      update_interval: 3s

I got the SDM630 working with the same converter board as in your picture.
Powered it with 5Vdc.
Txd and Rxd to GPIO 1 and GPIO3 of the D1 mini. (hardware uart)
A of the converter to A of the SDM.
B of the converter to B of the SDM.
I used a 120Ohm resistor between A and B on the SDM side, not sure if this is needed.
I didn’t connect the ground on the converter or SDM.

I use the default settings of the sdm630(address = 1, parity = none, baudrate = 9600, stopbits = 1)

Below is SDM part of my code:

esphome:
  name: "warmtepomp-sdm"

esp8266:
  board: d1_mini

# Enable logging
logger:
  level: verbose
  baud_rate: 0  # <--- must be disabled because gpio1/3 are used for modbus
  
#serial port
uart:
  id: mod_uart
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 9600
  stop_bits: 1

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

#modbuscontroller to read SDM630
modbus_controller:
  - id: sdm
    address: 0x0001
    modbus_id: mod_bus
    update_interval: 15s

sensor:
  - platform: modbus_controller
    modbus_controller_id: sdm
    name: "Warmtepomp Total active energy"
    id: total_energy
    #    address: 0x156 --> zie sdm630 manual 
    #    register_type: "read"
    ## reimplement using custom_command
    # 0x1 : modbus device address
    # 0x4 : modbus function code
    # 0x1 : high byte of modbus register address
    # 0x56: low byte of modbus register address
    # 0x00: high byte of total number of registers requested
    # 0x02: low byte of total number of registers requested
    custom_command: [ 0x1, 0x4, 0x1, 0x56,0x00, 0x02]
    value_type: FP32
    unit_of_measurement: kWh
    accuracy_decimals: 1

  - platform: modbus_controller
    modbus_controller_id: sdm
    name: "Warmtepomp Total system power demand"
    id: total_system_power
    #    address: 0x034 zie SDM630 manual
    #    register_type: "read"
    ## reimplement using custom_command
    # 0x1 : modbus device address
    # 0x4 : modbus function code
    # 0x1 : high byte of modbus register address
    # 0x54: low byte of modbus register address
    # 0x00: high byte of total number of registers requested
    # 0x02: low byte of total number of registers requested
    custom_command: [ 0x1, 0x4, 0x0, 0x34,0x00, 0x02]
    value_type: FP32
    unit_of_measurement: W
    accuracy_decimals: 1

Both leds of the converter board should be blinking when communication is running.

Hope this helps.

1 Like

Thank you @drled!
I will try your setup and report back.
I thought Eastron SDM meters are officially supported: Eastron SDM Energy Monitor — ESPHome
It’s really wierd because these meters are insanely popular.

UPDATE: I replicated exactly your setup, doesn’t work for me, the SDM is not answering.

What does the logger outputs? If the SDM is not responding, you should atleast see the modbus command in the logger output.
Also the tx led on your rs485 converter should blink if the command is sent…

Also check this, i reverted my esphome to version 11.5:

yes the first command is address on the sdm

@dried: how did you revert to ESPHome 11.5 ? Been having CRC errors as well on Modbus since the last update (in my case reading my Growat inverter locally via RS485, kind of the same setup you are running)

I went to the “backups” section in home assistant, there i found backups that were taken right before the upgrade of esphome. If you click on one of those it should be possible to restore one of the older versions.

@dried: I remembered I programmed/updated my ESP32’s for the first time from the CLI of my Macbook. So, I checked the version, it was 11.2 (so older than 12.0), reprogrammed/flashed my ESP32 from the CLI and now … everything works again !
So, something in ESPHome 12.0 is messing up the way the GPIO pins read/write the data.
I’m leaving my ESP32 alone for now, it works with 11.2

So I have this minimal config:

logger:
    level: verbose
    
uart:
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 9600

sensor:
  - platform: sdm_meter
    frequency:
      name: "Sdm630 Frequency"
    total_power:
      name: "SDM630M Total Power"
    update_interval: 5s

And here is the log.

Everything is cabled up correctly, nothing is happening except the RX LED of the modbus-rs232 converter is blinking.

I would appreciate every bit of help.

I have managed to get the SDM72D-M Energy Meter working with esphome.

I have pasted my code as a snippet here: Gitlab Snippet

Here the short version as an example:

uart:
  id: mod_uart
  tx_pin: D2
  rx_pin: D1
  baud_rate: 9600
  stop_bits: 1
      
modbus:
  send_wait_time: 500ms
  uart_id: mod_uart
  id: mod_bus

modbus_controller:
  - id: SDM72DM
    modbus_id: mod_bus
    address: 1
    setup_priority: -10

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

1 Like

Thank you for posting your snippet. I’m going to try it out. Would you mind attaching an image of exactly how you wired everything up?

1 Like

Try TX to TX and RX to RX on the ESP/RS485-module connection

And TRY USING SOFTWARE UART! As JFK344 did, that finally fixed it for me:

uart:
  id: mod_uart
  tx_pin: D2 #this line
  rx_pin: D1 #and this one, use these pins (others could work, but these are fine)
  baud_rate: 9600
  stop_bits: 1

How often is ESPhome actually sending the Modbus energy values over the API or MQTT to HA? Can this be configured?