Modbus / MBUS connection errors on fresh install with "known good" old config

Hi folks,

I’m migrating from one old Proxmox LXC running Ubuntu 22.04 to a new fresh LCX with a new fresh emoncms install. I’ve got the level 3 monitoring package with the SM120 Eastron Modbus energy meter and the Sontex MBUS heat meter.

The install seems to have gone really well, and I’m in the position where I can spin the two instance up or down as needed without too much of an issue.

I was able to set up emonhub too without too much of an issue and it starts just fine.

● emonhub.service - emonHub data multiplexer
     Loaded: loaded (/etc/systemd/system/emonhub.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2025-03-10 11:54:24 GMT; 4min 37s ago
    Process: 564 ExecStartPre=/bin/mkdir -p ${LOG_PATH} (code=exited, status=0/SUCCESS)
    Process: 565 ExecStartPre=/bin/chown ${USER} ${LOG_PATH} (code=exited, status=0/SUCCESS)
   Main PID: 566 (python3)
      Tasks: 5 (limit: 115460)
     Memory: 23.1M
        CPU: 754ms
     CGroup: /system.slice/emonhub.service
             └─566 python3 /usr/local/bin/emonhub/emonhub.py --config-file=/etc/emonhub/emonhub.conf --logfile=/var/log/emonhub/emonhub.log

I can see the logs in /var/log/emonhub/emonhub.log just fine and I’ve copy pasted across my config into /etc/emonhub/emonhub.conf. Config below for reference.

Both USB devices are unchanged between the two emoncms installations, and both can be seen in lsusb or ls -al /dev/serial/by-id/ ... etc

Strangely however, whereas I’m able to see the data fine from the older install, on the newer one, I’m getting connection errors. The OS is the same, the LXC setup is the same, both are running the latest version of emoncms etc, and both use the same serial Modbus and MBUS USB devices connected to the same ports (obviously - I only have one LXC running at once.)

Errors below the config. I’m generally missing something obvious - could anyone point me in the right direction please?

Thanks in advance!

#######################################################################
#######################      emonhub.conf     #########################
#######################################################################
### emonHub configuration file, for info see documentation:
### https://github.com/openenergymonitor/emonhub/blob/emon-pi/configuration.md
#######################################################################
#######################    emonHub  settings    #######################
#######################################################################

[hub]
    ### loglevel must be one of DEBUG, INFO, WARNING, ERROR, and CRITICAL
    loglevel = DEBUG
    autoconf = 1
### Uncomment this to also send to syslog
# use_syslog = yes
#######################################################################
#######################       Interfacers       #######################
#######################################################################

[interfacers]
    ### This interfacer manages the RFM12Pi/RFM69Pi/emonPi module
#    [[EmonPi2]]
#        Type = EmonHubOEMInterfacer
#        [[[init_settings]]]
#            com_port = /dev/ttyAMA0
#            com_baud = 115200
#        [[[runtimesettings]]]
#            pubchannels = ToEmonCMS,
#            subchannels = ToRFM12,

#    [[USB0]]
#        Type = EmonHubOEMInterfacer
#        [[[init_settings]]]
#            com_port = /dev/ttyUSB0
#            com_baud = 115200
#        [[[runtimesettings]]]
#            pubchannels = ToEmonCMS,
#            subchannels = ToRFM12,
#            nodename = emonTx4

#    [[SPI]]
#        Type = EmonHubRFM69LPLInterfacer
#        [[[init_settings]]]
#            nodeid = 5
#            networkID = 210
#            resetPin = 24
#            selPin = 16
#        [[[runtimesettings]]]
#            pubchannels = ToEmonCMS,

    [[MQTT]]
        Type = EmonHubMqttInterfacer
        [[[init_settings]]]
            mqtt_host = 127.0.0.1
            mqtt_port = 1883
            mqtt_user = emonpi
            mqtt_passwd = emonpimqtt2016

        [[[runtimesettings]]]
            pubchannels = ToRFM12,
            subchannels = ToEmonCMS,

            # emonhub/rx/10/values format
            # Use with emoncms Nodes module
            node_format_enable = 0
            node_format_basetopic = emonhub/

            # emon/emontx/power1 format - use with Emoncms MQTT input
            # http://github.com/emoncms/emoncms/blob/master/docs/RaspberryPi/MQTT.md
            nodevar_format_enable = 1
            nodevar_format_basetopic = emon/

            # Single JSON payload published  - use with Emoncms MQTT
            node_JSON_enable = 0
            node_JSON_basetopic = emon/

    [[emoncmsorg]]
        Type = EmonHubEmoncmsHTTPInterfacer
        [[[init_settings]]]
        [[[runtimesettings]]]
            pubchannels = ToRFM12,
            subchannels = ToEmonCMS,
            url = https://emoncms.org
            apikey = a8e4eae28dbfd04af07712b06fd1cf70
            senddata = 1    # Enable sending data to Emoncms.org
            sendnames = 1    # Send full input names (compression will be automatically enabled)
            interval = 30    # Bulk send interval to Emoncms.org in seconds

    [[SDM120]]
        Type = EmonHubMinimalModbusInterfacer
        [[[init_settings]]]
            device = /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A10N2R33-if00-port0
            baud = 9600
        [[[runtimesettings]]]
            pubchannels = ToEmonCMS,
            read_interval = 10
            nodename = eastron_modbus
            [[[[meters]]]]
                [[[[[electric]]]]]
                    address = 1
                    registers = 12, 72
                    names = Power, Energy
                    precision = 1, 3
#                [[[[[electric2]]]]]
#                    address = 2
#                    registers = 12, 72
#                    names = Power, Energy
#                    precision = 1, 3


    [[MBUS]]
        Type = EmonHubMBUSInterfacer
        [[[init_settings]]]
            device = /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_DLASb118D16-if00-port0
            baud = 2400
        [[[runtimesettings]]]
            pubchannels = ToEmonCMS,
            read_interval = 10
            validate_checksum = False
            nodename = sontex_mbus
            [[[[meters]]]]
                [[[[[heatmeter]]]]]
                    address = 1
                    type = standard


#    [[DS18B20]]
#        Type = EmonHubDS18B20Interfacer
#        [[[init_settings]]]
#        [[[runtimesettings]]]
#            pubchannels = ToEmonCMS,
#            read_interval = 10
#            nodename = sensors
            # In the two lines following, un-comment the lines and replace the IDs
            # and names with those applicable to your system.

            # ids = 28-000008e2db06, 28-000009770529, 28-0000096a49b4
            # names = ambient, cyl_bot, cyl_top

#######################################################################
#######################          Nodes          #######################
#######################################################################

## See config user guide: https://github.com/openenergymonitor/emonhub
## If autoconf is enabled above, node configuration will automatically
## populate based on templates listed in available.conf

[nodes]
➜  ~ tail -f /var/log/emonhub/emonhub.log
2025-03-10 12:05:50,059 ERROR    SDM120     Could not connect to Modbus device
2025-03-10 12:05:50,059 DEBUG    MBUS       Connecting to MBUS serial: /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_DLASb118D16-if00-port0 2400
2025-03-10 12:05:50,059 ERROR    MBUS       Could not connect to MBUS serial
2025-03-10 12:05:50,059 ERROR    MBUS       Could not write to MBUS serial port
2025-03-10 12:05:50,059 ERROR    MBUS       read_data_frame could not read from serial port
2025-03-10 12:05:50,059 DEBUG    MBUS       Invalid MBUS data received 0 bytes 0.0 ms, count: 7
2025-03-10 12:05:50,260 ERROR    MBUS       Could not write to MBUS serial port
2025-03-10 12:05:50,260 ERROR    MBUS       read_data_frame could not read from serial port
2025-03-10 12:05:50,260 DEBUG    MBUS       Invalid MBUS data received 0 bytes 0.0 ms, count: 8
2025-03-10 12:05:50,460 DEBUG    MBUS       Decoded MBUS data: None
2025-03-10 12:06:00,079 ERROR    SDM120     Not connected to modbus device
2025-03-10 12:06:00,081 DEBUG    MBUS       Connecting to MBUS serial: /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_DLASb118D16-if00-port0 2400
2025-03-10 12:06:00,081 ERROR    MBUS       Could not connect to MBUS serial
2025-03-10 12:06:00,081 INFO     SDM120     Connecting to Modbus device=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A10N2R33-if00-port0 baud=9600 parity=none datatype=float
2025-03-10 12:06:00,081 ERROR    MBUS       Could not write to MBUS serial port
2025-03-10 12:06:00,081 ERROR    MBUS       read_data_frame could not read from serial port
2025-03-10 12:06:00,082 DEBUG    MBUS       Invalid MBUS data received 0 bytes 0.1 ms, count: 9
2025-03-10 12:06:00,081 ERROR    SDM120     Could not connect to Modbus device
2025-03-10 12:06:00,282 ERROR    MBUS       Could not write to MBUS serial port
2025-03-10 12:06:00,282 ERROR    MBUS       read_data_frame could not read from serial port
2025-03-10 12:06:00,282 DEBUG    MBUS       Invalid MBUS data received 0 bytes 0.1 ms, count: 10
2025-03-10 12:06:00,282 DEBUG    MBUS       Invalid count = 10. Restarting MBUS serial connection on next read
2025-03-10 12:06:00,483 DEBUG    MBUS       Decoded MBUS data: None
2025-03-10 12:06:10,001 ERROR    SDM120     Not connected to modbus device
2025-03-10 12:06:10,003 INFO     SDM120     Connecting to Modbus device=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A10N2R33-if00-port0 baud=9600 parity=none datatype=float
2025-03-10 12:06:10,003 ERROR    SDM120     Could not connect to Modbus device
2025-03-10 12:06:10,004 DEBUG    MBUS       Connecting to MBUS serial: /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_DLASb118D16-if00-port0 2400
2025-03-10 12:06:10,004 ERROR    MBUS       Could not connect to MBUS serial
2025-03-10 12:06:10,004 ERROR    MBUS       Could not write to MBUS serial port
2025-03-10 12:06:10,004 ERROR    MBUS       read_data_frame could not read from serial port
2025-03-10 12:06:10,004 DEBUG    MBUS       Invalid MBUS data received 0 bytes 0.0 ms, count: 1
2025-03-10 12:06:10,204 ERROR    MBUS       Could not write to MBUS serial port
2025-03-10 12:06:10,205 ERROR    MBUS       read_data_frame could not read from serial port
2025-03-10 12:06:10,205 DEBUG    MBUS       Invalid MBUS data received 0 bytes 0.0 ms, count: 2
2025-03-10 12:06:10,405 DEBUG    MBUS       Decoded MBUS data: None
2025-03-10 12:06:20,024 ERROR    SDM120     Not connected to modbus device
2025-03-10 12:06:20,024 DEBUG    MBUS       Connecting to MBUS serial: /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_DLASb118D16-if00-port0 2400
2025-03-10 12:06:20,025 INFO     SDM120     Connecting to Modbus device=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A10N2R33-if00-port0 baud=9600 parity=none datatype=float
2025-03-10 12:06:20,025 ERROR    SDM120     Could not connect to Modbus device
2025-03-10 12:06:20,025 ERROR    MBUS       Could not connect to MBUS serial
2025-03-10 12:06:20,025 ERROR    MBUS       Could not write to MBUS serial port
2025-03-10 12:06:20,025 ERROR    MBUS       read_data_frame could not read from serial port
2025-03-10 12:06:20,025 DEBUG    MBUS       Invalid MBUS data received 0 bytes 0.0 ms, count: 3
2025-03-10 12:06:20,225 ERROR    MBUS       Could not write to MBUS serial port
2025-03-10 12:06:20,225 ERROR    MBUS       read_data_frame could not read from serial port
2025-03-10 12:06:20,225 DEBUG    MBUS       Invalid MBUS data received 0 bytes 0.0 ms, count: 4
2025-03-10 12:06:20,426 DEBUG    MBUS       Decoded MBUS data: None
2025-03-10 12:06:30,044 ERROR    SDM120     Not connected to modbus device
2025-03-10 12:06:30,046 INFO     SDM120     Connecting to Modbus device=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A10N2R33-if00-port0 baud=9600 parity=none datatype=float
2025-03-10 12:06:30,046 ERROR    SDM120     Could not connect to Modbus device
2025-03-10 12:06:30,046 DEBUG    MBUS       Connecting to MBUS serial: /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_DLASb118D16-if00-port0 2400
2025-03-10 12:06:30,046 ERROR    MBUS       Could not connect to MBUS serial
2025-03-10 12:06:30,046 ERROR    MBUS       Could not write to MBUS serial port
2025-03-10 12:06:30,046 ERROR    MBUS       read_data_frame could not read from serial port
2025-03-10 12:06:30,046 DEBUG    MBUS       Invalid MBUS data received 0 bytes 0.0 ms, count: 5
2025-03-10 12:06:30,246 ERROR    MBUS       Could not write to MBUS serial port
2025-03-10 12:06:30,247 ERROR    MBUS       read_data_frame could not read from serial port
2025-03-10 12:06:30,247 DEBUG    MBUS       Invalid MBUS data received 0 bytes 0.0 ms, count: 6
2025-03-10 12:06:30,447 DEBUG    MBUS       Decoded MBUS data: None
2025-03-10 12:06:40,064 ERROR    SDM120     Not connected to modbus device
2025-03-10 12:06:40,065 INFO     SDM120     Connecting to Modbus device=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A10N2R33-if00-port0 baud=9600 parity=none datatype=float
2025-03-10 12:06:40,065 ERROR    SDM120     Could not connect to Modbus device
2025-03-10 12:06:40,067 DEBUG    MBUS       Connecting to MBUS serial: /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_DLASb118D16-if00-port0 2400
2025-03-10 12:06:40,067 ERROR    MBUS       Could not connect to MBUS serial
2025-03-10 12:06:40,067 ERROR    MBUS       Could not write to MBUS serial port
2025-03-10 12:06:40,067 ERROR    MBUS       read_data_frame could not read from serial port
2025-03-10 12:06:40,067 DEBUG    MBUS       Invalid MBUS data received 0 bytes 0.0 ms, count: 7
2025-03-10 12:06:40,267 ERROR    MBUS       Could not write to MBUS serial port
2025-03-10 12:06:40,267 ERROR    MBUS       read_data_frame could not read from serial port
2025-03-10 12:06:40,267 DEBUG    MBUS       Invalid MBUS data received 0 bytes 0.0 ms, count: 8
2025-03-10 12:06:40,468 DEBUG    MBUS       Decoded MBUS data: None

Mm I’m not sure, could be a serial port permissions issue?

Is the mbus ID correct? Sontex is usually ID 0, but I could be ID 1 if its been set. If ID 1 was working previously then it much be ID 1

Hey @glyn.hudson - thanks mate.

I would assume the mbus ID is the same - the config was copied across, and I’ve not touched the devices themselves, plus it still works on the other instance.

I did have serial port permissions pop into my head at one point, but not sure what I’m looking for there. I’ll have a dig on Google and see what comes up. :+1:t2:

For my reference lol, this is from the working container.

lrwxrwxrwx 1 root root  13 Mar  9 22:20 usb-FTDI_FT232R_USB_UART_A10N2R33-if00-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root  13 Mar  9 22:20 usb-Prolific_Technology_Inc._USB-Serial_Controller_DLASb118D16-if00-port0 -> ../../ttyUSB0

and

crw-rw----  1 root dialout 188, 0 Mar 10 14:39 ttyUSB0
crw-rw----  1 root dialout 188, 1 Mar 10 14:39 ttyUSB1

On the new (not working container).

lrwxrwxrwx 1 root root  13 Mar  9 22:20 usb-FTDI_FT232R_USB_UART_A10N2R33-if00-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root  13 Mar  9 22:20 usb-Prolific_Technology_Inc._USB-Serial_Controller_DLASb118D16-if00-port0 -> ../../ttyUSB0

and

crw-rw----  1 root dialout 188, 0 Mar 10 14:40 ttyUSB0
crw-rw----  1 root dialout 188, 1 Mar 10 14:40 ttyUSB1

@glyn.hudson - genius mate. :beer:

I noticed that noone was in the dialout group.

➜  /dev sudo adduser root dialout
Adding user `root' to group `dialout' ...
Adding user root to group dialout
Done.
➜  /dev sudo adduser pi dialout
Adding user `pi' to group `dialout' ...
Adding user pi to group dialout
Done.

and now …

Thank you as always!

Whoo! Nice work :+1: