<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Quanzhong Guo</title>
    <description>The latest articles on DEV Community by Quanzhong Guo (@quanzhongguo).</description>
    <link>https://dev.to/quanzhongguo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4285910%2F7676acaf-41ff-4ff7-af88-a98ddd144f67.png</url>
      <title>DEV Community: Quanzhong Guo</title>
      <link>https://dev.to/quanzhongguo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/quanzhongguo"/>
    <language>en</language>
    <item>
      <title>Getting PLC Data to the Cloud Without a VPN - An Outbound-Only Design for OT Networks</title>
      <dc:creator>Quanzhong Guo</dc:creator>
      <pubDate>Sun, 06 Dec 2026 07:06:48 +0000</pubDate>
      <link>https://dev.to/quanzhongguo/getting-plc-data-to-the-cloud-without-a-vpn-an-outbound-only-design-for-ot-networks-2god</link>
      <guid>https://dev.to/quanzhongguo/getting-plc-data-to-the-cloud-without-a-vpn-an-outbound-only-design-for-ot-networks-2god</guid>
      <description>&lt;p&gt;A dashboard doesn't need a door into the plant. How to get PLC data out with one outbound, encrypted connection, enforce read-only at the protocol level, and segment the network so visibility never becomes a path to the process.&lt;/p&gt;

&lt;p&gt;Controls engineers rarely start by asking "can you read our PLCs?" They start by asking: "If we connect our machines, are we opening a door?"&lt;/p&gt;

&lt;p&gt;As a South African IoT company connecting plants to the cloud, we hear that question more than any other, and it is the right one. OT networks were historically safe because they were isolated. Connecting them for a dashboard makes the people responsible for uptime nervous, and the most common architecture for doing it gives them good reason to be.&lt;/p&gt;

&lt;h2&gt;
  
  
  The wrong tool: a VPN built for maintenance
&lt;/h2&gt;

&lt;p&gt;A site-to-site VPN or a remote-access tunnel exists so that a &lt;strong&gt;person can reach into&lt;/strong&gt; the plant network to program a controller, change a set-point or troubleshoot a sequence. That is a legitimate need, and it is a two-way door by design.&lt;/p&gt;

&lt;p&gt;A dashboard doesn't need a door. It needs &lt;strong&gt;a copy of the data&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When a monitoring project reuses the remote-access architecture, it inherits everything security teams dislike about it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;inbound firewall rules,&lt;/li&gt;
&lt;li&gt;standing credentials,&lt;/li&gt;
&lt;li&gt;a tunnel that is always up,&lt;/li&gt;
&lt;li&gt;a network path that ends at the PLC.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the first design decision is to keep the two apart. Monitoring is one connection in one direction. Maintenance access, if the plant wants it, is a separate decision with its own owner, approval and logging.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpvx5gdf603ktw82dnlkc.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpvx5gdf603ktw82dnlkc.webp" alt="Comparison: a remote-access VPN is two-way, needs inbound rules and standing credentials and ends at the PLC; a monitoring gateway connects out only, reads only, and needs no inbound rule" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The outbound-only design
&lt;/h2&gt;

&lt;p&gt;Put the reading device inside the plant and let it initiate the connection.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;An edge gateway sits next to the controllers&lt;/strong&gt; and reads agreed tags locally, over each PLC's own protocol.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The gateway opens an encrypted connection outward&lt;/strong&gt; to the platform, for example MQTT over TLS on 8883/tcp with a per-device client certificate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The platform never opens a connection into the plant.&lt;/strong&gt; The firewall needs no inbound rule, no PLC port is published, and nothing on the internet can address a controller.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If the link drops, the gateway buffers&lt;/strong&gt; and sends the readings with their original timestamps when the link returns.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That is the whole trick, and it is simpler than a VPN.&lt;/p&gt;

&lt;h2&gt;
  
  
  Segment it like you mean it
&lt;/h2&gt;

