Read SQL data and write to PLC

Hi,

I would like to read a value in SQL server and write it to a Rockwell PLC.
With "Inject" node it was possible to write, now I would like to reade (SQL) an write to PLC.
Thanks.

Put a SQL Node (I recommend node-red-contrib-mssql-plus) between the inject and the and the PLC node.

Use a change node or function node to format the SQL data into the correct payload format.

Hi,

Thank you Steve-Mcl, I tried to reproduce what you said but I think I did some wrong configuration in the change node.

[
    {
        "id": "e441ea33b0e8edbf",
        "type": "tab",
        "label": "DnA_Prediction",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "c34001de6df9fa2b",
        "type": "eth-ip out",
        "z": "e441ea33b0e8edbf",
        "endpoint": "31600212ce3ff55f",
        "variable": "TesteDnA",
        "program": "",
        "name": "TesteDnA1",
        "x": 310,
        "y": 240,
        "wires": []
    },
    {
        "id": "e46b4da53d6e058b",
        "type": "MSSQL",
        "z": "e441ea33b0e8edbf",
        "mssqlCN": "30fec03c812ee923",
        "name": "DnA_SP",
        "query": "SELECT TOP 1  Afinagem         \nFROM [DnA].[dbo].[Banco_Secador_SP]",
        "outField": "payload",
        "x": 260,
        "y": 360,
        "wires": [
            [
                "a96578912e68c0cb"
            ]
        ]
    },
    {
        "id": "e4f47ce9a8bfe538",
        "type": "debug",
        "z": "e441ea33b0e8edbf",
        "name": "debug 8",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 220,
        "y": 620,
        "wires": []
    },
    {
        "id": "a96578912e68c0cb",
        "type": "change",
        "z": "e441ea33b0e8edbf",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "payload[0].Afinagem",
                "fromt": "str",
                "to": "",
                "tot": "num"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 230,
        "y": 480,
        "wires": [
            [
                "e4f47ce9a8bfe538"
            ]
        ]
    },
    {
        "id": "79d3c146a55e631f",
        "type": "inject",
        "z": "e441ea33b0e8edbf",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "SELECT TOP 1  Afinagem          FROM [DnA].[dbo].[Banco_Secador_SP]",
        "payloadType": "str",
        "x": 90,
        "y": 300,
        "wires": [
            [
                "e46b4da53d6e058b"
            ]
        ]
    },
    {
        "id": "31600212ce3ff55f",
        "type": "eth-ip endpoint",
        "z": "e441ea33b0e8edbf",
        "address": "192.168.155.28",
        "slot": "0",
        "cycletime": "5000",
        "name": "TesteDna",
        "vartable": {
            "": {
                "TesteDnA": {
                    "type": "REAL"
                }
            }
        }
    },
    {
        "id": "30fec03c812ee923",
        "type": "MSSQL-CN",
        "name": "Dryer_DnA_SP",
        "server": "KPISERVER\\SSA",
        "encyption": false,
        "database": "Dna"
    }
]

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.