|
| 1 | +In the Industrial Internet of Things (IIoT), bidirectional data flow is key to enabling smart manufacturing. Beyond collecting data from devices, many scenarios now require the ability to send commands back for control and automation. |
| 2 | + |
| 3 | +NeuronEX is a real-time data acquisition and analytics software deployed at the industrial edge. It supports a wide range of industrial protocols for efficient data collection, filtering, and edge processing. More importantly, it offers flexible device control capabilities, allowing commands to be sent back to devices for closed-loop control in diverse industrial applications. |
| 4 | + |
| 5 | +This article explores NeuronEX’s device control features and how they can help optimize production and enhance automation. |
| 6 | + |
| 7 | +## What is Device Control |
| 8 | + |
| 9 | +Device control refers to the process of sending commands to downstream automation devices to control device behavior or modify device parameters. NeuronEX provides multiple control methods to meet the needs of different application scenarios: |
| 10 | + |
| 11 | +- **Dashboard Control**: Human control through an intuitive user interface. |
| 12 | +- **MQTT Control**: Sending control commands to devices via [MQTT protocol](https://www.emqx.com/en/blog/the-easiest-guide-to-getting-started-with-mqtt). |
| 13 | +- **Data Processing Module Control**: Implementing intelligent control using NeuronEX's data processing engine. |
| 14 | +- **API Control**: Programmatic control through RESTful API interfaces. |
| 15 | + |
| 16 | +During the device control process, device tags must have writable attributes; otherwise, the write operation will fail. A writable attribute means that the tags configured in NeuronEX must have the write property, and the corresponding tags on the device side must also support write operations. |
| 17 | + |
| 18 | +## Dashboard Control |
| 19 | + |
| 20 | +Dashboard control is the most intuitive human-machine interaction method, suitable for operations personnel performing daily operations and temporary debugging. Access the NeuronEX Web interface, go to **Data Collection** -> **Data Monitoring** page, select the appropriate southbound device and group name, find tags with write attributes, click the Write button at the end, enter a new value in the popup dialog, and click "Submit" to complete device control. |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +## MQTT Control |
| 25 | + |
| 26 | +### Feature Introduction |
| 27 | + |
| 28 | +MQTT control allows any client program that supports the MQTT protocol to send command data to the corresponding topic on an [MQTT Broker](https://www.emqx.com/en/blog/the-ultimate-guide-to-mqtt-broker-comparison). The NeuronEX northbound MQTT plugin subscribes to this topic to receive data and sends control commands to the southbound driver node to implement device control. |
| 29 | + |
| 30 | +This method is especially effective when using EMQX to build a UNS(Unifed Name Space) in industrial scenarios. |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | +To use this method, you need to configure the northbound MQTT plugin in NeuronEX and set the **Write Request Topic** and **Write Response Topic**. At the same time, you need to configure the southbound driver node and set the tags to readable and writable status. The following example provides detailed instructions using EMQX and MQTTX (as an [MQTT client](https://www.emqx.com/en/blog/mqtt-client-tools)). |
| 35 | + |
| 36 | +### Complete MQTT Example |
| 37 | + |
| 38 | +**1) Configure Southbound D11river** |
| 39 | + |
| 40 | +Configure the ModbusTCP southbound driver **modbus1** in NeuronEX, with group name **group1**, and add three data points **tag1**, **tag2**, **tag3** (supporting read and write). The modbus1 driver reads data from a Modbus simulator. For detailed information about this step, please refer to Connecting Southbound Drivers. |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +**2) Configure Northbound MQTT Plugin** |
| 45 | + |
| 46 | +Create a new northbound MQTT plugin in NeuronEX. In the plugin configuration, you can use the default **Write Request Topic** `/neuron/HgihrB/write/req` and **Write Response Topic** `/neuron/HgihrB/write/resp` to receive MQTT control commands, as shown below. In this example, we use EMQ's public MQTT server `broker.emqx.io` as the MQTT Broker. |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +**3) EMQX Configuration** |
| 51 | + |
| 52 | +There is no need to deploy or configure EMQX separately since we are using EMQ's public MQTT server. |
| 53 | + |
| 54 | +**4) MQTTX Configuration** |
| 55 | + |
| 56 | +Add a new connection in MQTTX to connect to the public MQTT server `broker.emqx.io`. |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +Refer to the NeuronEX MQTT data control format. The JSON message structure for controlling a single data tag is as follows: |
| 61 | + |
| 62 | +- **uuid** is a unique identifier generated by NeuronEX, used to match response data when receiving control responses. |
| 63 | +- **node** is the southbound driver node name; in this example, it's `modbus1`. |
| 64 | +- **group** is the southbound driver group name; in this example, it's `group1`. |
| 65 | +- **tag** is the southbound driver tag name; in this example, it's `tag1`. |
| 66 | +- **value** is the value to be written; in this example, it's `1234`. |
| 67 | + |
| 68 | +```json |
| 69 | +{ |
| 70 | + "uuid": "cd32be1b-c8b1-3257-94af-77f847b1ed3e", |
| 71 | + "node": "modbus1", |
| 72 | + "group": "group1", |
| 73 | + "tag": "tag1", |
| 74 | + "value": 1234 |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +For more information about the NeuronEX MQTT data control format, such as multi-tag writing, please refer to [MQTT Upstream and Downstream Data Format](https://docs.emqx.com/en/neuronex/latest/configuration/north-apps/mqtt/api.html#write-tag). |
| 79 | + |
| 80 | +In MQTTX, enter the JSON message above and configure the send topic as `/neuron/HgihrB/write/req`. Click the “send” button to send the control command to the MQTT Broker. |
| 81 | + |
| 82 | +To check if the control was executed successfully, you can use MQTTX's “**+ New Subscription**” button to subscribe to the `/neuron/HgihrB/write/resp` topic and view the response data. |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | +**5) View Control Results** |
| 87 | + |
| 88 | +On the **Data Collection** -> **Data Monitoring** page in NeuronEX, you can see that the value of tag1 has been updated to 1234, indicating that the control of tag1 in the southbound driver modbus1 through the MQTT client MQTTX was successful. |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | +There’s no need to configure the southbound driver to the MQTT driver's subscription list if you only want to control devices using the MQTT driver. However, if you also want to report data from the southbound driver to the MQTT Broker via the MQTT driver, you must add the southbound driver to the MQTT driver’s subscription list. |
| 93 | + |
| 94 | +## Data Processing Module Control |
| 95 | + |
| 96 | +### Feature Introduction |
| 97 | + |
| 98 | +NeuronEX's data processing module provides powerful data analysis and processing capabilities that can automatically trigger device control based on business logic, implementing automated control and closed-loop feedback. |
| 99 | + |
| 100 | +In this example, we will use the value of tag1 collected by the NeuronEX southbound driver node modbus1 to automatically control and write to tag2 of the southbound driver node modbus1. |
| 101 | + |
| 102 | +### Usage Example |
| 103 | + |
| 104 | +**1) Send modbus1 Driver Data to the Data Processing Module** |
| 105 | + |
| 106 | +Continue using the modbus1 driver from the [Complete MQTT Example](https://emqx.atlassian.net/wiki/spaces/EMQXBC/pages/1617821733/NeuronEX+Device+Control+Best+Practices#complete-mqtt-example). As shown in the figure below, configure the driver collection group to the data processing module's subscription group. After configuration, the neuronStream in the data processing module will receive all collection data from the modbus1 driver every second. |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | +**2) Create a Rule and Test Data Inflow** |
| 111 | + |
| 112 | +To create a rule, navigate to the **Data Processing -> Rules page** and click on "Create Rule." Then, click the "Run Test" button to confirm that the data processing module is receiving collection data from the Modbus1 driver every second. This indicates that the previous configuration steps were successful. Once you have verified this, you can stop the rule test. |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | +**3) Configure Control** |
| 117 | + |
| 118 | +Edit the SQL editor on the current page and enter the following SQL statement. This SQL statement renames the value of tag1 to tag2, and the SQL data result is `{tag2: 1234}`. You can also enable rule debugging here to test and view the rule SQL output. |
| 119 | + |
| 120 | +```sql |
| 121 | +SELECT |
| 122 | + values.tag1 as tag2 |
| 123 | +FROM |
| 124 | + neuronStream |
| 125 | +``` |
| 126 | + |
| 127 | +Select the rule action as `Neuron` type and configure as follows, indicating that the SQL output data result will be written to **tag2** of the southbound driver **modbus1** collection group **group1**. |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | +After saving the rule, it automatically enters the running state. |
| 134 | + |
| 135 | +**4) View Control Results** |
| 136 | + |
| 137 | +Navigate to the **Data Collection** -> **Data Monitoring** page to verify that the value of **tag2** has been updated to `1234`. This indicates that the control of **tag2** in the southbound driver **modbus1** through the data processing module was successful. |
| 138 | + |
| 139 | +At this point, we can click the Write button for **tag1** to write a new value of `5678`, and we can see that the value of **tag2** is also updated to `5678`, indicating that the control of **tag2** in the southbound driver **modbus1** through the data processing module was successful. |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | +Using data processing module control enables the implementation of more complex control logic. This includes triggering various control operations based on different conditions, or initiating control actions based on combinations of multiple conditions, thereby facilitating the rapid development of intelligent applications in industrial settings. |
| 144 | + |
| 145 | +## API Control |
| 146 | + |
| 147 | +### Feature Introduction |
| 148 | + |
| 149 | +NeuronEX provides comprehensive RESTful API interfaces that allow third-party applications to implement device control through the HTTP protocol. This method offers high flexibility and is suitable for integration with other systems. |
| 150 | + |
| 151 | +By calling NeuronEX's RESTful API, you can read and write device tags data. For more details, please refer to the [NeuronEX API Documentation](https://docs.emqx.com/en/neuronex/latest/api/api-docs.html). |
| 152 | + |
| 153 | +### POSTMAN Control Example |
| 154 | + |
| 155 | +POSTMAN is a commonly used API testing tool that can implement device control by calling NeuronEX's RESTful API. |
| 156 | + |
| 157 | +**1) Obtain NeuronEX Token** |
| 158 | + |
| 159 | +In POSTMAN, select the POST method and call the `localhost:8085/api/login` interface. Set the request body to JSON format, enter the username and password, and click the send button to obtain the NeuronEX Token. |
| 160 | + |
| 161 | + |
| 162 | + |
| 163 | +**2) Call the Control Interface to Write Data** |
| 164 | + |
| 165 | +In POSTMAN, select the POST method and call the interface at `localhost:8085/api/neuron/write`. Set the request header for `Authorization` with the value `Bearer ${Token}`. Then, set the request body to JSON format and input the control JSON message. Finally, click the send button to execute device control. For detailed information about the `/api/neuron/write` interface, please refer to the [NeuronEX API Documentation](https://docs.emqx.com/en/neuronex/latest/api/api-docs.html#tag/rw/paths/~1api~1neuron~1write/post). |
| 166 | + |
| 167 | +```json |
| 168 | +{ |
| 169 | + "node": "modbus1", |
| 170 | + "group": "group1", |
| 171 | + "tag": "tag1", |
| 172 | + "value": 12 |
| 173 | +} |
| 174 | +``` |
| 175 | + |
| 176 | + |
| 177 | + |
| 178 | +**3) View Control Results** |
| 179 | + |
| 180 | +On the **Data Collection** -> **Data Monitoring** page in NeuronEX, you can see that the value of **tag2** has been updated to `12`, indicating that the control of **tag2** in the southbound driver **modbus1** through the API was successful. |
| 181 | + |
| 182 | + |
| 183 | + |
| 184 | +## Summary |
| 185 | + |
| 186 | +The multiple device control functions provided by NeuronEX offer powerful support for intelligent control of industrial devices. Whether it's manual operation, remote control, or automated control, all can be implemented through NeuronEX. The flexible combination of these functions can greatly enhance the intelligence level and operational efficiency of industrial production. |
| 187 | + |
| 188 | +Users can choose the most suitable control solution based on their actual needs and implement comprehensive device management and control from edge to cloud through NeuronEX. |
| 189 | + |
| 190 | +Download NeuronEX now and start your industrial digital transformation journey: [https://www.emqx.com/en/try?tab=self-managed](https://www.emqx.com/en/try?tab=self-managed) |
| 191 | + |
| 192 | +For the full features of NeuronEX, please refer to the documentation: [Product Overview | NeuronEX Documentation](https://docs.emqx.com/en/neuronex/latest/) |
| 193 | + |
| 194 | + |
| 195 | + |
| 196 | +<section class="promotion"> |
| 197 | + <div> |
| 198 | + Talk to an Expert |
| 199 | + </div> |
| 200 | + <a href="https://www.emqx.com/en/contact?product=solutions" class="button is-gradient">Contact Us →</a> |
| 201 | +</section> |
0 commit comments