&lt;p&gt;NIST SP 800-82r3 (&lt;em&gt;Guide to OT Security&lt;/em&gt;) and IEC 62443 describe the same idea: defence in depth through zones and conduits. In practice, for a monitoring connection:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy9e8171h639aac5balvq.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy9e8171h639aac5balvq.webp" alt="Network zones: OT network with PLCs and HMI/SCADA, an edge zone with the gateway, the business network and the cloud, separated by firewalls, with data flowing outward only" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The firewall policy fits in one table:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;From&lt;/th&gt;
&lt;th&gt;To&lt;/th&gt;
&lt;th&gt;Port&lt;/th&gt;
&lt;th&gt;Rule&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Gateway&lt;/td&gt;
&lt;td&gt;Cloud broker&lt;/td&gt;
&lt;td&gt;8883/tcp&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Allow&lt;/strong&gt;, outbound only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gateway&lt;/td&gt;
&lt;td&gt;PLCs&lt;/td&gt;
&lt;td&gt;4840 (OPC UA) / 502 (Modbus) / 44818 (EtherNet/IP) / 102 (S7)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Allow&lt;/strong&gt;, from the gateway IP only, to listed PLC IPs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Internet&lt;/td&gt;
&lt;td&gt;Edge or OT zone&lt;/td&gt;
&lt;td&gt;any&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Deny&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Business IT network&lt;/td&gt;
&lt;td&gt;OT zone&lt;/td&gt;
&lt;td&gt;any&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Deny&lt;/strong&gt; (unless a separately approved conduit exists)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PLCs&lt;/td&gt;
&lt;td&gt;Gateway&lt;/td&gt;
&lt;td&gt;new connections&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Deny&lt;/strong&gt;. The controllers only answer, they never initiate&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If the cloud or the business network has a problem, it has no direct route to the control layer. The worst case is a compromised gateway, which is why the next section matters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make "read-only" something you can verify
&lt;/h2&gt;

&lt;p&gt;"Read-only" is easy to promise and easy to get wrong. Enforce it as close to the controller as possible, so it holds even if the gateway itself is compromised.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OPC UA (for example Siemens S7-1200 / S7-1500)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only expose the variables the gateway needs (&lt;em&gt;Accessible from HMI/OPC UA&lt;/em&gt;), and clear &lt;em&gt;Writable from HMI/OPC UA&lt;/em&gt; on them in TIA Portal.&lt;/li&gt;
&lt;li&gt;Give the gateway its own user. Don't let it connect anonymously.&lt;/li&gt;
&lt;li&gt;Use security mode &lt;code&gt;SignAndEncrypt&lt;/code&gt; with a current policy such as &lt;code&gt;Basic256Sha256&lt;/code&gt;, and trust the gateway's certificate explicitly on the server.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Modbus TCP&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Modbus has no authentication or encryption, so the network has to provide them.&lt;/li&gt;
&lt;li&gt;Allow only the gateway's IP, and on a Modbus-aware firewall or gateway allow only the read function codes: &lt;code&gt;01&lt;/code&gt;, &lt;code&gt;02&lt;/code&gt;, &lt;code&gt;03&lt;/code&gt;, &lt;code&gt;04&lt;/code&gt;. Block &lt;code&gt;05&lt;/code&gt;, &lt;code&gt;06&lt;/code&gt;, &lt;code&gt;15&lt;/code&gt;, &lt;code&gt;16&lt;/code&gt;, and also &lt;code&gt;23&lt;/code&gt; (read/write multiple). Despite the name, &lt;code&gt;23&lt;/code&gt; writes.&lt;/li&gt;
&lt;li&gt;A plain port filter on 502/tcp cannot tell a read from a write. If you only have a port filter, the read-only guarantee rests on the gateway's configuration, and your risk assessment should say so.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;S7 communication&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Enabling PUT/GET opens read &lt;em&gt;and&lt;/em&gt; write access for remote partners. Prefer OPC UA on S7-1200/1500 where it is available. If you must use S7 communication, keep it behind the gateway-only firewall rule above.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;SCADA historian&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the data already lands in a historian, read from the historian with a read-only database account instead of polling the live controllers. That puts zero extra load on the PLCs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then write it into the scope: &lt;em&gt;the platform has no write access to the control system.&lt;/em&gt; If a vendor resists putting that in writing, you have learned something useful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F28cc8yl66dmmwagznemq.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F28cc8yl66dmmwagznemq.webp" alt="Checklist for enforcing read-only: OPC UA read-only user on S7-1200/S7-1500, Modbus read function codes 01 to 04 only, read the SCADA historian, agree polling, and write no-write-access into the contract" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A checklist before you sign off a PLC connection
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] The gateway initiates all external connections, and there are no inbound rules&lt;/li&gt;
&lt;li&gt;[ ] Transport is encrypted, with a per-device certificate that can be revoked&lt;/li&gt;
&lt;li&gt;[ ] PLC-side access is read-only, enforced in the PLC, the protocol or a protocol-aware firewall&lt;/li&gt;
&lt;li&gt;[ ] The gateway lives in its own zone, with firewalls on both the OT and IT sides&lt;/li&gt;
&lt;li&gt;[ ] Poll rates and connection counts are agreed with the controls engineer&lt;/li&gt;
&lt;li&gt;[ ] Readings are buffered at the edge, with original timestamps preserved&lt;/li&gt;
&lt;li&gt;[ ] Platform users have named accounts and least-privilege roles, and access is logged&lt;/li&gt;
&lt;li&gt;[ ] Remote maintenance access, if any, is a separate, approved and time-limited path&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Is a connected plant less secure than an isolated one?
&lt;/h2&gt;

