You can try unsigned 32 bit integer, uint32. That spans over two 16 bit registers.
Best
Sami
You can try unsigned 32 bit integer, uint32. That spans over two 16 bit registers.
Best
Sami
Since the value type is int32, you are actually getting registers 202 and 203 combined to single signed integer. Is this what you want?
Good point regarding two serial devices, have to test it my self. Does not sound correct.
Interesting idea. Will let you know tomorrow after testing it out.
As long it shows the amount of air flow (m3/h) an integer is from 0 to 300 âmy caseâ. Nevertheless will check.
Regards
@narf27 checked the issue with two serial devices. I can reproduce it with other bindings as well, e.g. zwave. Must be an openHAB core / ESH issue. I wonder if it is reported alreadyâŠ
Best,
Sami
=)
in the end my config was correct and i was able to read the right values - i just figured out that i the comma was one place farther to the left⊠thatâs how you waste your time!
now it gets interesting. trying to write to register 5016
with the old binding we (meaing: rossko57 and you) tried different things, Modbus RTU Drexel & Weiss <> openHAB
how should i configure this with the new binding? probably the âWrite value typeâ is pretty important, but whatâs the right setting here?
cheers,
Peter
I guess you want to write 32 bit signed integers (int32)? In the new binding you can just use it, it works as expected.
Best
Sami
wow, that was easy! i tried â32bit integer, as twoâs complement (int32)â and it worked!
thank you so much for this great binding!
Hi @ssalonen,
thanks for the hint, uint32 - reading data from 2 registers works like a charm!
Very good work on the binding, thanks!
Regards
Dear @ssalonen,
I appreciate your work on implementing the OH2 binding.
Only for my understanding: Is it possible that there are contradictory statements regarding relative and absolute addressing of modbus registers at https://github.com/ssalonen/openhab2-addons/blob/modbus-openhab2-native-binding/addons/binding/org.openhab.binding.modbus/README.md? The âfull exampleâ suggests relative addresses as where there is a paragraph about âAbsolute addresses instead of relativeâ.
The only way I can get to input register values at all is using the absolute addressing method. Corresponding to the documentation of my solar inverter SMA STP 5000TL-20 the register 30535 (unsigned int 32) should return todays yield in Wh (watts per hour).
The crazy thing is, that it returns almost the correct value of 3072. The correct value would be 3215 regarding the Sunny Explorer Client Application. When I use Modbus Poll I get the correct value:
30535 = 000000
30536 = 003215
Log:
2018-01-07 21:59:49.933 [DEBUG] [nding.modbus.internal.Transformation] - Could not transform item state â3072â (of type DecimalType) to a State (tried the following types: [class org.eclipse.smarthome.core.library.types.PercentType, class org.eclipse.smarthome.core.library.types.UpDownType, class org.eclipse.smarthome.core.types.UnDefType])! Input state as string â3072â, transformed string â3072â, transformation 'defaultâ
2018-01-07 21:59:49.933 [DEBUG] [odbus.handler.ModbusDataThingHandler] - Thing modbus:data:sma:inputRegisters:daily_yield_kWh âModbus dataâ, channel modbus:data:sma:inputRegisters:daily_yield_kWh:rollershutter will not be updated since transformation was unsuccesful
_2018-01-07 21:59:51.130 [DEBUG] [nding.modbus.internal.Transformation] - transformed response is â3072â
Configuration:
Bridge modbus:tcp:sma [ host="<deleted>", port=502, id=3 ] {
Bridge poller inputRegisters [ start=30535, length=2, refresh=1000, type="input"
Thing data daily_yield_kWh [ readStart="30535", readValueType="uint32" ]
}
}
I would be glad if you could give me some advice if I am doing wrong.
Thank you in advance.
Kind regards
okay, next one!
i need 2 items.
is it possible to have 2 data things from 1 poll?
this is working:
poll:
Start = 200
Length = 2
data:
Address = 200
this is NOT working:
Start = 200
Length = 4
data1:
Address = 200
data2:
Address = 202
shouldnât i be able to read both registers (each with length 2) from with one poll?
this is probably a dumb question but iâm not getting anywhere with my trial&error methods
Yes, definitely two data items can refer to polled data. In fact, this is the purpose of these things.
From your example it unclear what value type you have, but not sure if it matters. I am not sure I understand what you are exactly trying to do.
Please note that slave can decide to answer with error, this would be visible in logs with ERROR level.
Best
Sami
The documentation uses the word relative address to mean addressing used in 1.x binding where the address was relative to polled data (0=first polled item, etc).
Absolute addressing is explained in this section: https://github.com/ssalonen/openhab2-addons/blob/modbus-openhab2-native-binding/addons/binding/org.openhab.binding.modbus/README.md
The paragraph has a case similar to yours. I believe you are polling input registers?
Please let me know if you still find it contradictory, and how to improve the docs. I am sure there is room for improvement
iâd like to read two input registers, int32
i tried to set it up like this (via paper UI, this are not my exact settings, as i donât know where to find this code âŠ)
as i said before, with length=2 for poller and only data with start=200 it works fine!
Bridge poller inputRegisters [ start=200, length=4, refresh=1000, type="input" ] {
Thing data input1 [ readStart="200", readValueType="int32" ]
Thing data input2 [ readStart="202", readValueType="int32" ]
this looks just like the example given (although with float32)
but as soon as âlengthâ of the poller thing is changed to 4 i get this:
2018-01-08 23:24:18.139 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - Last request: 01 04 00 c8 00 04 70 37
2018-01-08 23:24:18.141 [ERROR] [t.wimpi.modbus.io.ModbusRTUTransport] - failed to read: CRC Error in received frame: 0 bytes:
2018-01-08 23:24:18.144 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute try 1/1 error: I/O exception: IOException CRC Error in received frame: 0 bytes: . Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@1b56074 (unit id 1 & transaction 21863). Serial parameters: SerialParameters@891b67[portName=/dev/ttyAMA0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2018-01-08 23:24:18.147 [ERROR] [pi.modbus.io.ModbusSerialTransaction] - execute reached max tries 1, throwing last error: I/O exception: IOException CRC Error in received frame: 0 bytes: . Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@1b56074 (unit id 1 & transaction 21863). Serial parameters: SerialParameters@891b67[portName=/dev/ttyAMA0,baudRate=9600,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=none,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
2018-01-08 23:24:18.151 [ERROR] [rt.modbus.internal.ModbusManagerImpl] - Last try 3 failed when executing request (ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@126243e[slaveId=1,functionCode=READ_INPUT_REGISTERS,start=200,length=4,maxTries=3]). Aborting. Error was I/O error, so reseting the connection. Error details: net.wimpi.modbus.ModbusIOException I/O exception: IOException CRC Error in received frame: 0 bytes: [operation ID e8fa2492-384a-4b4e-b49b-249f91ced319]
2018-01-08 23:24:18.180 [ERROR] [odbus.handler.ModbusDataThingHandler] - Thing modbus:data:cc1262f7 'DW Data Read' had error on read: ModbusSlaveIOExceptionImpl null
Hi @ssalonen,
thank you for your quick reply.
I want to clarify, that I didnât mean to critizise your documentation Maybe I just donât understand modbus addressing well enought.
I think I want to poll input registers, but to be honest I assume this regarding the register number from the SMA Docu â30535â. It is also read only which would also perfectly fit to input register.
Thank you for your support!
No offence taken, sorry if I sounded rude!
In the traditional standard, [entity] numbers for those entities start with a digit, followed by a number of four digits in range 1â9,999:
âŠ
input register numbers start with a three and then span from 30001 to 39999
This translates into [entity] addresses between 0 and 9,998 in data frames.
The openHAB modbus binding uses data frame entity addresses when referring to modbus entities. That is, the entity address configured in modbus binding is passed to modbus protocol frame as-is. For example, Modbus poller thing with start=3, length=2 and type=holding will read modbus entities with the following numbers 40004 and 40005.
So 30535 address in documentation probably refers to entity number. This would correspond to entity address 534 with type="input"
.
This is my best guess at leastâŠ
Best,
Sami
The log indicates that the poll itself actually fails so the problem is certainly not in the way you have defined data
things.
In fact, I bet you would see the error even without the data
things.
When using PaperUI, you can take screenshots of the settings pages and paste them here. Are you using default settings with the serial
thing? Are all reads failing or is it failing just occasionally?
atm length is set to â2â, so i donât get errors, as soon as i set it to â4â the log is full of errors. so to me it seems that all the reads fail. (i can leave it to â4â if that could help?).
Iâm using default settings, yes. Can post screenshot later?
Thanks @narf27. Sounds bad.
Can you shutdown openhab and try to replicate with 3rd party tool, e.g. modpoll or pollmb.py
Try to replicate the read requests with these tools. Note the 1-based indexing with modpoll.
This would help to analyse whether 3rd party tools have the same issue or if the issue is in openhab.
Best
Sami
i could shutdown openhab, but i donât even know how to install either of the tools
here it says
and here i canât find anything on how to connect to a serial portâŠ
iâd be happy to test but iâm afraid without a helping hand i wonât be ablte to!
Hi @narf27,
donât forget that you have to âadd 1â when providing a length number:
registers index and (index + 1).
At least for me, that was the case not getting full register readings.