MODBUS extract single bit from register


I’m new to openHAB2 but the fantastic community and all the tutorials helped me to set up a working system with FM20, Homematic and Modbus.
On the MODBS side I’m working with BARIX devices (R6 and X8). The X8 ist an I/O Modbus converter. I’m only using the 8 inputs of the module. The state of the inputs is stored in the read only register 1 (input state bit 0…7).

The modbus binding tutorial does not say anything about reading single bits. My X8 devices in the modbus.cfg are defined as valuetype=int8. Further down in the tutorial i found the following sentence: “valuetypes smaller than one register (less than 16 bits) actually read the whole register, and finally extract single bit from the result.”

This seems logical to me but I have no clue how to extract the single bits from my register. Or sould I set the valuetype to ‘bit’ and define a new item for every input my my X8 module and set the start parameter accordingly?

I hope someone understands, what I’m trying to write



I believe you would do something like

modbus:tcp.X8.type=input      // probably - as you mentioned read-only
modbus.tcp.X8.start=1         // or whatever
modbus.tcp.X8.length=1        // means read one 16-bit register
modbus.tcp.X8.valuetype=bit   // treat register as bits
Contact X8_DI1 "bit 0 [%s]" {modbus="X8:0"}
Contact X8_DI2 "bit 1 [%s]" {modbus="X8:1"}

Hi Rossko.

Perfect - thank you. Then my “research” went too far :-)I I’ll try it as soon as I’m home from work an let you know, if it works.


Hello Rossko, I just tried as you suggested, but without success :confused:




Contact X8_1 "bit 0" {modbus="X8:0"}
Contact X8_2 "bit 1" {modbus="X8:1"}
Contact X8_3 "bit 2" {modbus="X8:2"}

The RS-485 receive and transmit LEDs of the X8 I/O converter do not show ANY activity (I’m using a busware RUX device)
Do you have any idea, why the polling service (of a fresh out of the box openHAB2 installation) does not work?
My other MODBUS devices (coils) who don’t need polling are working fine and I see BUS activity everytime I switch a coil. So the cabling seems to be right.

the loggers do not show any errors even in DEBUG level - actually the stay empty!

  • net.wimpi.modbus
  • org.openhab.binding.modbus

I just tried the Radzio! Modbus Master Simulator and everything works perfect! The BUS activity LEDs are blinking, the BUS is polled and everything works without any problems.

TIA Matthias

Some logic error in your configuration perhaps. Is there a ‘polling service started’ log at boot time? There should be.

Bear in mind an out of the box OH2 install will have an elderly Modbus binding, that won’t support several odd things. I’m not sure about that :150 parameter for example, or bit datatype. Consider an update to 1.10

Hi Rossko57

According to the log, no polling service was started! Therefore I updated to to 1.10 Modbus and to openHAB2 2.1.0 snapshot version and now the polling works! :+1:

I willl now try to get the BARIX R6 relay unit working. I think’t I’ll have to get back to you soon.


Hello friends,
I have the same issue with latest modbus bindings (2.4)
My device has 12 DO that all DOs are controlling in one holding register, each bit is dedicated for one of DOs.
Based on the documentations, some codes like this can read individual bit from register:

Thing data input1502bit0 [ readStart="1502.0", readValueType="bit" ]

But how to write?
Any helps is appreciated.

See discussion