&lt;p&gt;Not necessarily. "Air-gapped" often really means unmonitored and unpatched, with a shared SCADA password and a USB stick doing the data transfer. A designed connection with one direction, one owner, encryption and an audit log is easier to control than that.&lt;/p&gt;

&lt;p&gt;It also gives you something isolation never did: you can see abnormal behaviour early. A machine stopping at an odd hour or a value drifting out of range becomes visible the moment it happens, instead of at next month's review.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I work at addanode, an &lt;a href="https://addanode.co.za/" rel="noopener noreferrer"&gt;IoT company in South Africa&lt;/a&gt;. This is the pattern we use to connect existing PLCs to our industrial IoT platform. There is a longer write-up on &lt;a href="https://addanode.co.za/insights/industrial-iot-security/" rel="noopener noreferrer"&gt;connecting without exposing your PLCs&lt;/a&gt;. Security design is site-specific, so agree it with your OT and IT owners. I'm happy to discuss edge cases in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>iot</category>
      <category>security</category>
      <category>networking</category>
      <category>cloud</category>
    </item>
    <item>
      <title>How to Read Data from Siemens, Allen-Bradley and Modbus PLCs Without Changing Their Logic</title>
      <dc:creator>Quanzhong Guo</dc:creator>
      <pubDate>Sun, 06 Dec 2026 07:04:42 +0000</pubDate>
      <link>https://dev.to/quanzhongguo/how-to-read-data-from-siemens-allen-bradley-and-modbus-plcs-without-changing-their-logic-4lhk</link>
      <guid>https://dev.to/quanzhongguo/how-to-read-data-from-siemens-allen-bradley-and-modbus-plcs-without-changing-their-logic-4lhk</guid>
      <description>&lt;p&gt;A practical PLC-to-cloud pattern - pick the right read route per controller, keep the gateway read-only, buffer through outages, and prove the numbers against the line's own counters.&lt;/p&gt;

&lt;p&gt;Most factories already have the data they keep asking for. The filler's PLC knows when it stopped, which fault tripped it and how many bottles it made. So do the labeller, the packer and the CIP skid. The problem is that every machine came from a different supplier, at a different time, with its own controller and its own HMI. Nobody can see the whole line at once.&lt;/p&gt;

