The leader in industrial automation and control solutions

A PLC in an MQTT environment connects real-time machine control with modern industrial data systems. In packaging facilities, PLCs manage cycle counts, rejects, run status, and active fault conditions. The PLC executes control logic locally while publishing production data to a central MQTT broker. Instead of constant polling, the PLC pushes updates only when values change, improving efficiency.

Once the data reaches the MQTT broker, it can be instantly distributed to multiple subscribers such as a SCADA system, cloud dashboard, or analytics platform. This publish/subscribe model allows operations personnel to gain real-time visibility into production performance, downtime events, and machine health without complex drivers or custom integrations. Because systems subscribe to data rather than request it directly from the PLC, additional dashboards or software platforms can be added later without modifying the PLC program, making the architecture scalable and flexible.

The image above is an MQTT dashboard illustrated to show a machine monitoring interface focused on both production metrics and communication health. A bar chart compares product counts across eight machines, with Machine 1 leading at approximately 9,200 units and Machine 5 trailing at around 2,100 units. A green MQTT status indicator and “No Errors” message confirm a healthy broker connection. Below, each machine displays its ON status along with individual product counts and uptime and downtime values, providing clear, real-time operational insight.

Software Required

  • Any PLC software can be used (MapleLogic used in this example)
  • EBPro (Required software for the cMT-G01X – IIoT Communication Protocol Gateway)

Hardware Required

  • Any PLC can be used (A Maple Systems PLC is being used in this example)
  • IIoT Communication Gateways (The cMT-G01X – IIoT Communication Protocol Gateway is being used in this exmaple)
  • any MQTT Broker (I’ll be using a local Mosquitto MQTT server on a PC as an example).
  • (Optionally) an MQTT client software (I’ll be using MQTT Explorer for this tutorial).

Network Diagram

Above is the network mapping used in this article. This diagram shows a local industrial network where a PLC, a Gateway HMI, and a PC are connected through a network switch on the 192.168.255.x subnet.

The PLC (192.168.255.76) communicates with the Gateway HMI (192.168.255.108) using Modbus TCP/IP, with the HMI polling the PLC for data. The Gateway HMI acts as an MQTT client in publisher mode, sending the collected PLC data to a local MQTT broker server.

The broker then stores and forwards the messages to subscribed clients. A PC (192.168.255.75) running MQTT Explorer functions as an MQTT subscriber, receiving and displaying the published data.

PLC Configuration

This section will walk you through the intial setup of a new project in MapleLogic using a Micro PLC (FB1616P0202).

Initial Setup in MapleLogic

Follow this step by step guide for getting started with a new project in MapleLogic.

Instructions: Initial Setup in MapleLogic
  1. Start a New Project in MapleLogic

    – For this example, select the PLC-FB
    – Click Next to continue to next step

    MapleLogic New Project Choosing Micro PLC
  2. Set Project Details

    – Choose the CPU Type: PLC-FB1616
    – Name the Project
    – Click OK to continue

  3. Start a New Scanned Program

    – Right click on Program
    – Select Scan under LD program
    – Name the program
    – Click OK to continue

  4. PLC Parameter Settings

    – Double click on PLC Parameter
    – Select the Ethernet tab
    – Enter the IP address
    – Click OK

    This IP address is going to bethe target address for Modbus TCP/IP communication. The gateway HMI will be polling the Micro PLC for values and it will need this IP address to do that. The Maple PLC protocol will be used. These steps will be covered in this article.

    MapleLogic PLC Parameter Ethernet IP Address for Modbus TCP
  5. Modbus Addressing

    – Here is where to view the modbus settings
    – In this example we’ll be using a Coil Status Register (Y) which is a 0x address.
    – Holding Registers (D) will be used as well which are 4x addresses.

    MapleLogic PLC Parameter Modbus Addresses

PLC Logic Build

This section will walk you through the ladder logic build needed for a simple MQTT communication scenario including a machine on and off bit, machine up time, machine down time, and machine product count. If you need to learn more about MapleLogic please refer to the MapleLogic User Manual. We also have over two dozen MapleLogic Tutorials on our website.

