How-To Guides
DeviceHub Guides

Use the Write Topic to Send Data to a PLC

3min
notes you need to follow the following guidelines for topic names subject based messaging 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 follow the steps to connect a device docid\ ish7bqhzxswtdx8vbnszb for this use case, a simulator generator device is used follow the steps to add tags docid\ xgwokqbtpevii7or82ll0 and create one tag with the following parameters name m memory register value type int64 polling interval 5 tag name enter a name for the tag address 1 copy the topic name under the raw topic column you will refer to this later click the action menu for the tag and select view write topic the write dialog box displays click the copy icon for the tag you will refer to this later navigate to flows manager for a flows manager, click the go to flow definition icon the flow canvas opens in a new browser tab on the flow canvas, drag the inject node and datahub publish node onto the canvas then, connect the two nodes 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 docid\ veyyte7xdcangglzbqya0 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 drag the datahub subscribe node and debug node to the canvas and connect them 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 docid\ veyyte7xdcangglzbqya0 to learn more click done click deploy expand the message window beneath the flow click the debug icon to view messages from the debug node click the inject node button this will insert the value (114) into the payload of the tag confirm you see the value in the debug window