&lt;p&gt;The usual proposal is to standardise the controllers. That turns a monitoring question into a controls project, with a shutdown, a re-commissioning and a budget that rarely gets approved.&lt;/p&gt;

&lt;p&gt;There is a cheaper way, and it is the one we use most often as an IoT company in South Africa working with food and beverage plants. Monitoring and control are separate problems, so you can read a machine without changing what runs it. This post covers the read side: which route to use for which PLC, what the gateway loop looks like, and how to check the numbers before anyone relies on them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkj9jcuvxjoexkkdcepdb.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkj9jcuvxjoexkkdcepdb.webp" alt="Edge gateway reading Siemens, Allen-Bradley, Schneider, Mitsubishi and Delta PLCs read-only on the OT network and sending data outbound to a cloud platform" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The pattern in one paragraph
&lt;/h2&gt;

&lt;p&gt;An edge gateway sits on the plant network next to the controllers. It reads an agreed list of tags over each PLC's own protocol, adds names and scaling, writes every reading to a local buffer, and then sends the buffer outward to the platform over an encrypted connection. The PLC program is never touched. The gateway never writes to it, and nothing outside the plant connects in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pick the read route per controller
&lt;/h2&gt;

&lt;p&gt;Be precise about the route. "We support Siemens" tells you very little.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Controller&lt;/th&gt;
&lt;th&gt;Read route&lt;/th&gt;
&lt;th&gt;Port&lt;/th&gt;
&lt;th&gt;Things to check first&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Siemens S7-1500 / S7-1200&lt;/td&gt;
&lt;td&gt;Built-in OPC UA server&lt;/td&gt;
&lt;td&gt;4840/tcp&lt;/td&gt;
&lt;td&gt;The server must be enabled and licensed on the CPU, and the variables must be exposed to OPC UA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Siemens S7-1500 / S7-1200&lt;/td&gt;
&lt;td&gt;S7 communication (ISO-on-TCP)&lt;/td&gt;
&lt;td&gt;102/tcp&lt;/td&gt;
&lt;td&gt;Needs PUT/GET enabled and non-optimised DBs. That is a controls change, so get it signed off&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Allen-Bradley Logix&lt;/td&gt;
&lt;td&gt;EtherNet/IP (CIP) tag reads&lt;/td&gt;
&lt;td&gt;44818/tcp&lt;/td&gt;
&lt;td&gt;Read tags by name. Agree the connection count with your controls engineer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Schneider Electric&lt;/td&gt;
&lt;td&gt;Modbus TCP, or Modbus RTU on serial&lt;/td&gt;
&lt;td&gt;502/tcp&lt;/td&gt;
&lt;td&gt;You need the register map. Check word order on 32-bit values&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mitsubishi Electric&lt;/td&gt;
&lt;td&gt;MC protocol (SLMP), or Modbus where configured&lt;/td&gt;
&lt;td&gt;varies&lt;/td&gt;
&lt;td&gt;The Ethernet port has to be configured for MC protocol access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delta and older serial PLCs&lt;/td&gt;
&lt;td&gt;Modbus RTU over RS-485&lt;/td&gt;
&lt;td&gt;serial&lt;/td&gt;
&lt;td&gt;You need the register map, baud rate and parity&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two Siemens details catch people out most often.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PUT/GET.&lt;/strong&gt; Classic S7 reads (for example with &lt;code&gt;python-snap7&lt;/code&gt;) on an S7-1200 or S7-1500 only work if &lt;em&gt;Permit access with PUT/GET communication from remote partner&lt;/em&gt; is ticked in the CPU's protection settings, and the data blocks you read have &lt;em&gt;Optimized block access&lt;/em&gt; turned off. Both are changes to the PLC project. If a monitoring vendor makes them without asking, that is a red flag.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OPC UA exposure.&lt;/strong&gt; On the OPC UA route, every DB variable has &lt;em&gt;Accessible from HMI/OPC UA&lt;/em&gt; and &lt;em&gt;Writable from HMI/OPC UA&lt;/em&gt; attributes in TIA Portal. Expose what the gateway needs and clear &lt;em&gt;Writable&lt;/em&gt; on those variables. The read-only guarantee then lives in the PLC configuration, not in a vendor's promise.&lt;/p&gt;