MQTT Ladder Logic Project Build in MapleLogic

Follow this step by step guide for creating the ladder logic in MapleLogic.

Instructions: MQTT Ladder Logic Project Build in MapleLogic
  1. PLC Ladder Logic Layout

    – Here is the logic that’ll be used in this example.
    – 4 rungs of logic for turning Machine 1 on and off, product count, up time, and down time.

  2. Machine 1 On and Off

    – Add a Normally Open Contact (F5) on rung 1. Use X00 as an external contact.
    – Use Y10 as the Machine1_ON_OFF Coil (F9)
    – You can view the device registers in the Device Monitor window on the right side.

    When Machine 1 is on, Machine1_ProductCount and Machine1_UpTime will be activated. When Machine 1 is off, Machine1_DownTime will be activated and Machine1_ProductCount and Machine1_UpTime will stop.

  3. Machine 1 Product Count

    Add a Normally Open Contact (F5), use X00. Add a Positive Transition – Sensing Contact (F7), use F94 for a 2 second clock timer. Add an Application Instruction, use an increment instruction to be stored in a 16-word register D10. Name it Machine1_ProductCount

    This rung will be used to simulate the product count for Machine 1. Every 2 seconds a product will be counted and that count will be displayed in the D10 register. This will only be activated when the Machine1_ON_OFF bit is on.

    MapleLogic Main Scan Ladder Logic Machine 1 Product Count
  4. Machine 1 Up Time

    Add a Normally Open Contact (F5), use X00. Add a Positive Transition – Sensing Contact (F7), use F93 for a 1 second clock timer. Add an Application Instruction, use an increment instruction to be stored in a 16-word register D11. Name it Machine1_UpTime

    This rung will be used to simulate the up time for Machine 1. The up time will update every one second and that count will be displayed in the D11 register. This will only be activated when the Machine1_ON_OFF bit is on.

  5. Machine 1 Down Time

    Add a Normally Closed Contact (F6), use X00. Add a Positive Transition – Sensing Contact (F7), use F93 for a 1 second clock timer. Add an Application Instruction, use an increment instruction to be stored in a 16-word register D12. Name it Machine1_DownTime

    This rung will be used to simulate the down time for Machine 1. The down time will update every one second and that count will be displayed in the D12 register. This will only be activated when the Machine1_ON_OFF bit is off.

  6. Variable Editor – Y Register Modbus Address

    – Navigate to View > Variable Editor
    – Select Y: Bit
    – Here is where to view the modbus address for Y10. It’s 000017 or 0x_17

    The reason the modus address is 000017 or 0x_17 is because Y10 is mapped to the 17th (or 23rd if hex) coil offset in the Modbus memory table, not simply just coil 10. The PLC address Y10 is a native Maple PLC device address, not a Modbus address. When using Modbus TCP, the PLC internally maps its device memory (X, Y, D, M, etc.) into a separate Modbus address table. That mapping does not always directly equal the device number.

  7. Variable Editor – D Word Modbus Addresses

    – Navigate to View > Variable Editor
    – Select D: Word
    – Here is where to view the modbus addresses for D10, D11, D12. They are 400011, 400012, 400013, or 4x_11, 4x_12, 4x_13.

    Due to the Modbus addressing offset by 1 because EBPro displays Modbus Holding Registers (4x) using 1-based addressing, while the Maple PLC’s in MapleLogic internal D registers are effectively 0-based in the Modbus mapping.
    So the mapping works like this:
    D0 > 4x_1
    D1 > 4x_2
    D10 > 4x_11
    D11 > 4x_12
    D12 > 4x_13
    EBPro is adding +1 offset when displaying the Modbus 4x address.

MQTT Publisher Configuration

This guide explains how to configure the cMT-G01X Gateway HMI in EBPro by setting up the Maple PLC Ethernet protocol and connecting to a local MQTT broker server.

IIot Communication Gateway Configuration in EBPro

Follow this step by step guide for configuring the communication protocol and MQTT settings for the Gateway HMI in EBPro

