Node-RED Flow Examples
How to configure an eManager as a Modbus server?
Copy this flow and take it to Node-Red.
[
{
"id": "efba915cdfa25b76",
"type": "tab",
"label": "ModbusServer",
"disabled": false,
"info": ""
},
{
"id": "0cdb5a255240f755",
"type": "debug",
"z": "efba915cdfa25b76",
"name": "holding ",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 960,
"y": 120,
"wires": []
},
{
"id": "188d47735ef0f58c",
"type": "debug",
"z": "efba915cdfa25b76",
"name": "coils ",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 950,
"y": 160,
"wires": []
},
{
"id": "0bd35eb4359baa5e",
"type": "debug",
"z": "efba915cdfa25b76",
"name": "input ",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 950,
"y": 200,
"wires": []
},
{
"id": "57b89d91df1f2527",
"type": "debug",
"z": "efba915cdfa25b76",
"name": "discrete inputs",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 965.1166534423828,
"y": 239.11669921875,
"wires": []
},
{
"id": "5fae09ab656f9b93",
"type": "inject",
"z": "efba915cdfa25b76",
"name": "Start",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "10",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 130,
"y": 180,
"wires": [
[
"347f9549898a9ee3"
]
]
},
{
"id": "347f9549898a9ee3",
"type": "function",
"z": "efba915cdfa25b76",
"name": "Set Server Temperature Register",
"func": "\n\nmsg.payload = { \n 'value': 56, \n 'register': 'holding', \n 'address': 100 ,\n 'disableMsgOutput' : 1\n} ;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 380,
"y": 180,
"wires": [
[
"788794fffb6a16a7"
]
]
},
{
"id": "788794fffb6a16a7",
"type": "modbus-flex-server",
"z": "efba915cdfa25b76",
"name": "",
"logEnabled": true,
"serverAddress": "0.0.0.0",
"serverPort": "11502",
"responseDelay": 100,
"unitId": 1,
"delayUnit": "ms",
"coilsBufferSize": 20000,
"registersBufferSize": 20000,
"minAddress": 0,
"splitAddress": 10000,
"funcGetCoil": "function getFlexCoil(addr, unitID) {\n\tif (unitID === node.unitId && \n\t\taddr >= node.minAddress && \n\t\taddr <= node.splitAddress) { \n\n\t\treturn node.coils.readUInt8(addr * node.bufferFactor) \n\t} \n}",
"funcGetDiscreteInput": "function getFlexDiscreteInput(addr, unitID) {\n\taddr += node.splitAddress\n\tif (unitID === node.unitId && \n\t\taddr >= node.splitAddress && \n\t\taddr <= node.splitAddress * 2) { \n\n\t\treturn node.coils.readUInt8(addr * node.bufferFactor) \n\t} \n}",
"funcGetInputRegister": "function getFlexInputRegister(addr, unitID) { \n\tif (unitID === node.unitId && \n\t\taddr >= node.minAddress && \n\t\taddr <= node.splitAddress) { \n\n\t\treturn node.registers.readUInt16BE(addr * node.bufferFactor) \n\t} \n}",
"funcGetHoldingRegister": "function getFlexHoldingRegsiter(addr, unitID) { \n\tnode.log('GEtting coil')\n\taddr += node.splitAddress\n\tif (unitID === node.unitId && \n\t\taddr >= node.splitAddress && \n\t\taddr <= node.splitAddress * 2) { \n\n\t\treturn node.registers.readUInt16BE(addr * node.bufferFactor) \n\t} \n}",
"funcSetCoil": "function setFlexCoil(addr, value, unitID) { \n\tif (unitID === node.unitId && \n\t\taddr >= node.minAddress && \n\t\taddr <= node.splitAddress) { \n\n\t\tnode.coils.writeUInt8(value, addr * node.bufferFactor) \n\t} \n}",
"funcSetRegister": "function setFlexRegister(addr, value, unitID) { \n\taddr += node.splitAddress\n\tif (unitID === node.unitId && \n\t\taddr >= node.splitAddress && \n\t\taddr <= node.splitAddress * 2) { \n\n\t\tnode.registers.writeUInt16BE(value, addr * node.bufferFactor) \n\t} \n}",
"showErrors": true,
"x": 660,
"y": 180,
"wires": [
[
"0cdb5a255240f755"
],
[
"188d47735ef0f58c"
],
[
"0bd35eb4359baa5e"
],
[
"57b89d91df1f2527"
],
[]
]
}
]