Learn PLCs free

OpenPLC + Arduino: Complete Integration Guide

OpenPLC runs IEC 61131-3 ladder logic and structured text on Arduino-class boards. The OpenPLC Editor compiles your project to an Arduino sketch, you upload it via the Arduino IDE, and the board runs your program with Modbus TCP/Serial as the supervisory link.

Workflow at a glance

  1. Write your IEC 61131-3 program in OpenPLC Editor (LD, ST, SFC).
  2. Set the target hardware in Project Settings (Arduino Uno, Mega 2560, ESP32, Opta).
  3. File → Generate program for OpenPLC Runtime — produces an Arduino sketch folder.
  4. Open the generated .ino in the Arduino IDE.
  5. Select the matching board and port; click Upload.
  6. The board now runs your PLC program at the configured task rate; access I/O via Modbus TCP or Serial.

Pin mapping by board

BoardPLC AddressArduino pin
Arduino Uno%IX0.0–%IX0.7D2–D9 (digital inputs)
%QX0.0–%QX0.4D10–D14 (digital outputs)
%IW0–%IW5A0–A5 (analog inputs)
Arduino Mega 2560%IX0.0–%IX1.7 (16 DI)D2–D17
%QX0.0–%QX1.7 (16 DO)D22–D37
%IW0–%IW15 (16 AI)A0–A15
ESP32%IX0.0–%IX0.5GPIO 36, 39, 34, 35, 32, 33
%QX0.0–%QX0.3GPIO 4, 16, 17, 5
%IW0–%IW3ADC1 channels via GPIO 32-35
Arduino Opta%IX0.0–%IX0.7 (8 DI, 24V isolated)I1–I8
%QX0.0–%QX0.3 (4 relay DO)Q1–Q4
%IW0–%IW7A1–A8 (0-10V or 4-20 mA)

For the full pin map of every supported board, see OpenPLC Supported Hardware.

Limitations vs Raspberry Pi runtime

  • Memory. Arduino Uno: 2 KB SRAM, 32 KB Flash. Limits programs to ~50 rungs / a few hundred ST lines. Raspberry Pi has no practical limit.
  • Web interface. Arduino has no OpenPLC web interface — the Pi/Linux runtime does. Upload programs via Arduino IDE only.
  • Network protocols. Arduino without Ethernet shield has no Modbus TCP — only Serial Modbus over USB. Add a W5500 Ethernet shield for Modbus TCP.
  • No on-board logging. No persistent logs without external storage. Use Modbus TCP queries for debugging.
  • Single task. Arduino targets only support one PLC task; multi-task projects need Linux runtime.

Modbus TCP from a Pi controlling an Arduino OpenPLC

A common architecture: Arduino runs the local control logic; Raspberry Pi (or PC) acts as Modbus TCP master pulling data and pushing setpoints. This gives you the responsiveness of a microcontroller with Linux-side data logging, dashboards, and alerts.

Related guides