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
- Use the endpoint and security settings already proven in the controller-server lesson.
- Create a gateway client identity and certificate trust appropriate to the server configuration.
- Use a read-only account and browse the five approved DB members.
- Record the actual NodeIds and namespace URIs instead of assuming the node indexes.
- Create monitored items at an interval suited to the lab, then capture values, status and timestamps in the gateway.
- Map source tags to the stable JSON fields shown below. Confirm numeric and Boolean conversions explicitly.
| Source member | MQTT JSON field | Validation |
|---|---|---|
| LevelPct | level_pct | Numeric, unit % |
| Flow_m3h | flow_m3h | Numeric, unit m³/h |
| PumpRunning | pump_running | JSON Boolean |
| PumpFault | pump_fault | JSON Boolean |
| SampleSeq | source_seq | Detect 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 sampleKeep 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
- Compare the same level in the PLC watch table, WinCC field and MQTT subscriber.
- Stop only the gateway; WinCC should continue reading the CPU in this architecture.
- Interrupt the gateway’s source connection and verify stale/unavailable publication behavior.
- Interrupt only the broker connection; observe the bounded buffering/retry policy.
- Reconnect and confirm that old buffered samples retain their old identity/time.
- 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
- Siemens: S7-1500 OPC UA server configuration example
- OASIS: MQTT 3.1.1 specification
- Siemens: WinCC V7.5 OPC UA connection workflow
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