&lt;p&gt;If you are trying to decide between OPC UA, Modbus and MQTT, I wrote a longer comparison here: &lt;a href="https://addanode.co.za/insights/industrial-protocols-opcua-modbus-mqtt/" rel="noopener noreferrer"&gt;which industrial protocol for which PLC&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the gateway loop actually does
&lt;/h2&gt;

&lt;p&gt;Production gateways are usually purpose-built devices, not Python scripts. The loop underneath is still simple enough to sketch, and the sketch shows the two behaviours that matter: it only reads, and it never drops data when the link goes down.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Minimal sketch of the edge pattern: read-only OPC UA poll -&amp;gt; local buffer -&amp;gt; MQTT over TLS.&lt;/span&gt;
&lt;span class="c1"&gt;# Illustrative only: no retries/backoff, the flush blocks the loop, and the buffer is never pruned.&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sqlite3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;paho&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mqtt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;mqtt&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;asyncua&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Client&lt;/span&gt;

&lt;span class="no"&gt;OPCUA_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"opc.tcp://192.168.10.20:4840"&lt;/span&gt;   &lt;span class="c1"&gt;# PLC on the OT network&lt;/span&gt;
&lt;span class="no"&gt;TOPIC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"plant/line2/filler"&lt;/span&gt;
&lt;span class="no"&gt;POLL_S&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="no"&gt;TAGS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;                                     &lt;span class="c1"&gt;# name -&amp;gt; NodeId (S7-1500 style)&lt;/span&gt;
    &lt;span class="s2"&gt;"running"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="s1"&gt;'ns=3;s="Filler_DB"."Running"'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"count"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="s1"&gt;'ns=3;s="Filler_DB"."BottleCount"'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"faultCode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'ns=3;s="Filler_DB"."FaultCode"'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sqlite3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"buffer.db"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"CREATE TABLE IF NOT EXISTS q (id INTEGER PRIMARY KEY, payload TEXT)"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;mq&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mqtt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mqtt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CallbackAPIVersion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;VERSION2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;client_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"line2-edge"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;mq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tls_set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ca_certs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ca.pem"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;certfile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"edge.crt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;keyfile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"edge.key"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;mq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect_async&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"broker.example.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8883&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# outbound only&lt;/span&gt;
