<?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: Sarvin Aliyev</title>
    <description>The latest articles on DEV Community by Sarvin Aliyev (@siqurd).</description>
    <link>https://dev.to/siqurd</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%2F4284541%2Fceef248f-3216-4678-8d9b-508bd4b554bd.jpg</url>
      <title>DEV Community: Sarvin Aliyev</title>
      <link>https://dev.to/siqurd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/siqurd"/>
    <language>en</language>
    <item>
      <title>Why I built my own telemetry protocol for SCADA instead of 'just using MQTT'</title>
      <dc:creator>Sarvin Aliyev</dc:creator>
      <pubDate>Sat, 05 Dec 2026 11:10:53 +0000</pubDate>
      <link>https://dev.to/siqurd/why-i-built-my-own-telemetry-protocol-for-scada-instead-of-just-using-mqtt-2j4</link>
      <guid>https://dev.to/siqurd/why-i-built-my-own-telemetry-protocol-for-scada-instead-of-just-using-mqtt-2j4</guid>
      <description>&lt;p&gt;If you've never worked in industrial automation, here's the one thing to know: &lt;strong&gt;the network will drop&lt;/strong&gt;. A switch reboots, a cellular modem on a remote pump station loses signal, or someone unplugs the wrong cable during maintenance. Your software has to survive all of that without losing a single tag value, because those values end up in reports, alarms and sometimes billing.&lt;/p&gt;

&lt;p&gt;I build SCADA and IIoT software in Baku, and for years I kept writing the same plumbing for every project: buffer data on the edge, resend it later, figure out what the master already received. Eventually I pulled that plumbing into one library and open-sourced it. It's called &lt;strong&gt;LunaLink&lt;/strong&gt;.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/lunasoft-llc" rel="noopener noreferrer"&gt;
        lunasoft-llc
      &lt;/a&gt; / &lt;a href="https://github.com/lunasoft-llc/lunalink" rel="noopener noreferrer"&gt;
        lunalink
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Reliable telemetry and remote writes between industrial edge nodes and a SCADA master: a compact binary protocol, a .NET library, an MQTT Sparkplug B bridge and an OPC UA server facade.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;p&gt;&lt;a rel="noopener noreferrer nofollow" href="https://raw.githubusercontent.com/lunasoft-llc/lunalink-examples/main/docs/assets/lunalink-banner-light.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Flunasoft-llc%2Flunalink-examples%2Fmain%2Fdocs%2Fassets%2Flunalink-banner-light.png" alt="LunaLink: a Ping frame shown byte for byte. The magic bytes 4c 4c 4e 4b spell LLNK, followed by version, type, flags, sequence, length, a MessagePack payload and a CRC-16."&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;LunaLink&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="https://www.nuget.org/packages/LunaLink/" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/cd8fb16302d610962009266bd7adde69bf61eb1d0fc5c2919cffbd08c8523398/68747470733a2f2f696d672e736869656c64732e696f2f6e756765742f762f4c756e614c696e6b3f7374796c653d666c61742d737175617265266c6f676f3d6e75676574266c6162656c3d6e75676574" alt="NuGet"&gt;&lt;/a&gt;
&lt;a href="https://www.nuget.org/packages/LunaLink/" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/f96b94629096c0c98913fd1d1d741ac085502ed15823ab787ae7d61836c6f460/68747470733a2f2f696d672e736869656c64732e696f2f6e756765742f64742f4c756e614c696e6b3f7374796c653d666c61742d737175617265266c6162656c3d646f776e6c6f616473" alt="Downloads"&gt;&lt;/a&gt;
&lt;a href="https://www.nuget.org/packages/LunaLink.Bridge.Mqtt/" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/d7cb56030884a3a423aa9adb86de8385df8d88fce4d1067d350f03c1a8bc319a/68747470733a2f2f696d672e736869656c64732e696f2f6e756765742f767072652f4c756e614c696e6b2e4272696467652e4d7174743f7374796c653d666c61742d737175617265266c6f676f3d6e75676574266c6162656c3d4272696467652e4d717474" alt="LunaLink.Bridge.Mqtt"&gt;&lt;/a&gt;
&lt;a href="https://www.nuget.org/packages/LunaLink.OpcUa/" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/c4b9f30b5a234bae1a3e23ec3d343268084e13fdd2f867505248660358fa40b2/68747470733a2f2f696d672e736869656c64732e696f2f6e756765742f767072652f4c756e614c696e6b2e4f706355613f7374796c653d666c61742d737175617265266c6f676f3d6e75676574266c6162656c3d4f70635561" alt="LunaLink.OpcUa"&gt;&lt;/a&gt;
&lt;a href="https://dotnet.microsoft.com/" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/9a49043d2d2e3ea843723c8fc0a7c982ddef4dcfffc74a8427afedf002a5e1a5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2e4e45542d31302d3135313731613f7374796c653d666c61742d737175617265" alt=".NET 10"&gt;&lt;/a&gt;
&lt;a href="https://github.com/lunasoft-llc/lunalink-examples" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/7f04ccf9849611976a290531b01f7e6d7c2ff572816c8cf25b590ed9c5853e8f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6578616d706c65732d4769744875622d3064376136343f7374796c653d666c61742d737175617265266c6f676f3d676974687562" alt="Examples"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;LunaLink moves real-time tag values from edge nodes (PLC gateways, field controllers, edge PCs) to a central master, and carries write commands back. It is a compact binary protocol and a .NET library built for SCADA and industrial IoT networks that drop, stall and reconnect.&lt;/p&gt;
&lt;p&gt;A node writes every batch to a local SQLite outbox and deletes it only after the master confirms it was processed. A durable sequence number lets the master reject duplicates and detect gaps, and a full-state resync recovers when history is no longer available. The protocol handles this, so your application code only publishes values and receives them.&lt;/p&gt;
&lt;p&gt;LunaLink runs inside &lt;a href="https://lunasoft.az/en/products/luna-scada" rel="nofollow noopener noreferrer"&gt;Lunasoft SCADA&lt;/a&gt; and can be embedded in any .NET 10 application.&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;dotnet add package LunaLink&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;At a glance&lt;/h2&gt;
&lt;/div&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Delivery&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Durable outbox, windowed ordered replay, application-level acknowledgements, duplicate filtering, gap detection, full-state resync, optional exactly-once inbox&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Wire&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;17-byte frame overhead, MessagePack payloads, portable LZ4&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/lunasoft-llc/lunalink" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;In this post I'll explain the problem, why the usual answers didn't fully fit, and how the protocol works under the hood.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem: edge → master, over a link you can't trust
&lt;/h2&gt;

