Skip to content
PDF

S7 Client to cloud for visualization

This example demonstrates how to read data from an S7 demo server that provides temperature, revolutions and active digital inputs of a motor connected to an S7 PLC. The data is then visualized with the Central Data Services in the Management System.

The instructions below cover the following steps:

  • Provisioning an S7 demo server as a Docker workload
  • Deploying the provisioned Docker workload to the target node
  • Configuring the Data Services Gateway on the node
  • Configuring the Data Services Gateway in the Management System
  • Central data visualization in the Management System

Provisioning and deploying an OPC UA Server at the node

First, the S7 demo server must be deployed to the node as a Docker workload. Download the Data Services S7 demo server found under Example Applications from the Nerve Software Center. This is the Docker image that is required for provisioning the demo server as a Docker workload.

  1. Log in to the Management System. Make sure that the user has the permissions to access the Data Services.
  2. Provision a Docker workload by following Provisioning a Docker workload. This example uses s7-demo as the workload name. Use the following workload version settings:

    Setting Value
    Name Enter any name for the workload version.
    Release name Enter any release name.
    DOCKER IMAGE Select Upload to add the Docker image of the S7 demo sensor that has been downloaded before.
    DOCKER SPECIFIC INFO Select New port and enter the following settings:
    • Protocol: TCP
    • Host Port: 102
    • Container Port: 102
    Container name tttech-s7-server-demo
    Network name bridge
  3. Deploy the provisioned Docker workload by following Deploying a workload.

    Note

    Remember the node name and serial number of the target node. They are needed for the JSON configuration.

Configuring the Data Services Gateway on the node

With the S7 demo server deployed, the Gateway instance on the node must be configured next.

  1. Access the Local UI on the node. This is Nerve Device specific. Refer to the table below for device specific links to the Local UI. The initial login credentials to the Local UI can be found in the customer profile.

    Nerve Device Physical port Local UI
    MFN 100 P1 http://172.20.2.1:3333
    Kontron KBox A-150-APL LAN 1 <wanip>:3333

    To figure out the IP address of the WAN interface, refer to Finding out the IP address of the device in the Kontron KBox A-150-APL chapter of the device guide.
    Kontron KBox A-250 ETH 2 <wanip>:3333

    To figure out the IP address of the WAN interface, refer to Finding out the IP address of the device in the Kontron KBox A-250 chapter of the device guide.
    Maxtang AXWL10 LAN1 <wanip>:3333

    To figure out the IP address of the WAN interface, refer to Finding out the IP address of the device in the Maxtang AXWL10 chapter of the device guide.
    Siemens SIMATIC IPC127E X1 P1 http://172.20.2.1:3333
    Siemens SIMATIC IPC427E X1 P1 http://172.20.2.1:3333
    Supermicro SuperServer E100-9AP-IA LAN1 <wanip>:3333

    To figure out the IP address of the WAN interface, refer to Finding out the IP address of the device in the Supermicro SuperServer E100-9AP-IA chapter of the device guide.
    Supermicro SuperServer 1019D-16C-FHN13TP LAN3 http://172.20.2.1:3333
    Supermicro SuperServer 5029C-T LAN1 <wanip>:3333

    To figure out the IP address of the WAN interface, refer to Finding out the IP address of the device in the Supermicro SuperServer 5029C-T chapter of the device guide.
    Vecow SPC-5600-i5-8500 LAN 1 http://172.20.2.1:3333
    Winmate EACIL20 LAN1 <wanip>:3333

    To figure out the IP address of the WAN interface, refer to Finding out the IP address of the device in the Winmate EACIL20 chapter of the device guide.
  2. Select Data in the navigation on the left.

    !Local Data Services

  3. Select CONFIGURATION.

  4. Enter the following configuration into the configuration editor of the Gateway:

    {
    "inputs": [
        {
            "type": "S7_CLIENT",
            "name": "s7_client_on_node",
            "serverUrl": "127.0.0.1",
            "port": 102,
            "connectionType": "PG",
            "pollingInterval_ms": 1000,
            "connectors": [
                {
                    "name": "s7_demo_connector",
                    "datablocks": [
                        {
                            "name": "motor_temperature",
                            "datablock": 0,
                            "offset": 0,
                            "type": "float"
                        }
                    ],
                    "merkers": [
                        {
                            "name": "motor_revolutions",
                            "offset": 0,
                            "type": "uint32"
                        }
                    ],
                    "inputs": [
                        {
                            "name": "motor_input",
                            "offset": 0,
                            "quantity": 8,
                            "type": "bool"
                        }
                    ]
                }
            ]
        }
    ],
    "outputs": [
        {
            "name": "ms_mqtt_broker",
            "type": "MQTT_PUBLISHER",
            "serverUrl": "<MS-MQTT-BROKER>",
            "username": "<SN>",
            "password": "<SID>",
            "keepAliveInterval_s": 20,
            "qos": 1,
            "cleanSession": true,
            "sslOptions": {
                "serverAuthRequired": false
            },
            "connectors": [
                {
                    "name": "mqtt_demo_connector",
                    "topic": "<SN>/demo_s7_motor_topic_0"
                }
            ]
        }
    ],
    "connections" : [
        {
            "name" : "s7_client_to_mqtt_publisher",
            "input": { "index" : 0, "connector" : 0 },
            "output": { "index" : 0, "connector" : 0 }
        }
    ]
    }
    
  5. Select Apply to save the Gateway configuration. The Gateway will restart automatically.

    !Apply Gateway configuration

