Modbus openHAB2 binding available for alpha testing

openhab2-addons
modbus
binding
Tags: #<Tag:0x00007f6ce3b83b50> #<Tag:0x00007f6ce3b83a10> #<Tag:0x00007f6ce3b838a8>

(Headyman) #283

Hi
First great job and many thanks to all here.
I want to give some feedback and several questions in the end.

My hardware

  • Raspi 3
  • non FTDI Modbus USB Converter
  • SDM630 Powermeter

My software on raspi

  • openhab (latest stable)
  • influxdb + grafana

Working PC with Win10:

  • I am not using eclipse, but I read something about switching to visual sorce code as next step…?

things:

Bridge modbus:serial:modbus1 [ port="/dev/ttyUSB0", id=1, baud=9600, stopBits="1", parity="none", dataBits=8, encoding="rtu" ] 
{
    	Bridge poller inputRegisters [ start=0, length=18, refresh=60000, type="input" ] {
        	Thing data phase1Volt [ readStart="0",  readValueType="float32" ]
        	Thing data phase2Volt [ readStart="2",  readValueType="float32" ]
		Thing data phase3Volt [ readStart="4",  readValueType="float32" ]
		Thing data phase1Amps [ readStart="6",  readValueType="float32" ]
        	Thing data phase2Amps [ readStart="8",  readValueType="float32" ]
		Thing data phase3Amps [ readStart="10", readValueType="float32" ]
		Thing data phase1Power [ readStart="12", readValueType="float32" ]
        	Thing data phase2Power [ readStart="14", readValueType="float32" ]
		Thing data phase3Power [ readStart="16", readValueType="float32" ]
	}
	Bridge poller inputRegisters2 [ start=48, length=12, refresh=60000, type="input" ] {
        	Thing data sumAmps [ readStart="48", readValueType="float32" ]
		//Thing data xxx [ readStart="50", readValueType="float32" ]
		Thing data totalPower [ readStart="52", readValueType="float32" ]
		//Thing data xxx [ readStart="54", readValueType="float32" ]
		Thing data totalVA [ readStart="56", readValueType="float32" ]
		//Thing data xxx [ readStart="58", readValueType="float32" ]
	}
	Bridge poller inputRegisters3 [ start=342, length=2, refresh=60000, type="input" ] {
		Thing data totalKWh [ readStart="342", readValueType="float32" ]
    	}
}

I didn’t understand first the adress rules, so I run into troubles with

  • modbus-adresses, like 30049 (sumAmps) and the corresponding input read with start=48 instead of 49
  • readStart must also be start (or higher) from start-adress, I thought start means start-adress and readStart is an offset, so using first:
Bridge poller inputRegisters3 [ start=342, length=2, refresh=60000, type="input" ] {
wrong:		Thing data totalKWh [ readStart="0", readValueType="float32" ]
correct:	Thing data totalKWh [ readStart="342", readValueType="float32" ]
}

but “wrong” ends in some errors (reading negative bits…), I didn’t read carefully enough :roll_eyes:.
Now all works fine, saving several datas to influx and generating graphs with grafana.

If someone wants item or other settings, simple tell, i don’t want to spam too much with my first entry :sweat_smile:

Questions:
A) What is the difference beetween same or unique Bridge poller “names”? (look at @aco example)
B) I am using marketplace binding inside openhab (level beta) to install the two modbus bindings. How to keep them updated? How can I see which “version” I use?
C) Here are some log-Errors, I am not sure, what I can do to avoid this:


This I see a often in an hour, with polling every Minute:

2018-01-13 16:13:23.566 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 04 01 56 00 02 90 27

2018-01-13 16:13:23.569 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)

2018-01-13 16:13:23.574 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/1 error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@1a814e6 (unit id 1 & transaction 351). Serial parameters: SerialParameters@10214c8[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]

2018-01-13 16:13:23.577 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 1, throwing last error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@1a814e6 (unit id 1 & transaction 351). Serial parameters: SerialParameters@10214c8[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]

2018-01-13 16:13:23.581 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@11a50e0[slaveId=1,functionCode=READ_INPUT_REGISTERS,start=342,length=2,maxTries=3]). Will try again soon. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: IOException Error reading response (EOF) [operation ID d7066bd7-2894-4b58-9ac3-f4235a76cad0]

This I saw only once last hours:

2018-01-13 15:54:10.815 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - awaited 38 bytes, but received 16

