Skip to main content
Industrial automation · Siemens S7 to MQTT

Get Siemens S7 data to MQTT and the cloud.

If your S7-1200 or S7-1500 can serve Modbus, an AppBlocks gateway polls its registers, scales the values, and publishes them to any MQTT broker, an HTTP API, Azure IoT, or AppBlocks Cloud. The gateway is a separate device next to the controller, and its logic is a flowchart your whole team can read.

What changes on the PLC

One mapping on the PLC, then the gateway does the rest.

A one-time Modbus mapping

You decide which values the PLC exposes as Modbus registers. Everything else in the program stays as it is.

Read-only unless you say so

The gateway only reads. If you choose to send setpoints back, limits are checked in the flow before anything reaches the PLC.

Secure on the way out

MQTT over TLS with QoS 0, 1, or 2, and HTTPS for API calls, so plant-side Modbus never leaves the plant.

How it works

Two steps from register map to broker.

The flow uses real block names. Open the Designer and you’ll find each one in the palette.

Step 1: Serve Modbus from the Siemens S7 controller

S7-1200 and S7-1500 CPUs can act as a Modbus TCP server with the MB_SERVER instruction in TIA Portal. You call it from a cyclic organization block and point it at a data block, and the gateway reads that block as holding registers.

S7-1200 CPUs with an RS-485 communication module can serve Modbus RTU instead. For S7-300 and S7-400, and for any CPU without a Modbus option, a Modbus protocol converter bridges the gap.

  • Modbus TCP on port 502
  • Expose only the tags you choose, as holding registers
  • The PLC program stays in charge; the gateway reads
Modbus master in the docs
PLC tag              Modbus address   Gateway variable
Tank1.Level          40001            tank_level
Pump1.Running        40002            pump_running
Line2.Speed          40003            line_speed

Step 2: Poll the registers and publish

A timer sends a Modbus Request. When the PLC answers, On Modbus Response scales the value and publishes it. If the PLC stops answering, On Modbus Timeout publishes a status topic, so your dashboard can tell zero from offline.

  • Function codes 01–06, 15, and 16
  • Fast tags every second, slow ones every minute
  • Report by exception to save cellular data
The full PLC to MQTT guide
On Time Periodevery 1 s
Modbus RequestS7-1200 192.168.0.10 · FC03 · 40001, 3 regs
On Modbus Response
Variable Set/Mathtank_level = value ÷ 10
MQTT Publishplant/tank1/level
On Modbus Timeout
MQTT Publishplant/tank1/status = offline
FAQ

Questions, answered.

Does my S7 CPU support Modbus TCP?

S7-1200 and S7-1500 CPUs do, through the MB_SERVER instruction, on recent firmware. Check your CPU and firmware version in the Siemens documentation. For S7-300 and S7-400, use a communication module or a Modbus protocol converter.

Can AppBlocks read S7 tags directly over the S7 protocol?

Not today. AppBlocks talks Modbus, so the PLC serves the data you want over Modbus first, as described above.

Is Modbus TCP secure?

Modbus has no authentication or encryption of its own, so keep the PLC-to-gateway link on the plant network. The gateway then publishes outward over MQTT with TLS or over HTTPS.

What hardware do I use for the gateway?

A Tibbo Project System device with an Ethernet port and an RS-485 module is the usual choice, in a DIN-rail enclosure. Add a 4G LTE module for sites without a network. AppBlocks also runs on Zephyr boards such as the ESP32. Supported boards.

White-glove onboarding included

Ready to connect your first device?

Start free in your browser, follow the tutorials, or book a free one-on-one session. No board yet? We’ll demonstrate everything on ours.