The configuration defines the S7 demo server that was deployed earlier as a data input and the MQTT broker in the Management System as a data output. The S7 client will periodically read data from the S7 demo server and publish it to the MQTT broker of the Management System. The temperature of the motor is stored in the datablock 0 with offset 0 and data type float. The number of revolutions of the motor is stored in the merker with offset 0 and data type uint32. Eight digital inputs from the demo server are also read as eight different boolean values.

A success notification pops up in the upper-right to confirm that the Gateway has accepted the configuration and everything works as expected. Select the Logs tab to view the Gateway logs for more information.

!Gateway logs

Configuring the Data Services Gateway in the Management System

In order to visualize the data collected by the S7 client, the data published to the MQTT broker in the Management System needs to be collected and stored in the database. The example configuration below connects the input of the Central Data Gateway to the MQTT broker of the Management System, and transfers data through its output into Management System TimescaleDB storage.

  1. Log in to the Management System.
  2. Select Data in the navigation on the left. Make sure that the user has the necessary permissions to access the Data Services.
  3. Select Configuration to access the Data Services UI.

    !Central Data Services

  4. Enter the following configuration into the configuration editor of the Gateway. Replace <nodename> in the configuration below with the name of the node that the Docker workload has been deployed to earlier.

    {
        "inputs": [
            {
                "name": "ms_mqtt_broker",
                "type": "MQTT_SUBSCRIBER",
                "serverUrl": "<MS-MQTT-BROKER>",
                "keepAliveInterval_s": 20,
                "qos": 1,
                "cleanSession": true,
                "connectors": [
                    {
                        "name": "demo_s7_motor_0_from_broker",
                        "topic": "<SN:<nodename>>/demo_s7_motor_topic_0",
                        "variables": [
                            {
                                "name": "motor_temperature",
                                "type": "float"
                            },
                            {
                                "name": "motor_revolutions",
                                "type": "uint32"
                            },
                            {
                                "name": "motor_input[0]",
                                "type": "bool"
                            },
                            {
                                "name": "motor_input[1]",
                                "type": "bool"
                            },
                            {
                                "name": "motor_input[2]",
                                "type": "bool"
                            },
                            {
                                "name": "motor_input[3]",
                                "type": "bool"
                            },
                            {
                                "name": "motor_input[4]",
                                "type": "bool"
                            },
                            {
                                "name": "motor_input[5]",
                                "type": "bool"
                            },
                            {
                                "name": "motor_input[6]",
                                "type": "bool"
                            },
                            {
                                "name": "motor_input[7]",
                                "type": "bool"
                            }
                        ]
                    }
                ]
            }
        ],
        "outputs": [
            {
                "name": "cloud_timescale",
                "type": "DB_TIMESCALE",
                "url": "localhost",
                "port": 5432,
                "connectors": [
                    {
                        "name": "<nodename>",
                        "dbName": "<SN:<nodename>>"
                    }
                ]
            }
        ],
        "connections": [
            {
                "name": "s7_data",
                "input": {
                    "index": 0,
                    "connector": 0
                },
                "output": {
                    "index": 0,
                    "connector": 0
                }
            }
        ]
    }
    
  5. Select Apply to save the Gateway configuration. The Gateway will restart automatically.

    !Apply Gateway configuration

A success notification pops up in the upper-right to confirm that the Gateway has accepted the configuration and everything works as expected. Select the Logs tab to view the Gateway logs for more information.

!Verify logs

To verify if data is stored in the database, select Database in the navigation on the left. Select the serial number of the node under Database and s7_data under Table. Select Preview to display the data stored in the database as a table.

!Verify database

Central data visualization in the Management System

To visualize the motor temperature data in the Management System, open the central visualization element through the Data Services UI in the Management System.

  1. Select Visualization in the navigation on the left. The Grafana UI will open.

    !Access visualization

  2. Select + > Dashboard in the navigation on the left. A box will appear.

    !Create dashboard

  3. Select Add Query in the New Panel box.

    !Add query

  4. Select the data source from the drop-down menu. The name of the data source is the name and serial number of the node, formatted as <nodename> (<serialnumber>).

    Note

    Note that multiple data sources can be selected in the Grafana instance in the Management System, depending on the number of nodes that are registered. Make sure to remember the serial number of the node that was used for workload deployment before.

    !Select data source

  5. Fill in the following query information:

    Setting Value
    FROM s7_data

    Time column: "timestamp"
    SELECT Column: motor_temperature
    Format as Time series
  6. Select the save icon in the upper-right corner to save the dashboard.

    !Save dashboard

The dashboard can be accessed from the Grafana home menu.

!Home menu access