Openhab with KNX: Reading Data from Modbus

I am trying to get the data of my photovoltaic- and battery-system onto my openhab (Neostore)

But I have really no clue of modbus.

I have got an PDF-File with Register-Numbers, Register-Adresses, R/W, UNIT and Range…
So p. ex.

Register Number: 40023 with Register Adress 0022 is the Battery State of Charge.

Can anyone tell me how to modify the modbus.cfg and the things/items-File to get that value?!

Thanks,
Patrick

Hi,

Please make us understand how you connect to modbus!
You say you have “Openhab with KNX”! What does that have to do with Modbus? If you connect ModBUS through KNX, then this is a different story!
For Modbus configurations, take a look here!

BR,
George

Ah sorry for that.
My whole system is KNX.

Right now I try to add in one single Device via TCP / Modbus.
The device has network and a static ip. And via this ip I want to query the data like mentioned.
The ip is pingable. But querying should be via modbus.

Maybe I am totally wrong and this wont work?

It should definitely work! Take a look at the link posted by me! The binding documentation is self explanatory (I have worked with Modbus and for me the documentation has been enough)!
For modbus specific questions check on the search sites on Modbus forums!

Well… I tried it already with that docu… but it does not work…

2017-07-24 21:11:12.159 [ERROR] [.binding.modbus.internal.ModbusSlave] - ModbusSlave (slave1): Error getting modbus data for request net.wimpi.modbus.msg.ReadInputRegistersRequest@7d2a28af. Error: Executing transaction failed (tried 3 times). Endpoint ModbusTCPSlaveEndpoint@38f1d2a7[address=xxx.xxx.xxx.xxx,port=502]. Connection: TCPMasterConnection@1383f7d8[socket=Socket[addr=/xxx.xxx.xxx.xxx,port=502,localport=48874]]
2017-07-24 21:11:15.363 [ERROR] [wimpi.modbus.io.ModbusTCPTransaction] - execute try 1/3 error: I/O exception - failed to read.. Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@228bacc (unit id 1 & transaction 721). Address: /xxx.xxx.xxx.xxx:502

I dont know if that port is correct, I dont know what type of type i have to use (coil, discrete, holding, input…

And with the lengh… I took a bet and inserted the number of items in my pdf-file. But dunno if thats correct.

The documentation of the modbus binding assumes that you know your modbus connection point (which is normal for any connections in any binding).
I don’t think I can help you if you do not know your setup, and for sure I know less than you about the setup!

We cannot tell either. Maybe a link to your mystery PDF would help us to help you get something working.

A new version 2 of Modbus binding is becoming available, you might want to decide if you will use that before putting too much effort into 1.x config.

Hey,
thanks a lot.

Here is the PDF-File - maybe someone has any idea for me.

Ok, well lets take an example to read “Total AC active power” into OpenHAB.

The documentation tells us that can be found at register number 40008.
Modbus standard tells that register numbers in the 4xxxx range are of type holding, we will need that info.

But OH Modbus binding doesn’t use register numbers, it uses addresses. The doc gives that reg number 40008 is addressed at 0007, so we’ll need that info.

Modbus registers are 16-bit units, but they might represent signed or unsigned numbers, individual bits, or taken in pairs to givea 32-bit number, etc.
The doc tells us register 40008 has a range of -32768 to +32767. That tells us this register is to be treated as a signed 16-bit integer, more info we will need.

Earlier you told us the device was TCP, we need the IP address but your document does not tell us anything about that. Earlier you said you knew this IP, so another bit of info we need.

Something we do not know is the Modbus slave device ID (this a number between 1 to 247). This is important for Modbus over serial, but for many TCP devices it is defaulted to a value of 1. Your document does not tell us anything about that, maybe another doc does, but let’s guess it is 1.

You haven’t said if you want to use the old 1.x binding version, or try the new 2.x version, buts let’s guess you are going with 1.x as you have tried it already.

http://docs.openhab.org/addons/bindings/modbus1/readme.html tells us you should edit modbus,cfg to bring all this together

poll=1000

tcp.neostore1.connection=192.168.1.99:502
tcp.neostore1.id=1
tcp.neostore1.start=7
tcp.neostore1.length=1
tcp.neostore1.type=holding
tcp.neostore1.valuetype=int16

Here we have defined a virtual Modbus slave called neostore1, mapped to part of your real device.
It is a TCP device at port 502 and with a slave ID of 1.
We will read a block holding registers at each poll starting at address 007, and the length of the block we will read is just 1.
We will interpret the register(s) as a signed 16-bit number.

Okay, so now we have to associate an OpenHAB Item with the modbus slave.

Number MyPower "My Power x 0.01kW [%d]"  {modbus="neostore1:0"}

Here we have defined a number Item that takes its value from the first element of slave neostore1.

Get that working first, and later we can work out how to transform the integer value read in units of 0.01kW (from your documentation) and scale it into decimal kW (i.e divide by 100)

2 Likes

Hey Rossko57,
thanks a lot for the long manual. But it still does not work :frowning:

I replaced the ip because I use public IPs for this stuff right now… :slight_smile:
I do not have any more documentation than that single pdf-file…:frowning:

I did everything as you wrote, and it seems to work partly. If i insert another – wrong – ip-adress the errors have one more line like error connecting…

2017-08-01 18:25:21.081 [ERROR] [wimpi.modbus.io.ModbusTCPTransaction] - execute try 2/3 error: I/O exception - failed to read.. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@7a07363 (unit id 1 & transaction 5). Address: /19x.1xx.1x.xxx:502
2017-08-01 18:25:24.145 [ERROR] [wimpi.modbus.io.ModbusTCPTransaction] - execute try 3/3 error: I/O exception - failed to read.. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@7a07363 (unit id 1 & transaction 6). Address: /19x.1xx.1x.xxx:502
2017-08-01 18:25:24.145 [ERROR] [wimpi.modbus.io.ModbusTCPTransaction] - execute reached max tries 3, throwing last error: I/O exception - failed to read.. Request: net.wimpi.modbus.msg.ReadMultipleRegistersRequest@7a07363 (unit id 1 & transaction 6). Address: /19x.1xx.1x.xxx:502
2017-08-01 18:25:24.145 [ERROR] [.binding.modbus.internal.ModbusSlave] - ModbusSlave (neostore1): Error getting modbus data for request net.wimpi.modbus.msg.ReadMultipleRegistersRequest@7a07363. Error: Executing transaction failed (tried 3 times). Endpoint ModbusTCPSlaveEndpoint@f3002e4[address=19x.1xx.1x.xxx,port=502]. Connection: TCPMasterConnection@51dcdb5a[socket=Socket[addr=/19x.1xx.1x.xxx,port=502,localport=33476]] 

So I dont have any more clue :-((. All i could do is to open up an ticket with neostore… but up to now they were not very helpful…

Anyway: If we solve this or not… If you are somewhere near me ever (germany, 61130) I owe you at least one beer and a pizza :slight_smile:

Hey ByteBandito,

I’m in the same situation. My Log-File looks exacly the same.

Did you found a solution?

I try to connect a Oekofen Heating System via Modbus.

Hey Marcell,

no… I learned that the openhab-log is always filled with strange stuff and most of it is just informational (even if it looks like an error…)

Patrick

If I recall correctly the modbus 1.x binding log messages are sometimes missing important information (version 1.x binding: 1 & 2; vs; version 2.x binding: 1 & 2)

If you still have stamina to try this out further, I welcome you to try out the version 2 of the binding: Modbus openHAB2 binding available for alpha testing .

You can also try to use 3rd party tool to poll the slave, e.g. modpoll or pollmb