2018-01-13 15:54:10.818 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 04 00 00 00 12 70 07

2018-01-13 15:54:10.820 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: CRC Error in received frame: 17 bytes: 01 04 24 43 6a bf 88 43 6b 76 13 43 6a 1c 64 3f 24 

2018-01-13 15:54:10.823 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/1 error: I/O exception: IOException CRC Error in received frame: 17 bytes: 01 04 24 43 6a bf 88 43 6b 76 13 43 6a 1c 64 3f 24 . Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@71949c (unit id 1 & transaction 288). Serial parameters: SerialParameters@10214c8[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]

2018-01-13 15:54:10.826 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 1, throwing last error: I/O exception: IOException CRC Error in received frame: 17 bytes: 01 04 24 43 6a bf 88 43 6b 76 13 43 6a 1c 64 3f 24 . Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@71949c (unit id 1 & transaction 288). Serial parameters: SerialParameters@10214c8[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]

2018-01-13 15:54:10.828 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 1 out of 3 failed when executing request (ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@1f2c74c[slaveId=1,functionCode=READ_INPUT_REGISTERS,start=0,length=18,maxTries=3]). Will try again soon. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: IOException CRC Error in received frame: 17 bytes: 01 04 24 43 6a bf 88 43 6b 76 13 43 6a 1c 64 3f 24  [operation ID 9cdcd858-e467-4cf4-b0f6-02a0e9139345]

2018-01-13 15:54:12.692 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 04 00 00 00 12 70 07

2018-01-13 15:54:12.694 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: Error reading response (EOF)

2018-01-13 15:54:12.696 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/1 error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@6a4820 (unit id 1 & transaction 289). Serial parameters: SerialParameters@10214c8[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]

2018-01-13 15:54:12.699 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 1, throwing last error: I/O exception: IOException Error reading response (EOF). Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@6a4820 (unit id 1 & transaction 289). Serial parameters: SerialParameters@10214c8[portName=/dev/ttyUSB0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]

2018-01-13 15:54:12.701 [WARN ] [rt.modbus.internal.ModbusManagerImpl] - Try 2 out of 3 failed when executing request (ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@1f2c74c[slaveId=1,functionCode=READ_INPUT_REGISTERS,start=0,length=18,maxTries=3]). Will try again soon. Error was I/O error, so reseting the connection. Error details: 
net.wimpi.modbus.ModbusIOException I/O exception: IOException Error reading response (EOF) [operation ID 9cdcd858-e467-4cf4-b0f6-02a0e9139345]

(Andreas) #284

I only can see the first tree things: I can’t find any error in the log (only Error logging):


(Andreas) #285

Problem Solved. I had not realized that I had to set for every poller a different name (holding1, holding2, …)


(Headyman) #286

Seems to be an answer of my first Question :grinning:, each poller needs a different name…


(Headyman) #287

Yet another question:
How do you edit your things file under full run conditions?

If I change it and save, then chaos… warnings… nothing work anymore… => restart raspi … all fine

Should I stop or unregister something before?


(Andreas) #288

I do it while the System is up and running without any issue. Not shure it‘s relevant but I use a different hardware (because of corupt sd-cards)


(Ssalonen) #289

Yes it show work, otherwise something to fix. There might be warnings etc since ongoing polls are interrupted… How does it work for you @alexopenhab?


(Ssalonen) #290

B) I am using marketplace binding inside openhab (level beta) to install the two modbus bindings. How to keep them updated? How can I see which “version” I use?

Do refer to the modbus transport and modbus binding?

Not sure if you can find out the exact versions from paper UI. At least bundle:list will print out the versions. You can filter the list to make it more easily readable: bundle:list | grep -i modbus

Regarding update, not sure… Perhaps people on this thread would know. The original thread for marketplace is here:

C) Here are some log-Errors, I am not sure, what I can do to avoid this:

Not sure either. If it is with serial devices, it might be something low level even (physical connections).

Personally would not mind too much if the operations succeed with the retries.

Hope someone more knowledgeable can help you…

EDIT: if you like, you can try the scripts similar to posted here, and try if you can reproduce any issues with those. This is more like troubleshooting where the real issue is, in the binding or the device.


(Peter) #291

works!


(Ssalonen) #292

It’s quite weird… In principle the first method should work but cannot tell for sure.

Appreciate if you try out the alternative modbus master implementations, see the above posts for python implementations with pymodbus and minimalmodbus


