---
title: Use the PLC-Status Topic to Verify Connection Status
slug: bhdo-v2/use-the-plc-status-topic-to-verify-connection-status
createdAt: 2023-09-27T17:07:54.942Z
---

:::hint{type="info"}
**Notes**:

- You need to follow the following guidelines for topic names: [Subject-Based Messaging](https://docs.nats.io/nats-concepts/subjects).&#x20;
- 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&#x20;**&#x6E;ode.&#x20;
:::

The PLC status topic is used to verify the connection of DeviceHub devices.&#x20;

# User Scenario

You'd like to verify the connection status of a PLC to Belden Horizon Data Operations from a remote location.&#x20;

# Set up and Use the PLC-Status Topic

**To set up and use the PLC-status topic:&#x20;**

1. Follow the steps to [Connect a Device](docId\:f8KfMKcZ3LqC-Pp0XisNe). For this user scenario, a Simulator Generator device is used.&#x20;
2. Navigate to **DeviceHub**.&#x20;
3. In the Generator device tile, click th&#x65;**&#x20;Display Copy Options&#x20;**&#x69;con and select the PLC status topic. This will copy the PLC status topic. You will refer to this topic later on.&#x20;

   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/QMy8hxZv4CM5FZLn_sfsH_copy-plc-status.png" size="80" width="671" height="373" caption="Copy the PLC status topic" position="center" showCaption="true"}
4. Navigate to **Flows Manager**.&#x20;
5. For a Flows Manager, click the **Go To Flow Definition** icon.&#x20;
   The Flow canvas opens in a new browser tab.&#x20;

   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/jf1-qnDDkdTBeT6Q0snCS_go-to-flow-definitionbhdo.png" size="80" width="931" height="481" caption="Go To Flow Definition icon" position="center" showCaption="true"}
6. On the Flow canvas, drag the **Datahub Subscribe** node and **debug&#x20;**&#x6E;ode onto the canvas. Then, connect the two nodes.&#x20;

   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/rFBhmtBOhyKLZca06yEtQ_plc-status-nodes.png" size="80" width="870" height="494" caption="Nodes needed for PLC status" position="center" showCaption="true"}
7. Double-click the **DataHub Subscribe** node.
   The *Edit DataHub Subscribe node* dialog box appears.
   - In the **Topic&#x20;**&#x66;ield, paste the PLC status topic you copied in step 3.&#x20;
   - If needed, configure the Datahub Subscribe connection. See the *Step 3: Configure Connector Nodes* section in [Create a Flow](docId\:b6x9i0_DmIQn4-kz-2v-A) to learn more.&#x20;
   - Click **Done**, and then click **Deploy**.&#x20;
8. Expand the message window beneath the flow.&#x20;

   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/JX5Q6gfezPd36MMFlrwFH_message-bar.png" size="80" width="1920" height="937" caption="The message window" position="center" showCaption="true"}
9. Click the **Debug&#x20;**&#x69;con to view debug messages.&#x20;

   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/JC4cy7D-QXdzNqDI_czdP_debug-icon.png" size="80" width="1920" height="643" caption="The Debug icon" position="center" showCaption="true"}
10. Confirm the **Debug&#x20;**&#x6E;ode is activated.&#x20;

    ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/Ape1kZ4p0O1vNuxlL6wr4_activate-debug.png" size="80" width="1062" height="648" caption="The activate debug button" position="center" showCaption="true"}
11. The debug window displays a `"success": true` message, which means the device is successfully connected to Belden Horizon Data Operations. If you manually disconnected the device in Belden Horizon Data Operations, the debug window would display `"success": false`.&#x20;

    ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/k9cbCEQNSQyQzuHN7_1j2_success-true.png" size="80" width="1616" height="767" caption="Success true message" position="center" showCaption="true"}

The rest of the payload displays the following information from the device:

- **Data type**: The data type used to verify the PLC status. The bit data type displays two values: 0 for on/connected and 1 for off/disconnected.&#x20;
- **Value**: The bit value that displays the status of the device. The value 0 means the device is on/connected.&#x20;
- **Device Name**: The device name you configured in Belden Horizon Data Operations.&#x20;
- **Timestamp**: Date and time data for the PLC status message.&#x20;
- **Device ID**: The device ID for the DataHub device generated in Belden Horizon Data Operations.&#x20;
- **Description**: The default description for the PLC status topic (Poll Register).&#x20;