Instructions: IIot Communication Gateway Configuration in EBPro
  1. Add a New Project

    – Select the cMT-G01X Gateway model
    – Click OK

  2. Configuring Communication Protocol

    – Click the Settings button

  3. Selecting the Communication Protocol

    – Click the New Device/Server button
    – Select Modbus > TCP/IP Master
    – Choose Ethernet
    – Choose Station Number: 0 (this must match the station number in MapleLogic, which is also 0)

  4. IP Address Settings

    – Click Settings
    – Enter the IP address of the PLC. 192.168.255.76 for this example.
    – The default Port number is 502. DO NOT change this.
    – In Click OK to save the settings

    Port 502 is the official, standardized TCP port number assigned to Modbus TCP. So whenever a device is acting as a Modbus TCP server (like the Maple PLC), it listens on port 502 by default.

  5. Configuring MQTT Settings

    – Click MQTT to open these settings.

  6. MQTT Server Properties

    – Click Enable to open the server settings
    – Click Settings… to open the properties
    – Cloud service set to Generic
    – Protocol can be left as default as MQTT v3.1
    – Enter the IP address of the local MQTT server. 192.168.255.75 for this example. Port number is 1883.
    – Click OK to save the settings

    You will need to have an MQTT broker server set up. In this example a local Mosquitto server is being used as the MQTT broker server. Therefore the IP address of the PC is being used.

  7. Add Machine 1 On Off Topic

    – Select the Topic Publisher tab
    – Add a topic named Machine1_OnOff and use a nickname of your choosing, it doesn’t have to match the topic name, but it does in this example.
    – Check off Value-trigger based. This means that a message is published only when a tag’s value changes, instead of being sent continuously on a timed interval.
    – Click OK to save the topic

    All of the topics are being published in this example. If you refer back to the ladder logic, topics will need to be created to correspond with the bit and word registers used in MapleLogic.

  8. Machine 1 On Off Address

    – Click the Address tab
    – Select Bit
    – Select the Modbus TCP/IP Master protocol as a device
    – Select 0x_17 as an address.

    Y10 is being used as the bit address in the ladder logic in MapleLogic, therefore select the modbuss address for that bit address, which is 0x_17 or 000017.

  9. Machine 1 Product Count Address

    – Click the Address tab
    – Select Word
    – Select the Modbus TCP/IP Master protocol as a device
    – Select 4x_11 as an address. 4x is used for holding registers.

    D10 is being used as the word address in the ladder logic in MapleLogic, therefore select the modbuss address for that word address, which is 4x_11 or 400011.
    The other holding register addresses used in the ladder logic are D11 and D12, the modbus address are 4x_12 and 4x_13.

Downloading Projects

This guide explains how to download a project to the Gateway HMI in EBPro and download a PLC program in MapleLogic.

Downloading Projects in EBPro and MapleLogic

Follow this step-by-step giude for downloading projects in EBPro and MapleLogic

Instructions: Downloading Projects in EBPro and MapleLogic
  1. Downloading Project to Gateway HMI

    – Click the Download button on the toolbar
    – Enter the IP address of the Gateway HMI
    – Click Download to begin the processs

  2. MapleLogic – Online

    – Select Online on the toolbar
    – Select Connect Option to open the communication setup

  3. Choosing Ethernet

    – Select Ethernet ( USB is also an option, ethernet will be used in this example)
    – Enter the IP address of the PLC
    – Click OK

    If you choose USB instead, the Maple Systems PLC’s use a micro usb type cable for uploading and downloading projects to the PLC.

  4. Link+Download+Monitor

    – Click the Link+Download+Monitor button on the tool to download and monitor the project online

    Selecting Link +Download + Moniotr on the toolbar in MapleLogic
  5. Transmission to PLC

    – Once you click download transmission will begin to the PLC

  6. RUN mode

    – A prompt will pop up once the transmisssion completes to put the PLC into RUN mode
    – Click YES

  7. PLC Program Online

    – Once the download process completes, and selecting RUN mode the logic will be activated and live values can be viewed in MapleLogic
    – A PLC indicator will pop up to switch from RUN to STOP mode and display that the PLC is OK
    – In the Message Window on the bottom, is the view of the PLC’s status and will indicate everything is running smoothly.