&lt;p&gt;A typical setup looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[PLC] ──&amp;gt; [edge node / gateway] ──(flaky network)──&amp;gt; [SCADA master]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The edge node reads values from PLCs and field controllers and sends them to the central master. The master sends write commands back (start the pump, change a setpoint). For this to be safe, you need a few things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;No silent data loss&lt;/strong&gt; when the link goes down.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No duplicates&lt;/strong&gt; when the link comes back and data is resent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gap detection.&lt;/strong&gt; The master must &lt;em&gt;know&lt;/em&gt; if something is missing, not just hope.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Safe remote writes.&lt;/strong&gt; If a "start pump" command is retried, it must not run twice.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  "Why not just MQTT? Or OPC UA?"
&lt;/h2&gt;

&lt;p&gt;That was the first question I asked myself, and both are great tools. I actually ship bridges to both. But for this specific edge-to-master link, I kept running into gaps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MQTT&lt;/strong&gt; gives you QoS levels between client and broker, but end-to-end tracking (did the &lt;em&gt;master application&lt;/em&gt; actually process batch #48213?) is something you build on top yourself. Sparkplug B adds a lot of structure, but recovering history after a long outage is still largely up to you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OPC UA&lt;/strong&gt; is powerful and widely supported, but it's a heavy stack. It's hard to justify on a small microcontroller node that just needs to push values reliably.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So instead of re-gluing these pieces in every project, I wanted one small protocol with store-and-forward built in, from the edge all the way to the master's application code.&lt;/p&gt;

&lt;h2&gt;
  
  
  How LunaLink works
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Every batch goes to a local outbox first
&lt;/h3&gt;

&lt;p&gt;When the edge node publishes tag changes, they're written to a &lt;strong&gt;local SQLite outbox&lt;/strong&gt;. A batch is removed from the outbox &lt;strong&gt;only after the master acknowledges it&lt;/strong&gt;. That acknowledgement comes from the master's application, not just from the transport.&lt;/p&gt;

&lt;p&gt;Network down for an hour? The batches simply wait on disk. When the connection comes back, the client reconnects and replays them automatically.&lt;/p&gt;

&lt;p&gt;If the outbox database is ever corrupted (power loss on a cheap edge PC is a classic), it's quarantined rather than reused.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Sequence numbers make duplicates and gaps visible
&lt;/h3&gt;

&lt;p&gt;Each batch carries the node's &lt;strong&gt;sequence number&lt;/strong&gt;. On the master side this gives you two things for free:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Duplicates&lt;/strong&gt; (the same batch resent after a reconnect) are detected and rejected.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gaps&lt;/strong&gt; (a sequence number that never arrived) are detected, so the master knows data is missing instead of silently drawing a flat line on a trend chart.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Delivery to the master callback is &lt;strong&gt;at-least-once&lt;/strong&gt;, so your processing code should be idempotent. If you need &lt;strong&gt;exactly-once&lt;/strong&gt;, there's an optional transactional inbox store for that.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Full-state resync when history is too big (or gone)
&lt;/h3&gt;

&lt;p&gt;Sometimes replaying everything doesn't make sense. The backlog is huge, or the edge history just isn't available anymore. In that case the node can send a &lt;strong&gt;full-state snapshot&lt;/strong&gt; of current values instead, and the master resyncs from that.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Remote writes with idempotent command IDs
&lt;/h3&gt;

&lt;p&gt;Writes from the master to the node carry &lt;strong&gt;command IDs&lt;/strong&gt;, so a retried command is recognized and not executed twice. Results are reported back to the master.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. A compact binary frame
&lt;/h3&gt;

&lt;p&gt;On the wire, every frame starts with a fixed header and the magic bytes &lt;code&gt;LLNK&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| magic "LLNK" | version | message type | flags | sequence | payload length | payload ... | checksum |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Payloads are &lt;strong&gt;MessagePack&lt;/strong&gt;, and larger ones are compressed with &lt;strong&gt;LZ4&lt;/strong&gt;. The session flow is simple: hello + authentication, ordered tag deltas with application-level acks, heartbeats with inventory, and remote writes with results.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Small nodes are first-class
&lt;/h3&gt;

&lt;p&gt;A microcontroller doesn't want an LZ4 decoder or big receive buffers. So a node can declare in its hello that it &lt;strong&gt;doesn't want compression&lt;/strong&gt; and what its &lt;strong&gt;maximum payload size&lt;/strong&gt; is. The master then won't compress frames for that node, splits snapshots to fit, and reports writes that can't fit as failed instead of sending something the node can't handle.&lt;/p&gt;

&lt;p&gt;That's what makes the &lt;strong&gt;C node for ESP32 and STM32&lt;/strong&gt; practical. There are also Python and Go nodes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Security and operations
&lt;/h2&gt;

&lt;p&gt;Since this runs in real plants, the boring-but-important parts are included:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TLS 1.3&lt;/strong&gt; and &lt;strong&gt;mutual TLS&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Per-node authorization&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Events and alarms&lt;/strong&gt; (deduplicated by event ID)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;History backfill&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Master failover&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Plays nicely with what you already have
&lt;/h2&gt;

&lt;p&gt;LunaLink isn't meant to replace your existing stack. There are two preview extensions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;an &lt;strong&gt;MQTT bridge&lt;/strong&gt; (plain JSON or &lt;strong&gt;Sparkplug B&lt;/strong&gt;)&lt;/li&gt;
&lt;li&gt;an &lt;strong&gt;OPC UA server&lt;/strong&gt; facade&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So you can use LunaLink for the reliable edge-to-master hop and still expose data to tools that speak MQTT or OPC UA.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;It's a .NET 10 library on NuGet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet add package LunaLink
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The README has a full quick start for running a master and connecting an edge node. There's also a separate examples repo with WinForms master and node apps, offline buffering and a Grafana dashboard.&lt;/p&gt;

&lt;p&gt;The library is MIT-licensed, and we use it in production in our own SCADA product at LUNASOFT.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;p&gt;In upcoming posts I want to go deeper into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the outbox design and what happens on power loss&lt;/li&gt;
&lt;li&gt;running a LunaLink node on an ESP32&lt;/li&gt;
&lt;li&gt;benchmarks: throughput, latency and how fast a backlog drains&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;I'd really like feedback&lt;/strong&gt;, especially from people who've fought these problems with MQTT, OPC UA or something homegrown. What did I miss? What would stop you from trying it?&lt;/p&gt;

&lt;p&gt;If this looks useful, a ⭐ on &lt;a href="https://github.com/lunasoft-llc/lunalink" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; helps a lot. Thanks for reading!&lt;/p&gt;

</description>
      <category>iot</category>
      <category>dotnet</category>
      <category>opensource</category>
      <category>csharp</category>
    </item>
  </channel>
</rss>
