Hi everyone! I’m new in the forum.
A few weeks ago I bought a raspberry and OH installer. I’m testing with modbus rtu and a 16-input module.
I have a problem when I want to configure the read data.
I have managed to read one bit but my intention is to read 2 bytes.
When I configure modbus.data to read “Read Value Type int16” I get this error: Thing modbus: data: 5b885192e4: 68781dccb5 invalid readValueType: Only readValueType = ‘bit’ (or undefined) supported with coils or discrete inputs. Value type was: int16
I am attaching my confinguration and the manual for the 16-input module.
Define your Bridge for the physical pathway (mine is via a TCP gateway, yours is real serial)
Define your poller for what you want to read from the device.
I chose to read a block of discrete bits, because that’s what the device offers us.
Define your data Things for how to interpret parts of that block.
But remember - they are discrete bits here - they simply are not 16-bit numbers.
So my data Things treat them as bits.
I then go on to link these data Things to Contact Item types in my case, Switch Items are commonly used too. If you must have them as a Number, link your bit data Thing to a Number type Item - I think you’ll get 0/1.
But the point is that you got what you asked for - 16 individual bits, not bytes.
No idea why you want to do that, but the binding will not combine ‘discrete’ bits for you.
Link bits to 16 Items and combine in a rule.
Hi Rossko57! Thank you very much for your comment.
The reason why I want to do it is because the logic of the program is not done in Openhab. I want to have an integer variable to send to another device.
I understand what it says, but I don’t know where I can choose the option to read individual 16 bits.
I can create modbus data for each bit but I have 6 16-input devices and I can go crazy.
Also, all things I create through the interface (not code).
Well, I’ve shown you mine. You link 16 data Things to 16 openHAB Items. Then in a rule, you can combine 8 or 16 at a time to generate an integer or two. You’d need to think about just when to run the rule carefully; otherwise you’ll get some bits from one poll cycle and some from another, not all the Items update at the same instant.
Because this is all external to openHAB, it might be easier overall to have some little external python script or some such use a Modbus library to read-poll and access the bytes at the raw protocol level, for forwarding to wherever.
It’s unfortunate the Wellpro doesn’t provide an image of its binary inputs in a 16-bit register, like more sophisticated devices sometimes do.
Yes, a physical gateway with hardwired ethernet and RS485. There are WiFi versions available. The gateway firmware converts Modbus-TCP to/from Modbus-RTU, so the serial slave “looks like” a TCP slave to openHAB.
Actually I’ve several such gateways scattered around a large warehouse building, each serving two or three modbus devices.
This example is the exact opposite of what you’re trying to do, but the rule technique building a register from bits might be of use.