Writing to a global variable using an iodata out node
You can write message data to a global variable.
- Prerequisite
- You must create global variables in the real-time application and deploy the changes, before you can use these global variables in Node-RED.
- Open Node-RED.
- Add an iodata out node from the Weidmüller category to the workspace.
- Double-click the iodata out node to open the Edit node dialogue.
- In the Variable drop-down list, select the variable you want to write to.

If the desired variable is not displayed, check whether you have created that variable and deployed the changes.
- Click Done to apply your changes.
- To generate an input message for the iodata out node, add more nodes to the workspace and connect them to a flow.
The payload of the input message must be a JSON object of the format:
{ "value" : "1" }, with"1"being a place holder for the number you want to write to the variable.- Connect the flow that creates the input message to the input of the iodata out
- If you want to display a message summarising the writing process, connect the output of the iodata out node to a debug node.
- After deploying the flow, the iodata out node is triggered whenever it receives a message at its input.

If the error message setting value failed is displayed, check whether the value matches the data type of the variable you want to write to.