Use the Write Topic to Send Data to a PLC
3 min
Notes:
- When publishing structured data such as JSON, you must convert to a byte array (string) first. To do this in a flow, you can use the json node.
The Write Topic allows you to write data to a PLC device.
Video
User Scenario
In your production environment one of the sensors that a PLC uses malfunctions, causing the PLC to receive inaccurate data. While waiting for the sensor to be repaired, you input a value manually to simulate the correct sensor data.
Use the Write Topic
Complete the following steps to use the write topic based on the user scenario.
To use the Write topic:
- Name: M - Memory Register
- Value Type: int64
- Polling Interval: 5
- Tag Name: Enter a name for the tag.
- Address: 1
- Double-click the DataHub Publish node. The Edit DataHub Publish node dialog box displays.
- In the Topic field, paste the Write topic you copied previously (number 5).
- If needed, configure the Datahub Publish connection. See the Step 3: Configure Connector Nodes section in Create a Flow to learn more.
- Click Done.
- Double-click the inject node. The Edit inject node dialog box displays.
- For msg.payload, update the timestamp selection and select string.
- In the string field, enter {"value":114}. This will insert the desired value into the tag payload.
- Click Done.
- Double-click the DataHub Subscribe node. The Edit DataHub Subscribe node dialog box displays.
- In the Topic field, paste the topic name you copied previously (number 3).
- If needed, configure the Datahub Subscribe connection. See the Step 3: Configure Connector Nodes section in Create a Flow to learn more.
- Click Done.
- Click Deploy.








