|
| 1 | +## **Introduction: Bridging the Gap Between OT and IT** |
| 2 | + |
| 3 | +In the wave of Industry 4.0, seamlessly integrating real-time device data from the OT (Operational Technology) layer with cloud applications in the IT (Information Technology) layer is key to unlocking data potential and achieving smart manufacturing. The Siemens S7-1200 PLC, a cornerstone of industrial automation, contains a vast amount of production status and equipment parameter data. Efficiently and reliably transmitting this valuable OT data to an [MQTT Broker](https://www.emqx.com/en/blog/the-ultimate-guide-to-mqtt-broker-comparison) for use by MES, SCADA, or cloud-based AI analytics platforms is a common challenge for many enterprises. |
| 4 | + |
| 5 | +Traditional solutions often involve complex programming and protocol conversion, which are both time-consuming and labor-intensive. Now, with the powerful industrial edge gateway software, NeuronEX, you can easily build a stable data bridge from a Siemens S7-1200 PLC to MQTT in under 10 minutes, all in a no-code fashion. |
| 6 | + |
| 7 | +This article will provide a step-by-step guide to walk you through the entire configuration process, from PLC setup to successfully viewing data in an [MQTT client](https://www.emqx.com/en/blog/mqtt-client-tools). |
| 8 | + |
| 9 | +## **Architecture** |
| 10 | + |
| 11 | +This tutorial aims to read specified variable data from a Siemens S7-1200 PLC, send the data in JSON format to a designated MQTT Broker, and verify the data using the [MQTTX](https://mqttx.app/) client software. The technical architecture consists of three core components: |
| 12 | + |
| 13 | +- **Data Source:** Siemens S7-1200 PLC |
| 14 | +- **Data Collection Software:** NeuronEX |
| 15 | +- **Data Destination:** EMQX (this article uses the public broker `broker.emqx.io` as an example) |
| 16 | +- **MQTT Client Tool:** MQTTX |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +## **Prerequisites** |
| 21 | + |
| 22 | +Before you begin, please ensure you have the following: |
| 23 | + |
| 24 | +- A Siemens S7-1200 PLC and TIA Portal programming software. |
| 25 | + |
| 26 | +- NeuronEX: Quickly deploy it via Docker with a single command. |
| 27 | + |
| 28 | + ```shell |
| 29 | + # Start NeuronEX |
| 30 | + docker run -d --name neuronex -p 8085:8085 --log-opt max-size=100m --privileged=true emqx/neuronex:latest |
| 31 | + ``` |
| 32 | + |
| 33 | +- An MQTT Client: We will use [MQTTX](https://mqttx.app/) to verify the data later. |
| 34 | + |
| 35 | +## Connecting Siemens S7-1200 PLC to MQTT |
| 36 | + |
| 37 | +### **Step 1: Configure Siemens S7-1200 PLC** |
| 38 | + |
| 39 | +To allow NeuronEX to access PLC data, ensure that the network between NeuronEX and the S7-1200 is clear. We will use NeuronEX to collect data from the Data Block (DB2) and M area of the Siemens S7-1200. The tags to be collected from the data block (DB2) are shown in the red box in the figure below: |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +### **Step 2: Add a Southbound Device in NeuronEX** |
| 44 | + |
| 45 | +Now, let's tell NeuronEX where to read the data from. |
| 46 | + |
| 47 | +1. Access the NeuronEX management interface at `http://localhost:8085` |
| 48 | +2. Navigate to **Data Collection** -> **South Devices** and click **Add Device**. Select the **Siemens S7 ISOTCP** plugin. |
| 49 | +3. Fill in the device information: |
| 50 | + - **Name:** `S7-1200-Workshop` |
| 51 | + - **Target PLC IP Address:** Enter the IP address of your PLC. |
| 52 | + - Leave the other parameters at their default values. |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +### **Step 3: Create Data Tags** |
| 57 | + |
| 58 | +This is the core step where you define "what data to collect". |
| 59 | + |
| 60 | +1. Click on the newly created `S7-1200-Workshop` driver to enter the **Group List** page and create a collection group named `group1`. |
| 61 | +2. Enter the group and start to **Add Tag**. Add the following tags precisely according to the addresses in your PLC: |
| 62 | + |
| 63 | +| Data Type | PLC Address Example | NeuronEX Configuration | Address Format Description | |
| 64 | +| :-------- | :------------------ | :----------------------------------------- | :------------------------------------------ | |
| 65 | +| **Bool** | `M10.0` | **Type**: `BIT`, **Address**: `M10.0` | M area, bit 0 of byte 10. | |
| 66 | +| **Int** | `MW20` | **Type**: `INT16`, **Address**: `MW20` | M area, word starting at address 20. | |
| 67 | +| **Real** | `MW30` | **Type**: `FLOAT`, **Address**: `MW30` | M area, double word starting at address 30. | |
| 68 | +| **DINT** | `DB2.DBW4` | **Type**: `INT32`, **Address**: `DB2.DBW4` | In DB2, double word starting at address 4. | |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +### **Step 4: Monitor Data Collection** |
| 73 | + |
| 74 | +After completing step 3, you can view the real-time status of the `S7-1200-Workshop` driver on the **South Devices** page. A **Connected** status indicates that the connection between NeuronEX and the S7-1200 is `connected`. |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | +You can view the real-time values of these tags on the **Data Collection** -> **Data Monitoring** page. You will see that the value of `tag4` is `-123`, which matches the value in the TIA Portal software. |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | +### **Step 5: Configure the Northbound MQTT Application** |
| 83 | + |
| 84 | +Finally, let's configure the data's destination. |
| 85 | + |
| 86 | +1. On the left menu, click **North Apps** -> **Add Application** to add a northbound MQTT application. |
| 87 | + |
| 88 | +2. Select the **MQTT** plugin and configure the connection parameters: |
| 89 | + |
| 90 | + - **Name**: `emqx` |
| 91 | + - **Server Address**: `broker.emqx.io` ([Public MQTT Broker](https://www.emqx.com/en/mqtt/public-mqtt5-broker)) |
| 92 | + - **Port**: `1883` |
| 93 | + - Leave other settings at their default values. |
| 94 | + |
| 95 | +3. Click **Create**. |
| 96 | + |
| 97 | +  |
| 98 | + |
| 99 | +4. After creating the MQTT application, click the **Add Subscription** button. |
| 100 | + |
| 101 | +  |
| 102 | + |
| 103 | +5. Add the collection group from the southbound driver `S7-1200-Workshop` to the subscription, and set the publishing [MQTT topic](https://www.emqx.com/en/blog/advanced-features-of-mqtt-topics) to `neuronex/s7-1200/data`. |
| 104 | + |
| 105 | +  |
| 106 | + |
| 107 | +### **Step 6: Subscribe and Verify Data** |
| 108 | + |
| 109 | +This is the final step to complete the data flow. |
| 110 | + |
| 111 | +1. Open your MQTTX client, create a new connection to `broker.emqx.io:1883`, and subscribe to the topic `neuronex/s7-1200/data`. |
| 112 | +2. You will immediately see the PLC data collected by NeuronEX being continuously pushed to MQTTX in a standard JSON format! |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | +## **Conclusion** |
| 117 | + |
| 118 | +Congratulations! You have successfully connected a Siemens S7-1200 PLC to MQTT within 10 minutes using NeuronEX. The entire process requires no code and is completed through a simple web interface, establishing a stable and efficient channel for industrial data collection and cloud integration. |
| 119 | + |
| 120 | +This demonstrates the powerful capabilities of NeuronEX as a modern industrial edge gateway: it can dive into the OT layer to finely handle device protocols and data tags, and seamlessly integrate with the IT world to easily deliver data to the cloud. |
| 121 | + |
| 122 | +Download NeuronEX now to kickstart your industrial IoT journey: [Download NeuronEX](https://www.emqx.com/en/try?tab=self-managed). |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | +<section class="promotion"> |
| 127 | + <div> |
| 128 | + Talk to an Expert |
| 129 | + </div> |
| 130 | + <a href="https://www.emqx.com/en/contact?product=solutions" class="button is-gradient">Contact Us →</a> |
| 131 | +</section> |
0 commit comments