### Install Node.js 6.x using NodeSource Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Raspberry-PI2-and-PI3-hints This command fetches and executes the NodeSource setup script for Node.js 6.x, preparing your system for installation. ```bash curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - ``` -------------------------------- ### Troubleshooting npm Install Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/README.md If you encounter issues during installation, try these npm install options to assist with building the package. ```bash npm install --unsafe-perm --build-from-source ``` -------------------------------- ### Install Node.js with NPM Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Raspberry-PI2-and-PI3-hints Installs Node.js globally using NPM after setting up the NodeSource repository. ```bash sudo npm install -g nodejs ``` -------------------------------- ### Install Node-RED and Modbus Module Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Raspberry-PI Install Node-RED, node-red-contrib-modbus, and node-red-node-data-generator globally using npm. The --unsafe-perm and --build-from-source flags are used during installation. ```bash sudo npm install -g node-red --unsafe-perm --build-from-source ``` ```bash sudo npm install -g node-red-contrib-modbus --unsafe-perm --build-from-source ``` ```bash sudo npm install -g node-red-node-data-generator --unsafe-perm --build-from-source ``` -------------------------------- ### Install node-red-contrib-modbus Source: https://context7.com/biancoroyal/node-red-contrib-modbus/llms.txt Install the Modbus contribution package in Node-RED. Enable debug logging by setting the DEBUG environment variable. ```bash # In the Node-RED installation directory npm install node-red-contrib-modbus # Global install npm install -g node-red-contrib-modbus # Enable debug logging DEBUG=contribModbus*,modbus-serial node-red -v ``` -------------------------------- ### Install Node-RED Modbus Globally Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/README.md Install the node-red-contrib-modbus package globally on your system using npm. ```bash npm install -g node-red-contrib-modbus@3.6.1 ``` -------------------------------- ### Install Node.js without NPM Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Raspberry-PI2-and-PI3-hints Installs Node.js using the system's package manager, suitable when NPM is not preferred or available. ```bash sudo apt-get install nodejs ``` ```bash sudo apt install nodejs ``` -------------------------------- ### Install Node-RED Modbus Package Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/README.md Use this command to install the package in your Node-RED project directory. For global installation, use the -g flag. ```bash npm install node-red-contrib-modbus ``` ```bash npm install -g node-red-contrib-modbus ``` -------------------------------- ### Install Node.js 6.9.2 using N Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Raspberry-PI2-and-PI3-hints Use this command to downgrade or install Node.js version 6.9.2 on your system using the 'n' version manager. ```bash sudo npm cache clean -f sudo npm install -g n sudo n 6.9.2 ``` -------------------------------- ### Get Modbus IO File Value Names via HTTP Source: https://context7.com/biancoroyal/node-red-contrib-modbus/llms.txt This example shows how to retrieve a list of all available IO file value names using an HTTP GET request to the Node-RED admin endpoint. It requires an authorization token. ```javascript // HTTP Admin endpoint — get all IO file value names // GET /modbus/iofile/valuenames // curl -H "Authorization: Bearer " http://localhost:1880/modbus/iofile/valuenames // Response: ["SDM630 Phase 1 line to neutral volts", "SDM630 Phase 2 ...", ...] ``` -------------------------------- ### Install Data Generator Node Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Raspberry-PI2-and-PI3-hints Installs the node-red-node-data-generator package globally. Use --unsafe-perm and --build-from-source if encountering permission or build issues. ```bash sudo npm install -g node-red-node-data-generator --unsafe-perm --build-from-source ``` -------------------------------- ### List Available Serial Ports via HTTP GET Source: https://context7.com/biancoroyal/node-red-contrib-modbus/llms.txt Retrieve a list of available serial ports on the system using the /modbus/serial/ports HTTP GET endpoint. Requires the 'serialport' optional dependency to be installed. ```bash # List all available serial ports (requires serialport optional dependency) # GET /modbus/serial/ports curl -H "Authorization: Bearer " \ http://localhost:1880/modbus/serial/ports # Response: [{ path: "/dev/ttyUSB0", manufacturer: "..." }, ...] ``` -------------------------------- ### Install Node-RED Modbus Contrib Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Raspberry-PI2-and-PI3-hints Installs the node-red-contrib-modbus package globally. Use --unsafe-perm and --build-from-source if encountering permission or build issues. ```bash sudo npm install -g node-red-contrib-modbus --unsafe-perm --build-from-source ``` -------------------------------- ### Install Node.js 6.9 LTS on Raspberry Pi Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Raspberry-PI Download, extract, and install Node.js version 6.9.2 LTS for ARMv6l architecture on a Raspberry Pi. This involves using wget, tar, cp, and reboot commands. ```bash wget https://nodejs.org/dist/v6.9.2/node-v6.9.2-linux-armv6l.tar.gz ``` ```bash tar -xvf node-v6.9.2-linux-armv6l.tar.gz ``` ```bash cd node-v6.9.2-linux-armv6l ``` ```bash sudo cp -R * /usr/local/ ``` ```bash sudo reboot ``` ```bash node -v ``` -------------------------------- ### Start Node-RED with sudo Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Port-502-on-PI-or-PC To provide a Modbus virtual server with port 502, you must start Node-RED with sudo privileges. This is because port 502 is a well-known port (0-1023) and requires elevated rights. ```bash sudo node-red ``` -------------------------------- ### Install Node.js 4.7 LTS on Raspberry Pi Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Raspberry-PI Download, extract, and install Node.js version 4.7.2 LTS for ARMv6l architecture on a Raspberry Pi. This involves using wget, tar, cp, and reboot commands. ```bash wget https://nodejs.org/dist/v4.7.2/node-v4.7.2-linux-armv6l.tar.gz ``` ```bash tar -xvf node-v4.7.2-linux-armv6l.tar.gz ``` ```bash cd node-v4.7.2-linux-armv6l ``` ```bash sudo cp -R * /usr/local/ ``` ```bash sudo reboot ``` ```bash node -v ``` -------------------------------- ### Modbus Flex Connector SERIAL Example Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/src/modbus-flex-connector.html Example of configuring the Modbus Flex Connector for a Serial connection. Specifies the serial port and baud rate. ```javascript msg.payload = { 'connectorType': 'SERIAL', 'serialPort': '/dev/USB02', 'serialBaudrate': '9600' 'unitId': 2 } return msg ``` -------------------------------- ### IO-File JSON Format Example Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/src/modbus-io-config.html Example of the JSON-IO-File format used to define Modbus registers and coils. This format is derived from CODESYS CSV export. ```json { "name": "Modbus Holding Registers", "valueAddress": "%IW0" } { "name": "iCountDummyBorder", "valueAddress": "%IW0" } { "name": "bReset", "valueAddress": "%IX8.0" } { "name": "Modbus Input Registers", "valueAddress": "%QW0" } { "name": "iBooleanSetOne", "valueAddress": "%QW4" } { "name": "bOperationActive", "valueAddress": "%QX8.0" } ``` -------------------------------- ### Modbus Flex Getter: Multiple Inputs Read Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/src/modbus-flex-getter.html Configure the node to read multiple Modbus inputs. This example reads 10 registers starting from address 0 using function code 3. ```javascript msg.payload = { value: msg.payload, 'fc': 3, 'unitid': 1, 'address': 0 , 'quantity': 10 } return msg ``` -------------------------------- ### Modbus Flex Connector TCP Example Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/src/modbus-flex-connector.html Example of how to configure the Modbus Flex Connector for a TCP connection using a function node. Sets the connector type, host, and unit ID. ```javascript msg.payload = { 'connectorType': 'TCP', 'tcpHost': '127.0.0.1', 'unitId': 2 } return msg ``` -------------------------------- ### Get IO File Value Names via HTTP GET Source: https://context7.com/biancoroyal/node-red-contrib-modbus/llms.txt Fetch a list of IO file value names using the /modbus/iofile/valuenames HTTP GET endpoint. This is useful for populating dropdowns or configuration options related to Modbus IO files. ```bash # Get IO file value names (for response filter dropdowns) # GET /modbus/iofile/valuenames curl -H "Authorization: Bearer " \ http://localhost:1880/modbus/iofile/valuenames # Response: ["Register Name 1", "Register Name 2", ...] ``` -------------------------------- ### Install Specific Version of Node-RED Modbus Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/README.md Use npm to install a specific version of the node-red-contrib-modbus package by appending the version number with an '@' symbol. ```bash npm install node-red-contrib-modbus@3.6.1 ``` -------------------------------- ### Verify Node.js Version Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Raspberry-PI2-and-PI3-hints Checks the currently installed Node.js version. Ensure it meets the required version constraints (>=4.7.0 or <=6.9.2). ```bash node -v ``` -------------------------------- ### Modbus Flex Connector TCP with Port Example Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/src/modbus-flex-connector.html Example of configuring the Modbus Flex Connector for TCP, including the port number. This allows specifying a non-default port for the Modbus TCP server. ```javascript msg.payload = { 'connectorType': 'TCP', 'tcpHost': '127.0.0.1', 'tcpPort': '10502', 'unitId': 2 } return msg ``` -------------------------------- ### Activate Modbus Debugging Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/README.md Enable detailed debugging output for node-red-contrib-modbus by setting the DEBUG environment variable when starting Node-RED. ```bash DEBUG=contribModbus*,modbus-serial node-red -v ``` ```bash DEBUG=contribModbus:{option},contribModbus:{option},... ``` -------------------------------- ### Complete Modbus Flow Example Source: https://context7.com/biancoroyal/node-red-contrib-modbus/llms.txt This JSON represents a complete Node-RED flow demonstrating a Modbus TCP client, an embedded Modbus server, automatic reading, and a write operation. It includes configurations for the client, server, read, response, inject, function, and flex-write nodes. ```json [{"id":"tcp_client","type":"modbus-client","name":"My PLC","clienttype":"tcp","bufferCommands":true,"tcpHost":"127.0.0.1","tcpPort":"14502","tcpType":"DEFAULT","unit_id":1,"commandDelay":1,"clientTimeout":1000,"reconnectOnTimeout":true,"reconnectTimeout":2000,"parallelUnitIdsAllowed":true},{"id":"embedded_server","type":"modbus-server","hostname":"0.0.0.0","serverPort":"14502","responseDelay":"50","delayUnit":"ms","coilsBufferSize":1024,"holdingBufferSize":1024,"inputBufferSize":1024,"discreteBufferSize":1024,"showErrors":true,"wires":[["dbg_holding"],[],[],[],[]]},{"id":"auto_read","type":"modbus-read","dataType":"HoldingRegister","adr":"0","quantity":"10","rate":"5","rateUnit":"s","delayOnStart":true,"startDelayTime":"2","server":"tcp_client","emptyMsgOnFail":false,"wires":[["dbg_values"],["resp_node"]]},{"id":"resp_node","type":"modbus-response","registerShowMax":"10","wires":[]},{"id":"write_trigger","type":"inject","payload":"[100,200,300,400,500,600,700,800,900,1000]","payloadType":"json","wires":[["build_write_msg"]]},{"id":"build_write_msg","type":"function","func":"msg.payload = { value: msg.payload, fc: 16, unitid: 1, address: 0, quantity: 10 };\nreturn msg;","wires":[["flex_write"]]},{"id":"flex_write","type":"modbus-flex-write","server":"tcp_client","emptyMsgOnFail":true,"keepMsgProperties":false,"wires":[["dbg_write_done"],["resp_write"]]},{"id":"resp_write","type":"modbus-response","registerShowMax":"10","wires":[]}] ``` -------------------------------- ### Custom Function Code Message Example Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/src/modbus-flex-fc.html This example demonstrates the structure of a message object used for custom Modbus function codes, including request and response argument definitions. ```javascript msg = { topic: 'customFc', from: 'Requester-Name', payload: { unitid: 1, fc: 3, requestCard:[{ name: 'Read Registers Request Definition', data: 0, offset: 0, type: 'uint16be' }], responseCard: [{ name: 'Read Registers Answer Definition', data: 0, offset: 0, type: 'uint16be' }] messageId: mbCore.getObjectId() } } ``` -------------------------------- ### HTTP Admin Endpoint: List Serial Ports Source: https://context7.com/biancoroyal/node-red-contrib-modbus/llms.txt Retrieves a list of available serial ports on the system. This endpoint requires the `serialport` optional dependency to be installed. ```APIDOC ## HTTP Admin Endpoints ```bash # List all available serial ports (requires serialport optional dependency) # GET /modbus/serial/ports curl -H "Authorization: Bearer " \ http://localhost:1880/modbus/serial/ports # Response: [{ path: "/dev/ttyUSB0", manufacturer: "..." }, ...] ``` ``` -------------------------------- ### Modbus Server Input Payload Example Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/src/modbus-server.html Demonstrates how to send a message payload to the Modbus Server node to write data to its registers. This is useful for simulating a Modbus client writing to the server. ```javascript msg.payload = { 'value': msg.payload, 'register': 'holding', 'address': 1 , 'disableMsgOutput' : 0 }; return msg; ``` -------------------------------- ### modbus-flex-fc Node Configuration Source: https://context7.com/biancoroyal/node-red-contrib-modbus/llms.txt Configuration example for the `modbus-flex-fc` node, which allows sending custom Modbus function codes with defined request and response byte-array structures. ```APIDOC ## Node: modbus-flex-fc (Custom Function Code) The `modbus-flex-fc` node sends a custom Modbus function code using a request/response byte-array definition. It is designed for vendor-specific or non-standard Modbus function codes beyond FC1–FC4 and FC5/6/15/16. ```json // Node-RED flow JSON — custom FC node { "id": "fc1", "type": "modbus-flex-fc", "name": "Custom FC 0x43", "unitid": "1", "fc": "0x43", "requestCard": "0x43 0x00 0x00", "responseCard": "0x43 ?? ??", "server": "client1", "emptyMsgOnFail": true, "wires": [["debug_custom_response"]] } ``` ``` -------------------------------- ### Continuous Offset Example in Request Map Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/extras/argumentMaps/ArgumentMaps.md Illustrates the requirement for continuous offsets within a `requestMap`. This example shows a 16-bit value at offset 0, followed by an empty byte (not described in the map), and then an 8-bit value at offset 3, which would cause a parser error due to the gap. ```json "requestMap": [ { "name": "foo", "data": 0, "offset": 0, "type": "uint16be" }, { "name": "bar", "data": 1, "offset": 3, "type": "uint8be" } ] ``` -------------------------------- ### Modbus Single Write Example Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/src/modbus-flex-write.html Use this code in a Function node to perform a single Modbus write operation. Ensure 'fc', 'unitid', 'address', and 'quantity' are correctly set. ```javascript msg.payload = { value: msg.payload, 'fc': 5, 'unitid': 1, 'address': 0 , 'quantity': 1 } return msg ``` -------------------------------- ### HTTP Admin Endpoint: Get IO File Value Names Source: https://context7.com/biancoroyal/node-red-contrib-modbus/llms.txt Fetches a list of value names for IO files. This is typically used to populate dropdowns or selection lists within the Node-RED interface. ```APIDOC ```bash # Get IO file value names (for response filter dropdowns) # GET /modbus/iofile/valuenames curl -H "Authorization: Bearer " \ http://localhost:1880/modbus/iofile/valuenames # Response: ["Register Name 1", "Register Name 2", ...] ``` ``` -------------------------------- ### Modbus Multiple Write Example Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/src/modbus-flex-write.html Use this code in a Function node to perform multiple Modbus write operations. Adjust 'fc', 'unitid', 'address', and 'quantity' as needed for your Modbus device. ```javascript msg.payload = { value: msg.payload, 'fc': 15, 'unitid': 1, 'address': 0 , 'quantity': 10 } return msg ``` -------------------------------- ### Node-RED Example Flow for Modbus Buffer Manipulation Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Buffer-swap-and-endianness This JSON represents a Node-RED flow that demonstrates reading Modbus data, extracting buffer information, and performing endianness swaps. It includes nodes for Modbus reading, function nodes for data processing, and debug nodes for output. ```json [{"id":"18ea8042.ed0f2","type":"modbus-read","z":"325a2317.7214fc","name":"Automatic Read FC3","showStatusActivities":false,"unitid":"","dataType":"HoldingRegister","adr":"200","quantity":"10","rate":"1","rateUnit":"s","server":"","x":250,"y":200,"wires":[[ "4842691f.156838" ],[ "78c57d11.312d94", "7c3a39bf.40b348", "33239b9c.7605b4", "4d64be9f.20935" ]]},{"id":"78c57d11.312d94","type":"debug","z":"325a2317.7214fc","name":"","active":false,"console":"false","complete":"true","x":450,"y":240,"wires":[]},{"id":"7c3a39bf.40b348","type":"function","z":"325a2317.7214fc","name":"extract buffer","func":"return [{ payload: msg.payload.buffer.readInt16LE(0,2)}, { payload: msg.payload.buffer.readInt16BE(0,2) }];","outputs":"2","noerr":0,"x":470,"y":280,"wires":[[ "656af465.503b3c" ],[ "656af465.503b3c" ]]},{"id":"33239b9c.7605b4","type":"modbus-response","z":"325a2317.7214fc","name":"","registerShowMax":20,"x":490,"y":160,"wires":[]},{"id":"4842691f.156838","type":"debug","z":"325a2317.7214fc","name":"","active":false,"console":"false","complete":"false","x":470,"y":120,"wires":[]},{"id":"656af465.503b3c","type":"debug","z":"325a2317.7214fc","name":"","active":false,"console":"false","complete":"false","x":650,"y":280,"wires":[]},{"id":"4d64be9f.20935","type":"function","z":"325a2317.7214fc","name":"swap buffer","func":"msg.payload.buffer.swap16()\nreturn { payload: msg.payload.buffer };","outputs":"1","noerr":0,"x":470,"y":320,"wires":[[ "6ed544fa.dcce3c" ]]},{"id":"6ed544fa.dcce3c","type":"debug","z":"325a2317.7214fc","name":"","active":false,"console":"false","complete":"false","x":650,"y":320,"wires":[]}] ``` -------------------------------- ### Configure TCP Connector (Basic) Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Modbus-Flex-Connector Use this in a function node to configure a TCP connection. Specify the host and unit ID. ```javascript msg.payload = { 'connectorType': 'TCP', 'tcpHost': '127.0.0.1', 'unitId': 2 } return msg ``` -------------------------------- ### Configure TCP Connector (with Port) Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Modbus-Flex-Connector Use this in a function node to configure a TCP connection, including a specific port. Specify the host, port, and unit ID. ```javascript msg.payload = { 'connectorType': 'TCP', 'tcpHost': '127.0.0.1', 'tcpPort': '10502', 'unitId': 2 } return msg ``` -------------------------------- ### Reboot System Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Raspberry-PI2-and-PI3-hints Reboots the Raspberry Pi system. This is often necessary after system changes or installations. ```bash sudo reboot ``` -------------------------------- ### Read 64-bit Buffer Node-RED Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Buffer-8Bit,-16Bit,-32Bit,-64Bit,-128Bit-...-reading-with-SDM630-power-meter Use the `read` method with offset 0 and length 8 to read the first 64-bit value from the buffer. ```javascript msg.payload.buffer.read...(0,8) ``` -------------------------------- ### Configure Single Modbus Sequence Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/src/modbus-flex-sequencer.html Use this code in a Function node to define a single Modbus read sequence. Specify the function code, starting address, unit ID, and quantity of registers. ```javascript msg.sequences = [ { name : "Foo", fc : 1, address : 1, unitid: 2, quantity : 6 } ] return msg; ``` -------------------------------- ### Configure Modbus Queue Monitor Source: https://context7.com/biancoroyal/node-red-contrib-modbus/llms.txt Configure the modbus-queue-info node to monitor the Modbus client's command queue depth for a specific unit ID. Set thresholds for low, high, and critical queue levels. The 'server' property must match your Modbus client configuration. ```json // Node-RED flow JSON — queue monitor for unit 1 { "id": "queue1", "type": "modbus-queue-info", "name": "PLC Queue Monitor", "topic": "queue", "unitid": "1", "queueReadIntervalTime": "1000", "lowLowLevel": 25, "lowLevel": 75, "highLevel": 150, "highHighLevel": 300, "errorOnHighLevel": false, "showStatusActivities": true, "updateOnAllQueueChanges": false, "updateOnAllUnitQueues": false, "server": "client1", "wires": [["debug_queue_state"]] } // Output when high level reached: // msg = { // payload: 1700000000000, // Date.now() // state: "high level reached", // unitid: 1, // modbusClientName: "PLC Over TCP", // highLevel: 150, // bufferCommandListLength: 165 // } ``` -------------------------------- ### Overriding Custom FC Parameters at Runtime Source: https://context7.com/biancoroyal/node-red-contrib-modbus/llms.txt Example of how to dynamically override custom Modbus function code parameters (unit ID, function code, request/response card) using an input message payload. ```APIDOC ## Override custom FC parameters at runtime via input message ```js // Override custom FC parameters at runtime via input message msg = { topic: "customFc", payload: { unitid: 1, fc: 0x43, requestCard: "0x43 0x00 0x01", responseCard: "0x43 ?? ??", from: "myNode" } } return msg // Output msg.payload: full response object from modbus-serial ``` ``` -------------------------------- ### Override Modbus Sequencer at Runtime Source: https://context7.com/biancoroyal/node-red-contrib-modbus/llms.txt This JavaScript example shows how to dynamically override the Modbus flex-sequencer's read sequence at runtime by setting the `msg.sequences` property. Each entry in the array defines a read operation. ```javascript // Override sequences at runtime via msg.sequences msg.sequences = [ { name: "Dynamic Read", unitid: 2, fc: 3, address: 100, quantity: 10 }, { name: "Input Check", unitid: 2, fc: 4, address: 0, quantity: 5 } ] return msg // Each sequence entry produces a separate output message on output 1 ``` -------------------------------- ### Read 32-bit Buffer Node-RED Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Buffer-8Bit,-16Bit,-32Bit,-64Bit,-128Bit-...-reading-with-SDM630-power-meter Use the `read` method with offset 0 and length 4 to read the first 32-bit value from the buffer. ```javascript msg.payload.buffer.read...(0,4) ``` -------------------------------- ### Node-RED Flow: Static Modbus Read (modbus-getter) Source: https://context7.com/biancoroyal/node-red-contrib-modbus/llms.txt Configures a modbus-getter node to read 10 holding registers starting from address 0 on unit ID 1. This flow is triggered by an inject node. ```json // Node-RED flow JSON — getter wired to an inject node [ { "id": "inj1", "type": "inject", "repeat": "2", "once": true, "onceDelay": "2", "payload": "", "payloadType": "date", "wires": [["getter1"]] }, { "id": "getter1", "type": "modbus-getter", "name": "Manual Getter FC3", "unitid": "1", "dataType": "HoldingRegister", "adr": "0", "quantity": "10", "server": "client1", "emptyMsgOnFail": true, "keepMsgProperties": false, "showStatusActivities": false, "showErrors": false, "wires": [["debug_values"], ["debug_response"]] } ] // Output 1 msg.payload: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] ``` -------------------------------- ### Read 8-bit Buffer Node-RED Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Buffer-8Bit,-16Bit,-32Bit,-64Bit,-128Bit-...-reading-with-SDM630-power-meter Use the `read` method with offset 0 and length 1 to read the first 8-bit value from the buffer. ```javascript msg.payload.buffer.read...(0,1) ``` -------------------------------- ### Configure Modbus Flex Sequencer Source: https://context7.com/biancoroyal/node-red-contrib-modbus/llms.txt Configure the modbus-flex-sequencer node to execute a predefined sequence of Modbus read requests. Each sequence entry specifies function code, unit ID, address, and quantity. The 'server' property must match your Modbus client configuration. ```json // Node-RED flow JSON — sequencer reading coils from two address ranges { "id": "seq1", "type": "modbus-flex-sequencer", "name": "Multi-Read Sequence", "sequences": [ { "name": "Coils 1-2", "unitid": "1", "fc": "FC1", "address": "1", "quantity": "2" }, { "name": "Coils 10-11", "unitid": "1", "fc": "FC1", "address": "10", "quantity": "2" }, { "name": "Regs 0-4", "unitid": "1", "fc": "FC3", "address": "0", "quantity": "5" } ], "server": "client1", "showErrors": true, "emptyMsgOnFail": true, "keepMsgProperties": true, "delayOnStart": true, "startDelayTime": "2", "wires": [["debug_values"], ["debug_response"]] } ``` -------------------------------- ### Configure SERIAL Connector Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Modbus-Flex-Connector Use this in a function node to configure a SERIAL connection. Specify the serial port, baud rate, and unit ID. ```javascript msg.payload = { 'connectorType': 'SERIAL', 'serialPort': '/dev/USB02', 'serialBaudrate': '9600' 'unitId': 2 } return msg ``` -------------------------------- ### Read 16-bit Buffer Node-RED Source: https://github.com/biancoroyal/node-red-contrib-modbus/wiki/Buffer-8Bit,-16Bit,-32Bit,-64Bit,-128Bit-...-reading-with-SDM630-power-meter Use the `read` method with offset 0 and length 2 to read the first 16-bit value from the buffer. ```javascript msg.payload.buffer.read...(0,2) ``` -------------------------------- ### Modbus Flex Sequencer Configuration Source: https://github.com/biancoroyal/node-red-contrib-modbus/blob/master/src/modbus-flex-sequencer.html This JavaScript code configures the Modbus Flex Sequencer node, including handling sequence definitions and resizing the editor. It pushes sequence configurations to the node's `sequences` array. ```javascript sequences: $("#node-input-sequences-container").editableList({ addItem: function (node, item, $item) { if (item) { $(".node-input-unitid", $item).val(item.unitid); $(".node-input-function", $item).val(item.fc); $(".node-input-address", $item).val(item.address); $(".node-input-quantity", $item).val(item.quantity); } }, sortable: true, removable: true, addGroup: function ($item) { var $group = $( "
" ); return $group; }, add: function ($item) { var $node = $( "
  • " ); $(".node-input-sequences-container", $item).append($node); return $node; } }); $("#node-input-sequences-container").val(JSON.stringify(node.sequences)); }, oneditresize: function (size) { var height = size.height; $('#node-input-sequences-container').css("height", (height - 145) + "px"); } }) ```