&lt;span class="n"&gt;mq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loop_start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;flush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Send buffered readings oldest-first; stop at the first failure."""&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;mq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;is_connected&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;
    &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT id, payload FROM q ORDER BY id LIMIT 500"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetchall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;info&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;publish&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;TOPIC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;qos&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;wait_for_publish&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;is_published&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt;
        &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"DELETE FROM q WHERE id = ?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;commit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;OPCUA_URL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;plc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;      &lt;span class="c1"&gt;# read-only user + security mode in real use&lt;/span&gt;
        &lt;span class="n"&gt;nodes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;plc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_node&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nid&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;TAGS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;values&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;plc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;reading&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"ts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"INSERT INTO q (payload) VALUES (?)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reading&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;commit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nf"&gt;flush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;POLL_S&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few points the sketch makes concrete:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The timestamp is taken at the edge, when the value is read.&lt;/strong&gt; It is not the time the cloud receives it. That is what makes backfill after an outage honest.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Every reading goes into the buffer first&lt;/strong&gt;, so the buffer is the only path to the cloud. A dropped link only makes the queue longer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;QoS 1 plus delete-after-ack&lt;/strong&gt; gives at-least-once delivery. The platform has to de-duplicate on &lt;code&gt;(device, ts)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;There is no write call anywhere.&lt;/strong&gt; On a real gateway the PLC-side account should not be able to write either, so the guarantee doesn't rest on the code being correct.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For Allen-Bradley you would swap the OPC UA read for something like &lt;code&gt;pycomm3&lt;/code&gt;'s &lt;code&gt;LogixDriver.read()&lt;/code&gt;, and for Modbus &lt;code&gt;pymodbus&lt;/code&gt;'s &lt;code&gt;read_holding_registers()&lt;/code&gt;. The buffer and publish side stays the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  Outages are the normal case
&lt;/h2&gt;

&lt;p&gt;On many sites, especially in South Africa with scheduled power cuts, a link drop is not an edge case. A dashboard that shows nothing while the link is down is misleading, because the gap looks like downtime.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fecaaj1n9zuugcdz4p4g9.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fecaaj1n9zuugcdz4p4g9.webp" alt="Timeline: readings continue at the PLC while the link is down; the gateway stores them and sends them with original timestamps when the link returns" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Three requirements follow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Size the buffer for the longest realistic outage&lt;/strong&gt;, not the average one. Readings per second × bytes per reading × outage seconds, then double it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fail over between links&lt;/strong&gt;, such as wired, Wi-Fi and 4G, without anyone touching the gateway.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Record the outage as its own event.&lt;/strong&gt; Then a power cut shows up as a power cut, not as a machine fault in the shift report.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Respect the PLC's scan budget
&lt;/h2&gt;

&lt;p&gt;A read-only connection can still hurt a controller if it polls too hard. Before going live, agree three numbers with the plant's controls engineer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Poll interval per tag group.&lt;/strong&gt; Counters and states every 1–5 s are plenty for OEE. Energy totals every 60 s are fine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Number of concurrent connections&lt;/strong&gt; to the CPU. Older CPUs have small connection limits that HMIs and SCADA already use.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tag count per request.&lt;/strong&gt; Batch reads, such as &lt;code&gt;read_values&lt;/code&gt; or multi-register Modbus reads, are kinder to the CPU than one request per tag.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prove it before anyone trusts it
&lt;/h2&gt;

&lt;p&gt;The acceptance test is boring on purpose. Run the gateway alongside the line for several real shifts and compare:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the dashboard's count with the machine's own counter at shift end,&lt;/li&gt;
&lt;li&gt;stop events and fault codes with the HMI alarm log,&lt;/li&gt;
&lt;li&gt;run rate with the machine's rated speed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When the numbers agree, people stop arguing about the data and start arguing about the causes. That is the point of the exercise.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to show first
&lt;/h2&gt;

&lt;p&gt;Don't stream every tag the controller holds. Start with the question the plant already argues about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;running / stopped / faulted per machine, with the stop reason from the PLC's own fault codes,&lt;/li&gt;
&lt;li&gt;counts, run rate and rejects per shift and per product,&lt;/li&gt;
&lt;li&gt;CIP and changeover durations read from the controller, not written up by hand,&lt;/li&gt;
&lt;li&gt;water, power and compressed air per line, next to production,&lt;/li&gt;
&lt;li&gt;an alert on a long stop, sent to the person who can act on it.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;I work at addanode, a &lt;a href="https://addanode.co.za/" rel="noopener noreferrer"&gt;South African IoT company&lt;/a&gt;. We connect the PLCs and instruments plants already own to our industrial IoT platform. The full route-by-brand detail is on our &lt;a href="https://addanode.co.za/solutions/industrial-iot/plc-to-cloud/" rel="noopener noreferrer"&gt;PLC to cloud monitoring&lt;/a&gt; page. The code above is a teaching sketch, not our gateway firmware. Questions about a specific controller are welcome in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>iot</category>
      <category>python</category>
      <category>automation</category>
      <category>cloud</category>
    </item>
  </channel>
</rss>
