Modbus Single Phase meter

Hello,

I’m trying to get the readings from my sdm120 modbus single phase power meter (http://support.innon.com/PowerMeters/SDM120DB-MID/Manual/SDM120_PROTOCOL.pdf).
But no matter what settings I use, it keeps giving this error:

2021-02-15 20:00:35.062 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/1 error: Could not get port identifier, maybe insufficient permissions. null. Connection SerialConnection@564b9c70[portName=/dev/ttySDM,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@51f75751[portName=/dev/ttySDM]

2021-02-15 20:00:35.065 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - re-connect reached max tries 1, throwing last error: Could not get port identifier, maybe insufficient permissions. null. Connection SerialConnection@564b9c70[portName=/dev/ttySDM,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@51f75751[portName=/dev/ttySDM]

2021-02-15 20:00:35.067 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - Error connecting connection SerialConnection@564b9c70[portName=/dev/ttySDM,port=<null>] for endpoint ModbusSerialSlaveEndpoint@51f75751[portName=/dev/ttySDM]: Could not get port identifier, maybe insufficient permissions. null

2021-02-15 20:00:35.070 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Could not connect to endpoint ModbusSerialSlaveEndpoint@51f75751[portName=/dev/ttySDM] -- aborting request ModbusReadRequestBlueprint@55c8d9b7[slaveId=1,functionCode=READ_MULTIPLE_REGISTERS,start=30001,length=61,maxTries=3] [operation ID 8eff22ef-57fd-41f0-8284-3a7adb3e7448]

My Thing settings are as follows:

Using the Domotics sdm120 application I am able the read al the values correctly, so I know I have the correct settings.
I even tried a simple Modbus poller thing to see what happens, but same error.

I’m running the latest Openhabian image on a RPi3.

Hopefully someone can shine some light on this.

Kind regards,

Roelf

Hi Roelf, welcome!

Also have the SDM120, but don’t use the UI configuration. For sure no expert, but will try to help as far as I come.

To start with, I think your Stop Bit should be set to 1 (at least that is what I have).

Did you also set the EXTRA_JAVA_OPTS?

Hi Iampy,

Thanks! I tried the EXTRA_JAVA_OPTS, it didn’t make a difference.
I did said the names to static in the /etc/udev/rules.d/99-com.rules file.
I also have an other serial device to read out my smart meter with the DSMR binding, and
that work just fine, so I know my serial devices are coming thru in openHAB

Using this (Eastron SDM120C - Domoticz) tool and this commando

sdm120c -a1 -b9600 -PN -S2 -q /dev/ttySDM

I get the data correctly. The SDM120 documentation says 1 or 2 stopbits when using no parity, otherwise 1.
It also doesn’t change anything in openhab.

OK though the error message does tell openhab doesn’t have the right permissions.
Checked my notes, and I followed the link below. It also contains some additional steps. Take special note to use OpenHAB (with or w/o the 2)

1 Like

Hi, (without intention to hijack the topic) I am also looking into getting several Eastron meters. Which hardware would you recommend to be used to connect those meters on raspberry Pi4? Also has anybody tried daisy chain more than one slave? According Modbus protocol this should be possible

Yeah, I followed those instructions before. Made no difference.
Even tried is openhab had access to the device with

sudo -u openhab sdm120c … … /dev/ttyUSB1

that worked just fine. So I ran out of idea’s after that, hence I’m here :nerd_face:

I have a lot of them, currently 2 in use. rest yet to connect. The 2 so far work just fine daisy-chained.
I have a cheap modbus RTU to USB adapter from eBay, with G-A-B connector.
Using the Domotics SDM120C application (linked in post above) you can communicate with them.

At the moment I use it in combination with the exec binding to get the values into openHAB. Not my preferred method, but it works

If the Domotics tool has possession of the serial port, then openHAB cannot. One application at a time.

First follow the comment of Rossko57.

Since OH3 I only use the UI, except this SDM120. You could try to use my .things file, change your parameters accordingly. But don’t expect this solves the error.

Bridge modbus:serial:endpointSDM120 [port="/dev/ttyUSBMODBUS",baud=9600,id=1,dataBits=8,parity="none",stopBits="1.0",encoding="rtu"] {
    Bridge poller inputRegisters [ start=0, length=80, refresh=600, type="input" ] {
        Thing data Voltage                       "Voltage" @ "Mains"                            [ readStart="0", readValueType="float32" ]
        Thing data Current                       "Current" @ "Mains"                             [ readStart="6", readValueType="float32" ]
        Thing data ActivePower                   "Active Power" @ "Mains"                        [ readStart="12", readValueType="float32" ]
        Thing data ApparentPower                 "Apparent Power" @ "Mains"                      [ readStart="18", readValueType="float32" ]
        Thing data ReactivePower                 "Reactive Power" @ "Mains"                      [ readStart="24", readValueType="float32" ]
        Thing data PowerFactor                   "Power Factor" @ "Mains"                        [ readStart="30", readValueType="float32" ]
        Thing data PhaseAngle                    "Phase Angle" @ "Mains"                          [ readStart="36", readValueType="float32" ]
        Thing data Frequency                     "Frequency" @ "Mains"                            [ readStart="70", readValueType="float32" ]
        Thing data ImportActiveEnergy            "Import Active Energy" @ "Mains"                 [ readStart="72", readValueType="float32" ]
        Thing data ExportActiveEnergy            "Export Active Energy" @ "Mains"                [ readStart="74", readValueType="float32" ]
        Thing data ImportReactiveEnergy          "Import Reactive Energy" @ "Mains"              [ readStart="76", readValueType="float32" ]
        Thing data ExportReactiveEnergy          "Export Reactive Energy" @ "Mains"             [ readStart="78", readValueType="float32" ]
        
	}}

I know, when trying if it works, I disable everything that may want to connect to the serial port. just in case

I’ll give that a try! it’s a lot nicer to have things then scripts executing those kind of things.

Unfortunately none of my serial ports work anymore, even the DSMR binding which previously worked without any problems.
and the domoticz application can read any values anymore…

Even your config gives the same error as before. Could it be a bug?
Anyway, I’ll leave at that.
Due to the amount of units I want to read (16 of them), it needs a separate script to make sure none of the items try to read at the same time.
Something which I already encountered with 2 after a reboot.
16 need management to read 1 after the other, and so far I haven’t found anything like that in openHAB.
thanks for the help tho.

??

Modbus is "one at a time"over the bus, each query must get a response or fail before the next query can be sent. That’s part of the protocol definition.

In openHAB, you don’t worry about any of that at all, the binding manages traffic queues for the bus.

It is daisy chainable, you only need to change the address.
Hence the management part, read data in order to prevent errors

Yes, the binding manages all of that; 30 devices on one wire, 120 pollers fetching different data blocks, all managed for you.

Your problem is that your host system is just not allowing openHAB to access the serial port.

You might compare what is different about these ports.

Yeah, that’d be perfect indeed.

I check all things I could find online, tried all solutions to other serial problems I could find on the forums.
But none of them worked. As no other mention of the kind of problem I’m having

As far as I can tell, the only difference is the serial attribute, which makes sense of course.
FTDI chip has same manufacturer code and name and everything.

So not much luck there

One thing came across my mind, you do use openhabian right? Did you tried using the serial option in the menu?

  • system related (option 30)
  • serial port (option 35)