Sending modbus bit

Hi,

I have modbus control for power that works because bit 0, but if I want to control fan speed I have to use bit 12-15. Can you help me on how to do it?

thanks

[
    {
        "id": "bced3dc5da31bb7a",
        "type": "debug",
        "z": "0de2fcb7c52ddc84",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1210,
        "y": 320,
        "wires": []
    },
    {
        "id": "d52474f17c2c94cd",
        "type": "modbus-write",
        "z": "0de2fcb7c52ddc84",
        "name": "power 2000",
        "showStatusActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "unitid": "1",
        "dataType": "HoldingRegister",
        "adr": "2000",
        "quantity": "1",
        "server": "31b3b9976cf2bddc",
        "emptyMsgOnFail": false,
        "keepMsgProperties": false,
        "delayOnStart": false,
        "startDelayTime": "",
        "x": 1030,
        "y": 340,
        "wires": [
            [
                "bced3dc5da31bb7a"
            ],
            []
        ]
    },
    {
        "id": "1105add276c6b266",
        "type": "inject",
        "z": "0de2fcb7c52ddc84",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 850,
        "y": 360,
        "wires": [
            [
                "d52474f17c2c94cd"
            ]
        ]
    },
    {
        "id": "a59a858968ea6b25",
        "type": "inject",
        "z": "0de2fcb7c52ddc84",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 850,
        "y": 320,
        "wires": [
            [
                "d52474f17c2c94cd"
            ]
        ]
    },
    {
        "id": "31b3b9976cf2bddc",
        "type": "modbus-client",
        "name": "MODBUS",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "queueLogEnabled": false,
        "failureLogEnabled": true,
        "tcpHost": "192.168.28.202",
        "tcpPort": "10502",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "serialAsciiResponseStartDelimiter": "0x3A",
        "unit_id": "1",
        "commandDelay": "1",
        "clientTimeout": "1000",
        "reconnectOnTimeout": false,
        "reconnectTimeout": "2000",
        "parallelUnitIdsAllowed": true,
        "showErrors": false,
        "showWarnings": true,
        "showLogs": true
    }
]

You will need to read the value, mask the bit on/off and send the full WORD value back

To mask the bits on/off, use a function node. e.g: Node-red-contrib-remote-io, digital output for joining bool to word - #2 by Steve-Mcl

Alternatively, use the buffer-maker and buffer-parser nodes to conver your data to/from BOOLS in the node-red-contrib-buffer-parser package.