(Headyman) #293

openhab> bundle:list | grep -i modbus
219 │ Active │ 80 │ 2.3.0.201712240733 │ openHAB MODBUS Transport Bundle
220 │ Active │ 80 │ 2.3.0.201712240733 │ Modbus Binding

Seems to be the current version, is the same as here
https://openhab.jfrog.io/openhab/libs-pullrequest-local/org/openhab/io/org.openhab.io.transport.modbus/2.3.0-SNAPSHOT/

The actual solution works (after replacing teh first faulty SDM630 Powermeter), and i am now very happy.

I am not happy with the serial modbus-usb converter, the delivered software shows more errors and strange behaviour than I see under the actual bindings in openhab (ok it also eats up my CPU and stresses more than I do at the moment).
Maybe next time I will look for a Modbus-Wifi converter. I plan a second Powermeter far away from my current installation, and Wifi would be a better solution.


(Headyman) #294

Only for interest:

Several weeks ago, I want to test the newest bindings, but I didn’t know the way to install via marketplace binding.

I downloaded the jar file to addon and then I got java errors (several functions missing…).
After some hours of searching i found gnu.io.rxtx…jar, which resolved the missing dependencies.
One of the next updates/upgrades it was getting much worser (much more dependency issues), so I decided to look for another way and I found the marketplace binding.

I don’t know, where the problem was… openhab … apt … binding …
Since using marketplace binding (and cleaning addon-folder) it works fine.


(Nanna Agesen) #295

I have a Carlo Gavazzi Energy Analyzer that uses 64 Unit word for kWh and kW measurement.

I was under the impression that the new binding wasn’t supporting that, but I can read those Input registers using uInt32 - I’m I missing something here ? :slight_smile:


(Ssalonen) #296

Hey @Nanna_Agesen,

(u)int64 support would mean to me that there is a value type int64 and uint64. Binding would then read 4 (or more) consecutive registers, combine them, and would provide them as a ready-to-use number. Similar to float32 or int32, for example.

Now you have to combine the data yourself, and construct the number from two uint32.

It’s mostly for convenience, otherwise we could just use “uint16” for registers and do all conversions in e.g. rules.

Furthermore, writing (u)int64 would be quite advanced now, since you would have to use the “Advanced write using JSON” if you like to write it with single modbus request.

Best,
Sami


(Ssalonen) #297

rxtx means that you are missing the serial transport feature… that’s why. So that was quite expected.

If you install jars manually, you need to also install the serial feature since it is an dependency of the modbus transport.

All this will be way more simple / transparent when/if the addon gets official, and there would be no need even for the marketplace.


(Headyman) #298

@Nanna_Agesen

Reading the 64bit Value with uInt32 “works” in some cases:

  • if uInt32 reads the “lower” 32bit part of the 64bit value, and
  • if the 32bit value is lower/equal than 4294967296 (the other 32bit value is “0”)

If the kWh value is saved as “Wh” you first come in trouble with uInt32 Reading after 4294967.296 kWh.

Powering 120kW (3*100A @ 400V) constant to this PowerMeter all over the time, you will reach this value after about 4 years and costs you > 1Mill. € (at 0.30€/kWh) :crazy_face:.


(Headyman) #299

Carlo Gavazzi Energy Analyzer was also a choice for me, but i didn’t found a retailer with fast order.
My B+G E-Tech SDM630Modbus was available via Amazon.
It uses float32 for all values, quite simple …

Nevertheless the first Power Meter was broken, with 32A constant current :open_mouth: on L2 and L3 even if all fuses were off…


(Nanna Agesen) #301

Hi @ssalonen

Thanks for your explanation.

i’m I correct that in some of your first versions of the binding, I would receive an error if I tried to read an Uint64 word?


(Nanna Agesen) #302

@alexopenhab

I’m a Carlo Gavazzi retailer so it was my first choice :slight_smile:


(Ssalonen) #303

I don’t think any error occurs. This is because at modbus protocol level there are no concepts such as int64 or even float32. There are just 16 bit registers (input and holding), 1 bit coils, and 1 bit discrete inputs.

Naturally you would get an configuration error if you try to use unknown valuetypes such “foobar” or “int64”.

So the binding can poll the data just fine. Constructing the number just needs some work as mentioned above. Arithmetic is following similar logic @alexopenhab explains above.

Best
Sami