Marcio Cunha

From PLC to the cloud: how to integrate industrial automation, APIs, and databases

Learn how to connect the corporate factory floor to the cloud securely and deterministically, integrating PLCs, industrial protocols, REST APIs, and modern databases.

Marcio Cunha12 min
Also available in:EspañolPortuguês
Summary
  • Integrating the factory floor with corporate systems requires translating raw electrical signals into structured real-time data streams.
  • Protocols like OPC UA and MQTT act as secure bridges that prevent performance bottlenecks in the automation network.
  • Robust APIs allow cloud applications to query machine states without overloading programmable logic controllers.
  • Time-series databases organize millions of sensor measurements for predictive analytics and production audits.
  • Industrial cybersecurity requires strict isolation between physical control networks and internet-connected corporate environments.

The boundary between the physical world and the corporate cloud

Anyone visiting a modern factory sees mechanical arms, high-speed conveyors, and blinking electrical panels. Behind this heavy machinery, the real ruler is the PLC, which stands for Programmable Logic Controller—a rugged computer with no screen or keyboard, built to withstand heat, dust, and vibration, whose sole mission in life is to turn on motors, read sensors, and ensure no parts collide. For a long time, these metallic brains lived in isolation on their own digital islands, talking only to each other and local operator screens. In practice, this meant that figuring out if a machine was running efficiently required walking out to the floor with a flash drive or reading an analog production clock.

Today, the pressure for efficiency has completely transformed this scenario. Corporate leadership wants to know in real time how much every manufactured bolt costs, and engineers need to predict failures before a gear breaks and halts the entire line. Accomplishing this requires opening the factory doors and connecting the PLC to the cloud. This process unites two technological cultures that grew up back-to-back: industrial automation, which prizes rigid determinism and millimetric physical stability, and information technology, which thrives on agility, constant updates, and scalability on remote servers.

Understanding PLCs and the invisible language of the factory floor

To integrate any machine into the cloud, the first step is understanding who we are talking to. A PLC does not run conventional operating systems like Windows or Linux; it executes ultrafast scan cycles, reading all physical inputs, processing control logic, and updating outputs in fractions of a millisecond. This timing precision is sacred: if the program lags by a millisecond, a hydraulic press might crush a part at the wrong moment. This is why we cannot simply plug in an ordinary network cable and start running heavy database queries directly on the PLC.

To communicate with these devices without disrupting their critical operation, we use specialized industrial communication protocols. While the internet uses HTTP to load web pages, industry uses dialects like Modbus, Ethernet/IP, and more recently, OPC UA. OPC UA, or Open Platform Communications Unified Architecture, acts as a high-level universal translator. It takes raw data from inside the PLC's memory and organizes it into clear structures with names, units of measure, and timestamps, allowing any external system to query machine status without risking controller crashes.

The intermediary bridge: edge computing and lightweight protocols

Since sending data directly from a factory PLC to a cloud server on the other side of the world is slow and risky, modern engineering relies on a key component called Edge Computing. In practice, we place a compact, rugged computer—usually running Linux—right inside the electrical panel, close to the PLCs. This local computer acts as an intelligent gatekeeper and intermediate translator. It gathers data from PLCs via OPC UA or Modbus, performs preliminary filtering, discards irrelevant noise, and packages what matters before sending it to the cloud.

To transmit this data from the edge to the cloud, the chosen protocol is almost always MQTT, which stands for Message Queuing Telemetry Transport. Unlike traditional web protocols that constantly open and close heavy connections, MQTT was designed for unstable networks and low-bandwidth devices. It operates on a publish-subscribe model: the edge computer publishes machine temperature state to a specific topic, and any cloud service subscribed to that topic receives the data instantly. If factory internet drops, the local gateway buffers messages and retransmits them as soon as connectivity is restored, preventing historical production gaps.

Here is a practical Python code example running on the edge computer, using the Paho-MQTT library to send sensor readings collected from a PLC to a cloud broker:

import timeimport jsonimport paho.mqtt.client as mqttdef on_connect(client, userdata, flags, rc):    print(f