Extracting bit from modbus holding register not working

  • Platform information:
    • Hardware: Orange Pi Zero 3
    • OS: Armbian_25.5.1_Orangepizero3_bookworm_current_6.12.23_minimal.img
    • Java Runtime Environment: which java platform is used and what version: OpenJDK RE 17.0.18
    • openHAB version: 4.3.10
  • Issue of the topic: I am having a slave (Modbus RTU over TCP) slave address 2, single holding register at 4701. I am trying to read individual bits in 16 data variable. I am getting the poller online. I am also getting the data thing online. I have also confirmed that the traffic from slave is as per the expectaion However the data thing value does not change from null to zero or one when i try to change the holding register.
  • Please post configurations (if applicable):
    • Items configuration related to the issue
      • Contact SW_01_01 {channel=“modbus:data:SLV02:DI:DI0000:switch”}
        Contact SW_01_02 {channel=“modbus:data:SLV02:DI:DI0001:switch”}
        Contact SW_01_03 {channel=“modbus:data:SLV02:DI:DI0002:switch”}
        Contact SW_01_04 {channel=“modbus:data:SLV02:DI:DI0003:switch”}
        Contact SW_01_05 {channel=“modbus:data:SLV02:DI:DI0004:switch”}
        Contact SW_01_06 {channel=“modbus:data:SLV02:DI:DI0005:switch”}
        Contact SW_01_07 {channel=“modbus:data:SLV02:DI:DI0006:switch”}
        Contact SW_01_08 {channel=“modbus:data:SLV02:DI:DI0007:switch”}
        Contact SW_01_09 {channel=“modbus:data:SLV02:DI:DI0008:switch”}
        Contact SW_01_10 {channel=“modbus:data:SLV02:DI:DI0009:switch”}
        Contact SW_01_11 {channel=“modbus:data:SLV02:DI:DI0010:switch”}
        Contact SW_01_12 {channel=“modbus:data:SLV02:DI:DI0011:switch”}
        Contact SW_01_13 {channel=“modbus:data:SLV02:DI:DI0012:switch”}
        Contact SW_01_14 {channel=“modbus:data:SLV02:DI:DI0013:switch”}
        Contact SW_01_15 {channel=“modbus:data:SLV02:DI:DI0014:switch”}
        Contact SW_01_16 {channel=“modbus:data:SLV02:DI:DI0015:switch”}
    • Thing configuration related to the issue
      • Bridge modbus:tcp:SLV02 [host=“192.168.4.50”,timeBetweenTransactionsMillis=1, port=502, id=2, rtuEncoded=true]
        {
        Bridge poller DI [ start=4107, length=1, refresh=1000, type=“holding”] {
        Thing data DI0000 [ readStart=“4107.0”, readValueType=“bit” ]
        Thing data DI0001 [ readStart=“4107.1”, readValueType=“bit” ]
        Thing data DI0002 [ readStart=“4107.2”, readValueType=“bit” ]
        Thing data DI0003 [ readStart=“4107.3”, readValueType=“bit” ]
        Thing data DI0004 [ readStart=“4107.4”, readValueType=“bit” ]
        Thing data DI0005 [ readStart=“4107.5”, readValueType=“bit” ]
        Thing data DI0006 [ readStart=“4107.6”, readValueType=“bit” ]
        Thing data DI0007 [ readStart=“4107.7”, readValueType=“bit” ]
        Thing data DI0008 [ readStart=“4107.8”, readValueType=“bit” ]
        Thing data DI0009 [ readStart=“4107.9”, readValueType=“bit” ]
        Thing data DI0010 [ readStart=“4107.10”, readValueType=“bit” ]
        Thing data DI0011 [ readStart=“4107.11”, readValueType=“bit” ]
        Thing data DI0012 [ readStart=“4107.12”, readValueType=“bit” ]
        Thing data DI0013 [ readStart=“4107.13”, readValueType=“bit” ]
        Thing data DI0014 [ readStart=“4107.14”, readValueType=“bit” ]
        Thing data DI0015 [ readStart=“4107.15”, readValueType=“bit” ]
        }
        }
    • Sitemap configuration related to the issue
      • Frame{Text label=“Switches1” icon=“contact”{
        Default item= SW_01_01
        Default item= SW_01_02
        Default item= SW_01_03
        Default item= SW_01_04
        Default item= SW_01_05
        Default item= SW_01_06
        Default item= SW_01_07
        Default item= SW_01_08
        Default item= SW_01_09
        Default item= SW_01_10
        Default item= SW_01_11
        Default item= SW_01_12
        Default item= SW_01_13
        Default item= SW_01_14
        Default item= SW_01_15
        Default item= SW_01_16
        }}
    • Rules code related to the issue
    • Services configuration related to the issue
  • If logs where generated please post these here using code fences:

Log looks helathy.

Following is Modslave communication traffic when i try to simulate the slave.

005994-Rx:02 03 10 0B 00 01 F1 3B
005995-Tx:02 03 02 00 00 FC 44
005996-Rx:02 03 10 0B 00 01 F1 3B
005997-Tx:02 03 02 00 00 FC 44
005998-Rx:02 03 10 0B 00 01 F1 3B
005999-Tx:02 03 02 00 00 FC 44
006000-Rx:02 03 10 0B 00 01 F1 3B
006001-Tx:02 03 02 00 00 FC 44
006002-Rx:02 03 10 0B 00 01 F1 3B
006003-Tx:02 03 02 00 00 FC 44

Please guide as to what might be going wrong. Thanks in advance.

I have this configuration and it works:

Thing data Modbus_PoolController_Measure_pH_PumpRun “Modbus Pool Controller pH Pump Run” [ readStart=“270.0”, readValueType=“bit” ]

    //Thing data  Modbus_PoolController_Measure_Filter_PumpRun       "Modbus Pool Controller Filter Pump Run"           \[ readStart="270.1", readValueType="bit" \]

    Thing data  Modbus_PoolController_Measure_Lights_On            "Modbus Pool Controller Lights Status"             \[ readStart="270.2", readValueType="bit" \]

    Thing data  Modbus_PoolController_Measure_Rx_PumpRun           "Modbus Pool Controller RX Pump Run"               \[ readStart="270.3", readValueType="bit" \]

    //Thing data  Modbus_PoolController_Measure_HeatingRun           "Modbus Pool Controller Heating Pump Run"          \[ readStart="270.4", readValueType="bit" \]

}





items

             
    Switch      Modbus_PoolController_Measure_pH_PumpRun                "Modbus Pool Controller pH Pump Run"        (grpPool)        ["Measurement"]                  { channel="modbus:data:Modbus_PoolController:Modbus_PoolController_Measure:Modbus_PoolController_Measure_pH_PumpRun:switch"}                 
    //Switch      Modbus_PoolController_Measure_Filter_PumpRun            "Modbus Pool Controller Filter Pump Run"    (grpPool)        ["Measurement"]                  { channel="modbus:data:Modbus_PoolController:Modbus_PoolController_Measure:Modbus_PoolController_Measure_Filter_PumpRun:switch"}         
    Switch      Modbus_PoolController_Measure_Lights_On                 "Modbus Pool Controller Lights Status"      (grpPool)        ["Measurement"]                  { channel="modbus:data:Modbus_PoolController:Modbus_PoolController_Measure:Modbus_PoolController_Measure_Lights_On:switch"}        
    Switch      Modbus_PoolController_Measure_Rx_PumpRun                "Modbus Pool Controller RX Pump Run"        (grpPool)        ["Measurement"]                  { channel="modbus:data:Modbus_PoolController:Modbus_PoolController_Measure:Modbus_PoolController_Measure_Rx_PumpRun:switch"}        
    //Switch      Modbus_PoolController_Measure_HeatingRun                "Modbus Pool Controller Heating Pump Run"   (grpPool)        ["Measurement"]                  { channel="modbus:data:Modbus_PoolController:Modbus_PoolController_Measure:Modbus_PoolController_Measure_HeatingRun:switch"}         

I have no RTU encoding but wondering if timeBetweenTransactionsMillis=1 is a good idea.
I would try to increase to minimum 1000.

log:set debug org.openhab.binding.modbus then in the log find the lines for an item that doesn’t work. Also check events.log.

Common mistakes are to use a wrong data type or bad offset.

Your item mapping from contact to switch type channel looks fishy. Try with a Number first.

your observation is right. changing from switch to contact made it work. Thanks a lot.