Connecting Siemens controllers to the cloud has been difficult so far. In addition to the option of using an IoT gateway for communication, it is now also possible to establish direct communication via the MQTT protocol to transfer data to the cloud. We have tested different possibilities for you.
We are often asked if our AnyViz Cloud Adapter is also available for Siemens devices. Unfortunately, Siemens STEP 7 does not offer all the features we need to implement the cloud adapter. However, there are other ways to connect a SIMATIC PLC to AnyViz. For example, an IoT gateway with the Universal Cloud Adapter can be used for Siemens controllers. If you want to save another component and prefer a direct connection to the cloud, you have hardly had any options so far. This changes with the support of the MQTT protocol.
Since December 2017 AnyViz supports the slim and open communication protocol MQTT. In our blog post we have described pros and cons as well as the functionality. Almost at the same time a Siemens application example on the same topic was published. In addition, there is also an open source implementation on GitHub.
Comparison of existing MQTT solutions for Siemens
Siemens offers three libraries for the TIA Portal V14 to use MQTT for CPUs of the S7-300, S7-1200 or S7-1500 series. If an S7-1500 is used, the MQTT connection can also be encrypted. We tested the library on our S7-1200 CPU and were able to establish a successful connection to the AnyViz portal after only a short time. The detailed documentation has helped to the quick success. Unfortunately, the publishing of topics, i.e. the sending of variable values, is somewhat time-consuming, since this has to be done via a single function block. Unfortunately, the variable values can only be transferred as strings.
Development projects for control programmers can also be found on the GitHub online service by now. The GibHub project MQTT Siemens-S7-300 is the first of these. It is clean implemented and offers comfortable functions for Publish and Subscribe. The project can easily be ported to CPUs of the new generation. If you don’t want to do this work, take a look at the MQTT Siemens-S7-1500 project, which is based on the previous project. A Publish is done by a function call. We recommend to provide the variable value (also called “payload”) depending on the TIA version with the data type ANY or VARIANT. The value should be transmitted binary. This requires less CPU power and reduces the programming effort.
Before establishing an MQTT connection to AnyViz, you should first have a look at our documentation. Unfortunately, none of the libraries contains the function of name resolution (DNS). Therefore our broker “portal.anyviz.de” has to be resolved first, which results in the IP address “22.214.171.124”. As soon as the Siemens MQTT client appears in the AnyViz portal, the byte order should be adjusted as well as the password. Siemens uses the Big-Endian Byte-Order. If you have any further questions feel free to contact the AnyViz team.
The easy alternative
Those who avoid the effort to implement a quite complex MQTT-connection can use the free Universal Cloud Adapter. The adapter establishes a connection via Siemens TCP or OPC-UA to a SIMATIC controller and transfers the data to the cloud via an encrypted connection. The advantages compared to MQTT: