Skip to content

Siemens S7 Flux Asset

The Siemens S7 Connector is a flux asset provided by Coreflux that facilitates seamless communication between Siemens S7 PLCs (Programmable Logic Controllers) and your data hub. This guide offers a comprehensive overview of the Siemens S7 Connector, detailing its features, benefits, installation, configuration, and usage.

Introduction

What is Siemens S7?

Siemens S7 is a family of PLCs developed by Siemens for automation tasks in industrial processes. These controllers are widely used in various industries due to their reliability, flexibility, and performance.

Features and Benefits

  • Seamless Communication: Enables direct communication between Siemens S7 PLCs and your data hub.
  • Real-time Monitoring: Allows real-time monitoring of Siemens S7 PLCs.
  • Easy Integration: Simplifies the integration of Siemens S7 PLCs with your IIoT projects.
  • Configurable Parameters: Offers a range of parameters to customize the connection to your specific needs.

Prerequisites

Before you install and configure the Siemens S7 Connector, ensure you have the following prerequisites:

  • Basic understanding of the MQTT protocol.
  • Coreflux account.
  • Coreflux v1.2 or higher.
  • Coreflux MQTT Broker asset.
  • MQTT Client (e.g., MQTT Explorer).
  • Access to a Siemens S7 PLC.

Installation

Method 1: GUI

// Instructions for GUI installation

Method 2: Command-line

// Instructions for command-line installation

Configuration

To configure the Siemens S7 Connector, execute the following command:

-assetConfigSave <guid> <configuration>
  • <guid>: A unique asset id generated during installation. To retrieve the asset guid, refer to the $SYS/Coreflux/Assets topic.
  • <configuration>: The asset settings.

Parameters

MQTT Parameters

  • Port: MQTT broker port.
  • Address: MQTT broker IP Address.
  • IsAnonymous: Connect to MQTT broker as an anonymous client.
  • Username: MQTT client username.
  • Password: MQTT client password.
  • EnableTLS: Enables a secure connection between broker and client.
  • EnableDebugTopic: Enables a special topic for connection state feedback.
  • DebugTopic: Specifies the debug topic.

Siemens S7 Parameters

  • IP: Device IP address.
  • PLCRack: Device rack number, typically set to 0.
  • PLCSlot: Device slot number, often set to 1.
  • Retries: Number of reconnection attempts after a connection failure. Setting to 0 makes the asset try indefinitely.
  • RetryTimeInSeconds: Delay time between reconnection attempts.
  • RefreshTimeInMs: Refresh rate for reading/writing device variables.
  • ConnectionResource: Device IP address (this seems redundant based on the provided code; please verify).

Tags

Each tag in the configuration represents a unique connection between a MQTT topic and a Siemens S7 PLC variable. The parameters for each tag are:

  • Name: Unique Tag identifier.
  • WriteDirection: Determines the direction of data flow. Options are:
  • ToMqtt: Data flows from the Siemens S7 PLC to the MQTT broker.
  • ToDevice: Data flows from the MQTT broker to the Siemens S7 PLC.

  • MQTTTopic: Unique topic that connects to the specified “Variable” parameter.

  • MQTTQoS: Quality of service for the topic. This will be based on the MQTT quality of service levels, which typically include:
  • AtMostOnce: The message is delivered at most once, and delivery is not confirmed.
  • AtLeastOnce: The message is delivered at least once, and delivery is confirmed.
  • ExactlyOnce: The message is delivered exactly once by using a four-step handshake.

  • MQTTRetain: Determines whether the message is retained or not. Options are: true or false.

  • VariableType: Defines the type of the PLC variable. Options are:
  • BOOL: Boolean value (true or false).
  • BYTE: 8-bit unsigned integer.
  • INT: 16-bit signed integer.
  • WORD: 16-bit unsigned integer.
  • DINT: 32-bit signed integer.
  • REAL: 32-bit floating point number.
  • STRING: Sequence of characters.

  • Variable: Specifies the PLC variable to read or write. Examples include Merker address - “M0.0”, input address - “I0.0”, and more.

  • Behaviour: Defines the event for data publishing on the broker or the device. Options are:
  • TriggerOnlyDifferent: Publishes data only when there's a change in value.
  • TriggerAlways: Always publishes data regardless of value changes.

Example Configuration for Tags

"Tags": [
  {
    "Name": "ExampleTag",
    "WriteDirection": "ToMqtt",
    "MQTTTopic": "s7asset/triggerTopicDirectS7",
    "MQTTQoS": "AtLeastOnce",
    "MQTTRetain": false,
    "VariableType": "BOOL",
    "Variable": "M0.0",
    "Behaviour": "TriggerOnlyDifferent"
  }
]

PLC Rack and Slot Configuration

These two elements must align with the configuration of the running PLC. Typically, it should be PLC Rack=0 and PLC Slot=1. However, you can verify this configuration in TiaPortal: Navigate to Devices > Device Configuration > click on CPU > Project Information. In this example, it would show Rack 0, Slot 1.

Rack and Slot Configuration for different Siemens PLCs

PLC Model Rack Slot Notes
S7-300 0 2 Always like this
S7-400 Defined in project Defined in project Follow hardware configuration in Tia Portal or STEP 7
WinAC As S7-400 As S7-400 -
S7-1200 0 0 or 1 -
S7-1500 0 0 or 1 -
WinAC IE 0 0 or follow hardware configuration -

Connection Resource

By default, the client connects as a PG (the programming console). With this function, it's possible to change the connection resource type to OP or S7 Basic (a generic data transfer connection).

In the hardware configuration (Simatic Manager) of the CPU, under the “Communication” tab, you can modify, PLC-side, the connection’s distribution. Essentially, this represents a protocol resource on the PLC side.

Enabling “Connection mechanisms” in Tia Portal

Due to a series of hacking incidents targeting the Siemens Tia Portal, especially the S7–1200 and S7–1500 series, Siemens introduced a solution where the user decides if remote partners can access to read/write the internal variables of the devices they're connecting to.

For the S72MQTT Flux asset to read/write into the PLC, it's essential to activate the PUT/GET communication access. Here's how to do it:

  1. Connect to Your PLC: Connect your Tia Portal project to your target PLC and then navigate to “Local modules” and select your PLC CPU.
  2. Access Properties: Double-click on the device or go to Properties and scroll down to select “Protection & Security”.
  3. Connection Mechanisms: Open “Protection & Security” and select “Connection mechanisms”.
  4. Enable PUT/GET: Ensure the option “Permit access with PUT/GET communication from remote partner” is selected.
  5. Compile and Download: Compile and download your updated hardware configuration.

FAQ

General Questions

What is the Siemens S7 Connector Asset?

The Siemens S7 Connector Asset is a flux asset provided by Coreflux that enables seamless communication between Siemens S7 PLCs and your data hub. It allows you to monitor them in real-time and easily integrate them with your IIoT projects.

What are the prerequisites for using the Siemens S7 Connector Asset?

Before you install and configure the Siemens S7 Connector, ensure you have the following prerequisites: - Basic understanding of the MQTT protocol. - Coreflux account. - Coreflux v1.2 or higher. - Coreflux MQTT Broker asset. - MQTT Client (e.g., MQTT Explorer). - Access to a Siemens S7 PLC.

How do I install the Siemens S7 Connector Asset?

The Siemens S7 Connector Asset can be installed via GUI or command-line. Detailed installation instructions can be found in the Installation section of the Siemens S7 Connector documentation.

Configuration Questions

How do I configure the Siemens S7 Connector Asset?

To configure the Siemens S7 Connector, you need to run only one command:

-assetConfigSave <guid> <configuration>
The <guid> is a unique asset id that is generated during the installation. To retrieve the asset guid, refer to the $SYS/Coreflux/Assets topic. The <configuration> parameter is where you are able to set the asset settings. Detailed configuration instructions and an example configuration can be found in the Configuration section of the Siemens S7 Connector documentation.

What are the parameters in the configuration?

The configuration consists of three main sections: MQTTParameters, SiemensS7Parameters, and Tags. - MQTTParameters are used to configure the connection between the client and the MQTT broker. - SiemensS7Parameters are used to configure the connection between the MQTT Broker and the Siemens S7 PLC. - Tags is an array of "Tag", each containing parameters for a unique PLC variable and MQTT topic connection. A detailed explanation of all parameters can be found in the Glossary of Parameters page.

Usage Questions

How do I run the Siemens S7 Connector Asset?

To run the Siemens S7 Connector, publish the “-R” (run) command with the asset guid to $SYS/Coreflux/Cloud/Command topic:

-R <guid>
And the asset is running!

How can I visualize the data?

Using a MQTT client, it is possible to visualize the data. Detailed usage instructions can be found in the Usage section of the Siemens S7 Connector documentation.

Troubleshooting Questions

The Siemens S7 Connector Asset is not running, what should I do?

Ensure that you have correctly installed and configured the Siemens S7 Connector Asset. Check the $SYS/Coreflux/Assets topic to confirm that the asset guid is correct. If the problem persists, consult the Appendix page for additional troubleshooting tips or join our Discord community for help.

I am not receiving any data, what should I do?

Ensure that the Siemens S7 Connector Asset is running and that the MQTT client is correctly configured. Check the DebugTopic specified in the MQTTParameters section of the configuration for any connection state feedback. If the problem persists, consult the Appendix page for additional troubleshooting tips or join our Discord community for help.