# Writing to a global variable using an iodata out node

You can write message data to a global variable.

1. Prerequisite
2. You must create global variables in the real-time application and deploy the changes, before you can use these global variables in Node-RED.

1. Open Node-RED.
2. Add an iodata out node from the Weidmüller category to the workspace.
3. Double-click the iodata out node to open the Edit node dialogue.
4. In the Variable drop-down list, select the variable you want to write to.

5. If the desired variable is not displayed, check whether you have created that variable and deployed the changes.

6. Click Done to apply your changes.
7. To generate an input message for the iodata out node, add more nodes to the workspace and connect them to a flow.

8. 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.

9. Connect the flow that creates the input message to the input of the iodata out
10. If you want to display a message summarising the writing process, connect the output of the iodata out node to a debug node.

1. 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.

Creating a global variable

Deploying changes to the real-time application

Data types