Reading values EASTRON SDM220-modbus power meter

Hello, I’m trying to read the values of this power meter, but they always show the value of 0.

In the configuration.yaml file I’ve the following:

modbus:
  type: serial
  method: rtu
  port: /dev/ttyUSB0
  baudrate: 9600
  stopbits: 1
  bytesize: 8
  parity: N

sensor:
  platform: modbus
  registers:
    - name: Line_to_neutral_volts
      unit_of_measurement: Volts
      slave: 1
      register: 30001
      register_type: input
      count: 2
      data_type: float
    - name: Current                                                    
      unit_of_measurement: Amps
      slave: 1                                                                
      register: 30007
      register_type: input                                                        
      count: 2                                                                 
      data_type: float 
      *** etc ***

This is the output of the home assistant logs:

2017-08-07 12:52:41 INFO (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=modbus>
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.modbus
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.frequency, old_state=None, new_state=<state sensor.frequency=unknown; unit_of_measurement=Hz, friendly_name=Frequency @ 2017-08-07T12:52:41.417262+02:00>>
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.export_reactive_energy, old_state=None, new_state=<state sensor.export_reactive_energy=unknown; unit_of_measurement=kvarh, friendly_name=Export_reactive_energy @ 2017-08-07T12:52:41.420998+02:00>>
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.apparent_power, old_state=None, new_state=<state sensor.apparent_power=unknown; unit_of_measurement=VoltAmps, friendly_name=Apparent_power @ 2017-08-07T12:52:41.423696+02:00>>
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.total_active_energy, old_state=None, new_state=<state sensor.total_active_energy=unknown; unit_of_measurement=kwh, friendly_name=Total_active_energy @ 2017-08-07T12:52:41.426743+02:00>>
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.current, old_state=None, new_state=<state sensor.current=unknown; unit_of_measurement=Amps, friendly_name=Current @ 2017-08-07T12:52:41.429492+02:00>>
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.line_to_neutral_volts, old_state=None, new_state=<state sensor.line_to_neutral_volts=unknown; unit_of_measurement=Volts, friendly_name=Line_to_neutral_volts @ 2017-08-07T12:52:41.432269+02:00>>
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.import_reactive_energy, old_state=None, new_state=<state sensor.import_reactive_energy=unknown; unit_of_measurement=kvarh, friendly_name=Import_reactive_energy @ 2017-08-07T12:52:41.435079+02:00>>
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.import_active_energy, old_state=None, new_state=<state sensor.import_active_energy=unknown; unit_of_measurement=kwh, friendly_name=Import_active_energy @ 2017-08-07T12:52:41.437995+02:00>>
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.export_active_energy, old_state=None, new_state=<state sensor.export_active_energy=unknown; unit_of_measurement=kwh, friendly_name=Export_active_energy @ 2017-08-07T12:52:41.440889+02:00>>
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.phase_angle, old_state=None, new_state=<state sensor.phase_angle=unknown; unit_of_measurement=Degree, friendly_name=Phase_angle @ 2017-08-07T12:52:41.443783+02:00>>
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.active_power, old_state=None, new_state=<state sensor.active_power=unknown; unit_of_measurement=Watts, friendly_name=Active_power @ 2017-08-07T12:52:41.446714+02:00>>
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.total_reactive_energy, old_state=None, new_state=<state sensor.total_reactive_energy=unknown; unit_of_measurement=kvarh, friendly_name=Total_reactive_energy @ 2017-08-07T12:52:41.449733+02:00>>
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.reactive_power, old_state=None, new_state=<state sensor.reactive_power=unknown; unit_of_measurement=VAr, friendly_name=Reactive_power @ 2017-08-07T12:52:41.452742+02:00>>
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.power_factor, old_state=None, new_state=<state sensor.power_factor=unknown; unit_of_measurement=None, friendly_name=Power_factor @ 2017-08-07T12:52:41.455793+02:00>>
2017-08-07 12:52:41 INFO (MainThread) [homeassistant.setup] Setup of domain sensor took 6.4 seconds.

And this is a screenshot of the webpage:

Thanks for your help!

I’ve discovered the problem!
It was the adress of the registers. In the Eastron manual the registers adresses were 30001, 30007, etc, but reading a python implementation on https://github.com/gianfrdp/SDM120C/blob/master/sdm120c.py, the addresses werw 0,6, 12, etc.

Now I can see the values of the SDM220 modbus energy meter in Home Assistant :slight_smile:
Regards,

2 Likes

Thank you so much for this, I was struggling with my Eastron SDM120 for a few hours before I discovered this.

Sorry, What devices do you use to connect modbus to Blackberry? Do you need máster devices?

so how to translate i get some info but it is not correct

Need translate start sddress from HEX to OCT. Sample: start sddress 000C (HEX) = 0014 (OCT)

I was able to get it working however i am getting no response errors
Update of sensor.dht22_sensor8_humidity is taking over 10 seconds

12:33 PM util/async_.py (WARNING)

No response from modbus slave 50, register 358

12:32 PM components/sensor/modbus.py (ERROR)

my current delay is 100

any solution for this i am using two meters

If i will change the speed of reading should it reduce the no responsive comments?

Anyone using the SDM220Modbus with a USR-TCP232-410s Modbus RTU > Modbus TCP RS485 converter? I have both and the SDM220Modbus is measuring power and connected to the USR-TCP232-410s but using either HA or Modbus poll, I can’t seem to connect and poll the data.

image

image

P.S I’m using the registers from here Eastron (SDM220) data logging - MODBUS registers map

I got this working. I found a blog post that indicated the A and B terminals on my SDM220 may be printed backwards so I re-wired it (incorrectly) as I failed to note the blog post was 2015!!

Wired correctly, changed baud rate for comms to 9600 and used the following config and I have some nice looking gauges now using this very cost-effective MODBUS RTU > MODBUS TCP gateway!

image

  - platform: modbus
    # scan_interval: 30
    registers:
    - name: Reg0
      unit_of_measurement: V
      register: 0
      register_type: input
      count: 2
      slave: 1
      precision: 2
      data_type: float

    - name: Reg6
      unit_of_measurement: A
      register: 6
      register_type: input
      count: 2
      slave: 1
      precision: 2
      data_type: float

    - name: Reg12
      unit_of_measurement: W
      register: 12
      register_type: input
      count: 2
      slave: 1
      precision: 2
      data_type: float
      # reverse_order: true

    - name: Reg70
      unit_of_measurement: Hz
      register: 70
      register_type: input
      count: 2
      slave: 1
      precision: 2
      data_type: float

    - name: Reg342
      unit_of_measurement: kwh
      register: 342
      register_type: input
      count: 2
      slave: 1
      precision: 2
      data_type: float

modbus:
  type: tcp
  host: 10.0.1.10
  port: 26

Hey , I found the issue with this meter 9600 data transfer is really loading the bus of modbus,

so i have connected separate converter and i am doing HTTP server
Using:


I have setup the converter by ID to resolve the USB address changes.

Hi sir,I found rs485 to wifi converter. it is possible use you code for reader my EASTRON SDM modbus ?

Hi, If it’s just a WiFi to RS485 ( no modbus conversion) the settings are the same, but change tcp to rtuovertcp.
I did just that, and it works like a charm :slight_smile:

Working flawlessly until update to 0.108

The following integrations and platforms could not be set up:

Yes I have issues on 0.108 and 0.108.1 too with these modbus (RTU) sensors.

Same here, also for a serial modbus setup, still working perfect on 0.107.7. After updating to 0.108.2 it throws the following error.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 171, in _async_setup_component
    hass, processed_config
  File "/usr/src/homeassistant/homeassistant/components/modbus/__init__.py", line 139, in async_setup
    await hass.async_add_executor_job(start_modbus)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/modbus/__init__.py", line 111, in start_modbus
    client.setup()
  File "/usr/src/homeassistant/homeassistant/components/modbus/__init__.py", line 207, in setup
    loop=self._loop,
  File "/usr/local/lib/python3.7/site-packages/pymodbus/client/asynchronous/serial.py", line 75, in __new__
    yieldable = factory_class(framer=framer, port=port, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pymodbus/client/asynchronous/factory/serial.py", line 104, in async_io_factory
    client = AsyncioModbusSerialClient(port, proto_cls, framer, loop, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pymodbus/client/asynchronous/asyncio/__init__.py", line 689, in __init__
    self._connected_event = asyncio.Event()
  File "/usr/local/lib/python3.7/asyncio/locks.py", line 249, in __init__
    self._loop = events.get_event_loop()
  File "/usr/local/lib/python3.7/asyncio/events.py", line 644, in get_event_loop
    % threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'SyncWorker_1'.

There are two bugreports who could be related to these issues. One is about a direct serial connection.That one has a fix but it’s not in a release yet:
https://github.com/home-assistant/core/issues/33872

The other one is about RTU over TCP, that one is still open:
https://github.com/home-assistant/core/issues/33947

If you already run a NodeRed Instance you could switch from HA modbus integration to NodeRed & MQTT and grab the data via MQTT Sensors in HA. I did that yesterday with my installation

1 Like

I have done the same, I moved all modbus read inside nodered, below my export for read sdm120 and publish data as MQTT

[{“id”:“c233fe31.d746b”,“type”:“inject”,“z”:“c5d09c5.47fefe”,“name”:“”,“topic”:“”,“payload”:“”,“payloadType”:“date”,“repeat”:“5”,“crontab”:“”,“once”:false,“onceDelay”:0.1,“x”:150,“y”:100,“wires”:[[“78678abc.6260ac”]]},{“id”:“78678abc.6260ac”,“type”:“function”,“z”:“c5d09c5.47fefe”,“name”:“sdm120 config”,“func”:“msg.payload = { value: msg.payload, ‘fc’: 4, ‘unitid’: 1, ‘address’: 0 , ‘quantity’: 72 } \nmsg.topic ="sdm120"\nreturn msg “,“outputs”:1,“noerr”:0,“x”:340,“y”:100,“wires”:[[“10575b73.1e080d”]]},{“id”:“10575b73.1e080d”,“type”:“modbus-flex-getter”,“z”:“c5d09c5.47fefe”,“name”:“sdm120Read”,“showStatusActivities”:true,“showErrors”:true,“logIOActivities”:false,“server”:“e022a16d.7d87e”,“useIOFile”:false,“ioFile”:””,“useIOForPayload”:false,“emptyMsgOnFail”:false,“x”:540,“y”:100,“wires”:[[“c2897480.708678”],]},{“id”:“c2897480.708678”,“type”:“function”,“z”:“c5d09c5.47fefe”,“name”:“”,“func”:“var rawData = new ArrayBuffer(4);\nvar intView = new Uint16Array(rawData);\nvar fltView = new Float32Array(rawData);\n\n\nintView[0] = msg.payload[1]; //low\nintView[1] = msg.payload[0]; //high\n\nvar msg1 = { payload:Math.round(parseFloat(fltView[0].toFixed(1))) };\nmsg1.topic = "smd/1/voltage";\n\n\n\nintView[0] = msg.payload[7]; //low\nintView[1] = msg.payload[6]; //high\n\nvar msg2 = { payload:parseFloat(fltView[0].toFixed(1)) };\nmsg2.topic = "smd/1/current";\n\n\n\nintView[0] = msg.payload[13]; //low\nintView[1] = msg.payload[12]; //high\nvar msg3 = { payload:Math.round(parseFloat(fltView[0].toFixed(1))) };\nmsg3.topic = "smd/1/power";\nglobal.set("actPower",msg3.payload);\n\n\nintView[0] = msg.payload[71]; //low\nintView[1] = msg.payload[70]; //high\n\nvar msg4 = { payload:parseFloat(fltView[0].toFixed(1)) };\nmsg4.topic = "smd/1/frequency";\n\n\n\nreturn [msg1, msg2, msg3 , msg4 ];\n\n”,“outputs”:4,“noerr”:0,“x”:770,“y”:100,“wires”:[[“f7a9ca52.3640d8”],[“450203de.5d6c8c”],[“76a2743f.cd745c”],[“22d0c38e.84ee4c”]]},{“id”:“f7a9ca52.3640d8”,“type”:“function”,“z”:“c5d09c5.47fefe”,“name”:“payload is changed”,“func”:“var mem=context.get("memory");\nvar forceCall=global.get("force_call");\n\nnode.status({shape:"ring",fill:"green",text:"msg: "+msg.payload +" | msg_old:"+ mem + " | fc: "+forceCall});\n\nif ((msg.payload != mem || forceCall)) {\n context.set("memory",msg.payload);\n return msg; \n }\n\nreturn null;\n\n”,“outputs”:1,“noerr”:0,“x”:1010,“y”:80,“wires”:[[“25585f16.519318”]],“info”:“if msg payload is changed then return the msg.payload otherwise return null “},{“id”:“450203de.5d6c8c”,“type”:“function”,“z”:“c5d09c5.47fefe”,“name”:“payload is changed”,“func”:“var mem=context.get("memory");\nvar forceCall=global.get("force_call");\n\nnode.status({shape:"ring",fill:"green",text:"msg: "+msg.payload +" | msg_old:"+ mem + " | fc: "+forceCall});\n\nif ((msg.payload != mem || forceCall)) {\n context.set("memory",msg.payload);\n return msg; \n }\n\nreturn null;\n\n”,“outputs”:1,“noerr”:0,“x”:1010,“y”:140,“wires”:[[“3347fd0.b2d7284”]],“info”:“if msg payload is changed then return the msg.payload otherwise return null “},{“id”:“76a2743f.cd745c”,“type”:“function”,“z”:“c5d09c5.47fefe”,“name”:“payload is changed”,“func”:“var mem=context.get("memory");\nvar forceCall=global.get("force_call");\n\nnode.status({shape:"ring",fill:"green",text:"msg: "+msg.payload +" | msg_old:"+ mem + " | fc: "+forceCall});\n\nif ((msg.payload != mem || forceCall)) {\n context.set("memory",msg.payload);\n return msg; \n }\n\nreturn null;\n\n”,“outputs”:1,“noerr”:0,“x”:1010,“y”:200,“wires”:[[“a9167b3c.ced7f8”,“46985845.386ec8”]],“info”:“if msg payload is changed then return the msg.payload otherwise return null “},{“id”:“22d0c38e.84ee4c”,“type”:“function”,“z”:“c5d09c5.47fefe”,“name”:“payload is changed”,“func”:“var mem=context.get("memory");\nvar forceCall=global.get("force_call");\n\nnode.status({shape:"ring",fill:"green",text:"msg: "+msg.payload +" | msg_old:"+ mem + " | fc: "+forceCall});\n\nif ((msg.payload != mem || forceCall)) {\n context.set("memory",msg.payload);\n return msg; \n }\n\nreturn null;\n\n”,“outputs”:1,“noerr”:0,“x”:1010,“y”:320,“wires”:[[“ced7c462.eda5d8”]],“info”:“if msg payload is changed then return the msg.payload otherwise return null “},{“id”:“ced7c462.eda5d8”,“type”:“mqtt out”,“z”:“c5d09c5.47fefe”,“name”:””,“topic”:“sdm120/1/frequency”,“qos”:“0”,“retain”:“true”,“broker”:“3c4f987a.7246”,“x”:1300,“y”:320,“wires”:},{“id”:“a9167b3c.ced7f8”,“type”:“mqtt out”,“z”:“c5d09c5.47fefe”,“name”:””,“topic”:“sdm120/1/power”,“qos”:“0”,“retain”:“true”,“broker”:“3c4f987a.7246”,“x”:1250,“y”:200,“wires”:},{“id”:“3347fd0.b2d7284”,“type”:“mqtt out”,“z”:“c5d09c5.47fefe”,“name”:””,“topic”:“sdm120/1/current”,“qos”:“0”,“retain”:“true”,“broker”:“3c4f987a.7246”,“x”:1250,“y”:140,“wires”:},{“id”:“25585f16.519318”,“type”:“mqtt out”,“z”:“c5d09c5.47fefe”,“name”:””,“topic”:“sdm120/1/voltage”,“qos”:“0”,“retain”:“true”,“broker”:“3c4f987a.7246”,“x”:1250,“y”:80,“wires”:},{“id”:“e022a16d.7d87e”,“type”:“modbus-client”,“z”:“”,“name”:“Serial_9600_8_N_1”,“clienttype”:“serial”,“bufferCommands”:true,“stateLogEnabled”:false,“queueLogEnabled”:false,“tcpHost”:“127.0.0.1”,“tcpPort”:“502”,“tcpType”:“DEFAULT”,“serialPort”:“/dev/ttyUSB0”,“serialType”:“RTU-BUFFERD”,“serialBaudrate”:“9600”,“serialDatabits”:“8”,“serialStopbits”:“1”,“serialParity”:“none”,“serialConnectionDelay”:“100”,“unit_id”:“”,“commandDelay”:“30”,“clientTimeout”:“2000”,“reconnectOnTimeout”:true,“reconnectTimeout”:“5000”,“parallelUnitIdsAllowed”:false},{“id”:“3c4f987a.7246”,“type”:“mqtt-broker”,“z”:“”,“name”:“”,“broker”:“localhost”,“port”:“1883”,“clientid”:“”,“usetls”:false,“compatmode”:false,“keepalive”:“60”,“cleansession”:true,“birthTopic”:“”,“birthQos”:“0”,“birthPayload”:“”,“closeTopic”:“”,“closeQos”:“0”,“closePayload”:“”,“willTopic”:“”,“willQos”:“0”,“willPayload”:“”}]