Skip to main content
WinCC Explorer & S7-1500 · Practical Blog 9 of 10

S7-1500 OPC UA to MQTT: Practical Edge Gateway and WinCC Explorer Lab

Bridge S7-1500 OPC UA telemetry to MQTT with an edge gateway while WinCC Explorer remains an independent client; map quality, timestamps and stale data.

Practical result: An explicit five-tag gateway mapping with broker messages that distinguish good, stale and unavailable data.

OPC UA · MQTT · REST gateway · Updated 6 September 2026

S7-1500 OPC UA to MQTT: Practical Edge Gateway and WinCC Explorer LabS7-1500 OPC UA → Edge UA subscription → JSON / quality mapper → MQTT brokerBRIDGE OPC UA DATA TO MQTTS7-1500 OPC UAEdge UAsubscriptionJSON / qualitymapperMQTT brokerTraining architecture · verify software support and each interface independently
Original architecture diagram. It describes the training data path; it is not a tested PLC or gateway project.

Keep the two clients visible in the architecture

Use the S7-1500 as the OPC UA server. WinCC Explorer reads the controller for the operator display. A separate edge OPC UA client reads the same approved telemetry and publishes it to MQTT. The edge process is the protocol bridge; WinCC graphics do not have to perform the translation.

If a project instead uses WinCC as an OPC UA source, verify the WinCC server interface and required licensing/options for that release. That is a different source configuration from the CPU-server path demonstrated here.

Lab scope: use an isolated training CPU/network, TIA Portal compatible with its firmware and a supported WinCC Classic release where required. Check the exact CPU order number, firmware, license and installed software before following configuration steps. Examples use read-only telemetry; no example writes a motor command. The addresses, tag names and values are teaching choices.

Configure the OPC UA side of the gateway

  1. Use the endpoint and security settings already proven in the controller-server lesson.
  2. Create a gateway client identity and certificate trust appropriate to the server configuration.
  3. Use a read-only account and browse the five approved DB members.
  4. Record the actual NodeIds and namespace URIs instead of assuming the node indexes.
  5. Create monitored items at an interval suited to the lab, then capture values, status and timestamps in the gateway.
  6. Map source tags to the stable JSON fields shown below. Confirm numeric and Boolean conversions explicitly.
Source memberMQTT JSON fieldValidation
LevelPctlevel_pctNumeric, unit %
Flow_m3hflow_m3hNumeric, unit m³/h
PumpRunningpump_runningJSON Boolean
PumpFaultpump_faultJSON Boolean
SampleSeqsource_seqDetect frozen source samples

Configure publication and freshness

Publish to factory/lab/unit101/telemetry using a broker account restricted to the intended topic. Set the listener, client ID, TLS trust and delivery options. Decide how the gateway handles multiple changed values: individual records or a snapshot with explicit collection semantics.

{
  "schema": "unit101.v1",
  "source_seq": 42,
  "level_pct": 50.0,
  "flow_m3h": 12.0,
  "pump_running": true,
  "pump_fault": false,
  "quality": "good",
  "age_ms": 180
}

Define the meaning of age_ms in your gateway: for example, elapsed time since the gateway last received a valid source sample. This is different from the age of the last MQTT receipt. If the PLC data stops updating, repeated publications must not reset source age.

For the lab, choose a stale threshold of five seconds for a one-second source update and document it as an exercise setting. On bad quality or timeout, mark the sample unavailable/stale and avoid publishing a last-known value as fresh.

Implement a bounded translation loop

Use your selected gateway’s OPC UA client and MQTT publisher components, or a reviewed service with those libraries. Configure the same boundaries regardless of tool choice. The sequence below is implementation pseudocode; it is not an importable gateway flow.

on_source_sample(value, status, source_time):
    validate type and source status
    update last_valid_sample only when source is valid
    retain source timestamp/sequence separately from publish time

on_publish_tick:
    calculate source age
    build telemetry with explicit quality
    publish through the configured MQTT session
    if broker is unavailable: apply a bounded buffer/drop policy

on_reconnect:
    restore subscription and publish current quality
    never relabel buffered old data as a new source sample

Keep queue limits and retry backoff explicit. A broker outage must not consume memory indefinitely or block the PLC’s independent WinCC path. Record dropped samples when your selected policy discards data.

Verify both normal and degraded paths

  1. Compare the same level in the PLC watch table, WinCC field and MQTT subscriber.
  2. Stop only the gateway; WinCC should continue reading the CPU in this architecture.
  3. Interrupt the gateway’s source connection and verify stale/unavailable publication behavior.
  4. Interrupt only the broker connection; observe the bounded buffering/retry policy.
  5. Reconnect and confirm that old buffered samples retain their old identity/time.
  6. Restart the subscriber and inspect any retained sample before treating it as fresh.

Deliver: the node-to-field map, source-age definition, topic policy, example payload and failure-test record. Use the same data contract for the REST endpoint in the next lesson.

Official technical references

The workflows use these references for the named software/protocol features. Unit 101 data, diagrams, payloads and acceptance criteria are original training examples. Confirm release-specific settings in the matching Siemens documentation.

Connect the data to your factory screen

Use the five P&ID lessons to create the tank, pump and valve display, then apply the tested controller connection.

Factory screen learning seriesOPC UA manualDiscuss practical training
☎ Call WhatsApp ✉ Email Enquire Now