Live Simulation

This guide explains how to configure MQTT Explorer to connect to a local Mosquitto broker using the PC’s IP address (192.168.255.75) and port 1883, allowing users to monitor published topics. It also describes the live data flow where the PLC updates values, the Gateway polls via Modbus, publishes changes to the MQTT broker, and MQTT Explorer subscribes and displays the updates in real time.

MQTT Explorer Configuration

Follow this step-by-step guide for configuring MQTT Explorer and how to monitor live MQTT topics.

Instructions: MQTT Explorer Configuration
  1. Add MQTT Connection in MQTT Explorer

    – Choose the MQTT Broker Server (local MQTT Mosquitto server host url in this example: 192.168.255.75)
    1883 is the port number
    Save the settings
    – Click Connect

    In this example, there’s a local MQTT Mosquitto server being used, so the host url is the IP address of the PC being used.

  2. Viewing Topics

    – Now view MQTT Explorer after connecting to the local MQTT broker server.
    – If the MQTT configuration and mosbus addressing were done correctly, all of the topics can be monitored here.

Below is a live simulation showing PLC logic update values in MapleLogic, Gateway detects change via Modbus polling, the Gateway publishes via MQTT, the broker routes the message, and subscriber (MQTT Explorer) receives and displays it.

The live simulation begins with the local Mosquitto broker running and waiting for client connections. The PLC switches from STOP to RUN mode, activating the ladder logic. When Y10 turns on, uptime and product count increment; when off, downtime increments instead.

The Gateway HMI continuously polls the PLC using Modbus TCP/IP, monitored through cMT Diagnoser. The cMT-G01X acts as Modbus Master, while the PLC responds as Modbus Slave.
The gateway stores register values internally and detects changes during continuous polling.

When a configured tag changes, the gateway publishes the updated value to the MQTT broker.
The broker simply routes messages to subscribed clients without modifying any data.

MQTT Explorer subscribes to topics and displays timestamps, payloads, and topic structures.
When messages arrive, MQTT Explorer updates instantly, completing the PLC-to-MQTT data flow.

Recap

This tutorial demonstrated how a Maple Systems PLC can control a machine locally while publishing real-time production data, such as run status, product count, uptime, and downtime, through MQTT to a central broker for plant-wide visibility.

It walks through the complete setup, including PLC ladder logic in MapleLogic, Gateway MQTT configuration in EBPro, network architecture, project downloads, and live monitoring in MQTT Explorer, showing how data flows from PLC to Gateway using Modbus TCP/IP Protocol to the broker, and finally to subscribers for real-time dashboards and analytics.

Next Steps

Pactical next steps would be to expand from monitoring to integrating the MQTT data into a SCADA system, cloud platform, or analytics tool for OEE tracking, downtime analysis, predictive maintenance, and automated reporting. Do this by implementing alarm management, secure MQTT communication (TLS, authentication), network segmentation, and data buffering to ensure reliability during outages.

Finally, consider adding more machines, standardizing tag structures, implementing edge computing logic in the gateway, and aligning with industry standards (ISA-95, OPC UA integration, or Sparkplug B) to build a scalable and future-proof architecture.

Sample Project

This integration tutorial uses these MapleLogic and EBPro sample projects.

Resources & Documentation

The following guides and documentation are specific to the hardware used in this integration tutorial and will help you with setup, configuration, and programming:

Looking for additional learning resources? Explore our library of tutorials, example projects, and software tools to help you get the most out of your system:

Also, browse our Support Center for a complete list of installation guides, FAQs, and additional technical documentation.

Kyle Nicholas Avatar

System integrations can raise questions that go beyond documentation. Our knowledgeable team is available to help connect you with the right resources and guidance. If you are working with Maple Systems hardware or considering a solution, reach out and we’ll help point you in the right direction.