Reading from a SDM120 meter using EmonHub

Did you update your emonhub config to reflect the example I gave above? any chance there’s an error in your copy and paste?

[[modbus]]
    Type = EmonHubMinimalModbusInterfacer
    [[[init_settings]]]
        device = /dev/ttyUSB0
        baud = 2400
    [[[runtimesettings]]]
        pubchannels = ToEmonCMS,
        read_interval = 10
        nodename = sdm120
        # prefix = sdm_
        [[[[meters]]]]
            [[[[[sdm120a]]]]]
                address = 1
                registers = 0,6,12,18,30,70,72,74,76
                names = V,I,P,VA,PF,FR,EI,EE,RI
                precision = 2,3,1,1,3,3,3,3,3
            [[[[[sdm120b]]]]]
                address = 2
                registers = 0,6,12,18,30,70,72,74,76
                names = V,I,P,VA,PF,FR,EI,EE,RI
                precision = 2,3,1,1,3,3,3,3,3

I did the following:

cd /opt/openenergymonitor/emonhub
git fetch --all
git checkout minimalmodbus_multiple_meters
git pull
sudo service emonhub restart

My emonhub.conf looks like:

[interfacers]

#[[SDM230]]
 #   Type = EmonHubMinimalModbusInterfacer
  #  [[[init_settings]]]
   #     device = /dev/ttyUSB0
    #    baud = 9600
#    [[[runtimesettings]]]
 #       pubchannels = ToEmonCMS,
  #      read_interval = 10
   #     nodename = SDM230
    #   addresses = 1,2,
     #  registers = 12,72,74,342
      # names = Active power W, Import active energy kWh, Export active energy kWh, Total active energy kWh
      # precision = 1,1,1,1

[[modbus]]
    Type = EmonHubMinimalModbusInterfacer
    [[[init_settings]]]
        device = /dev/ttyUSB0
        baud = 9600
    [[[runtimesettings]]]
        pubchannels = ToEmonCMS,
        read_interval = 10
        nodename = sdm120
        # prefix = sdm_
        [[[[meters]]]]
            [[[[[sdm120a]]]]]
                address = 1
                registers = 0,6
                names = V,I
                precision = 2,3
            [[[[[sdm120b]]]]]
                address = 2
                registers = 0,6
                names = V,I
                precision = 2,3
             

[[MQTT]]

Baud is 9600 on my meters. I’m just reading a couple of values to make clean up easier on inputs page when I revert to your first method which is working (commented out section above).

Log looks like:

2022-02-15 11:42:39,668 INFO     MainThread EmonHub emonHub (emon-pi variant) v2.2.6
2022-02-15 11:42:39,672 INFO     MainThread Opening hub...
2022-02-15 11:42:39,674 INFO     MainThread Logging level set to DEBUG
2022-02-15 11:42:39,675 INFO     MainThread Creating EmonHubMinimalModbusInterfacer 'modbus'
2022-02-15 11:42:39,776 INFO     MainThread Connecting to Modbus device=/dev/ttyUSB0 baud=9600
2022-02-15 11:42:39,795 INFO     MainThread Setting modbus read_interval: 10
2022-02-15 11:42:39,796 INFO     MainThread Setting modbus nodename: sdm120
2022-02-15 11:42:39,797 INFO     MainThread Setting modbus prefix: 
2022-02-15 11:42:39,798 INFO     MainThread Setting modbus address: 1
2022-02-15 11:42:39,799 ERROR    MainThread Unable to create 'modbus' interfacer: sequence item 0: expected str instance, int found
2022-02-15 11:42:39,800 INFO     MainThread Creating EmonHubMqttInterfacer 'MQTT'
2022-02-15 11:42:39,802 DEBUG    MainThread Setting MQTT pubchannels: ['ToRFM12']
2022-02-15 11:42:39,802 DEBUG    MainThread Setting MQTT subchannels: ['ToEmonCMS']
2022-02-15 11:42:39,803 INFO     MainThread Setting MQTT node_format_enable: 1
2022-02-15 11:42:39,804 INFO     MainThread Setting MQTT nodevar_format_enable: 1
2022-02-15 11:42:39,805 INFO     MainThread Setting MQTT nodevar_format_basetopic: emon/
2022-02-15 11:42:39,805 INFO     MainThread Setting MQTT node_JSON_enable: 0
2022-02-15 11:42:39,807 INFO     MainThread Creating EmonHubEmoncmsHTTPInterfacer 'emoncmsorg'
2022-02-15 11:42:39,809 DEBUG    MainThread Setting emoncmsorg pubchannels: ['ToRFM12']
2022-02-15 11:42:39,809 DEBUG    MainThread Setting emoncmsorg subchannels: ['ToEmonCMS']
2022-02-15 11:42:39,810 WARNING  MainThread Setting emoncmsorg apikey: obscured
2022-02-15 11:42:39,811 INFO     MainThread Setting emoncmsorg url: https://emoncms.org
2022-02-15 11:42:39,812 INFO     MainThread Setting emoncmsorg senddata: 1
2022-02-15 11:42:39,813 INFO     MainThread Setting emoncmsorg sendstatus: 1

Parsing errors seem to have stopped, just getting unable to create modbus interfacer now.

2 Likes

Hello @MBC sorry for taking such a long time to get back to you. I’ve pushed up some more changes to this interfacer, it should hopefully solve the issue.

That’s fixed it! I can now read different registers on each meter :smiley:
Many thanks for sorting it. I will make a new post with my notes on how to set up emoncms with multiple meters so that other folks can hopefully set it all up more easily.

Thanks again, Mark.

Fantastic. Appreciate your efforts on this as about to dig into interfacing with several SDM120 Modbus myself

I have put my notes in a new topic if you want to take a look :slight_smile:

Installing Emoncms onto a PC (or Mac) and using with multiple modbus meters (e.g. SDM230)

1 Like