Learn PLCs free
Programming Guides11 min read2,055 words

Arduino and Raspberry Pi as a PLC: Complete 2026 Guide

Turn an Arduino or Raspberry Pi into a functional PLC for under $100. Complete guide covering OpenPLC runtime, Codesys on Pi, IEC 61131-3 programming, real I/O wiring, and when a DIY PLC actually makes sense.

PPI
PLC Programming IO Editorial Team
Sourced guidance with documented review and correction standards

An Arduino Uno costs $25. A Raspberry Pi 4 costs $75. A commercial PLC from a tier-one vendor starts at around $400 for the smallest form factor and climbs well past $4,000 for anything with meaningful I/O. For engineers learning PLC programming, for makers prototyping industrial projects, and for developing-market automation where vendor pricing makes mainstream PLCs unviable, using an Arduino or Raspberry Pi as a PLC has gone from curiosity to credible deployment path.

This guide covers both platforms — what they can and can't do as PLCs in 2026, which software stacks turn them into IEC 61131-3-compatible controllers, how to wire safe industrial-grade I/O, and the honest picture of when a DIY PLC is the right choice versus when you should save time and money by buying a real industrial controller.

DIY PLC architecture: Arduino or Raspberry Pi plus industrial I/O A DIY PLC setup shows an Arduino Uno or Raspberry Pi at the centre running OpenPLC or Codesys runtime, connected to external I/O expansion boards through shielded wiring. Inputs include push buttons and 24V sensors through optocouplers. Outputs drive relays or SSRs that switch motors, valves, and lights. A separate 24V industrial power supply feeds the I/O side, isolated from the microcontroller's 5V or 3.3V logic. Field Inputs Push buttons Proximity sensors 24 V DC Isolators Optocouplers 24V → 5V/3.3V ground isolation Arduino / Raspberry Pi OpenPLC · Codesys · ladder IEC 61131-3 runtime scan cycle 10–100 ms 5V / 3.3V logic Relay / SSR contact switching Field Outputs Motors · Valves · Lights 24 V DC or 110/230 V AC switched by SSR / relay Industrial PSU 24 V DC isolated powers field I/O side separate from Pi USB Electrical isolation between microcontroller logic and field-side power is non-negotiable.
A safe DIY PLC architecture: microcontroller in the middle, optocouplers and relays doing the voltage-level and isolation work on both sides, a separate industrial PSU feeding the field side. Short-cutting the isolation is the #1 cause of fried Arduinos and Pis in maker-built PLC projects.

What Counts as a "PLC" for DIY Purposes

A PLC is three things combined: ruggedised hardware that handles industrial environments, a deterministic runtime that runs control logic on a scan cycle, and I/O that interfaces safely with 24 V DC sensors and 110/230 V AC loads. An Arduino or Raspberry Pi provides none of these out of the box. What they provide is a flexible, cheap compute platform that — with the right software and I/O expansion — can do roughly 70% of what a small-form-factor commercial PLC does, at 5% of the price.

The three gaps you can close with extra hardware and software:

  1. Rugged enclosure and wiring — DIN-rail mounts, IP-rated enclosures, proper terminal blocks. Off-the-shelf Arduino and Pi industrial carriers (Revolution Pi, Controllino, UniPi, Industrial Shields) solve this.
  2. Deterministic runtime — OpenPLC, Codesys, CODESYS Control for Raspberry Pi, or custom firmware patterns that emulate the PLC scan cycle.
  3. Industrial-grade I/O — Optocoupled input modules, relay or SSR output modules, 24 V input conditioning, RTD/analog expansion boards.

What you can't easily close:

  • Safety ratings (SIL / PL) — No DIY platform is certified for safety-rated control of hazardous machinery. Period.
  • Long-term firmware support — Commercial PLCs ship with 15-year guaranteed firmware availability. Arduino and Pi offerings come and go.
  • Vendor phone support at 3 AM — When your line is down, Rockwell technical support answers. OpenPLC's forum might not.

Option 1: Arduino as a PLC

The Arduino approach works best for small machines, educational labs, and projects where 20-40 I/O points are sufficient.

Arduino Hardware Options

Stock Arduino Uno / Mega — Works for learning. 5 V logic, no isolation, handles toy-class loads. Not for real industrial use.

Industrial Shields PLC boards — Purpose-built Arduino-based PLCs (M-DUINO, ARDBOX). DIN-rail, industrial 12-24 V power, isolated I/O, Ethernet. Pricing: ~$200-500 depending on I/O count. Closest thing to a "real" Arduino PLC.

Controllino MEGA / MAXI / MINI — Swiss-designed Arduino-based industrial controllers. DIN-rail, opto-isolated inputs, relay outputs, Ethernet. ~$250-500 range.

OpenPLC-compatible boards — Any Arduino Uno, Mega, Nano, Leonardo, or the ESP32/ESP8266 family works with the OpenPLC runtime.

Arduino PLC Software Stack

OpenPLC Runtime for Arduino — Free, open-source IEC 61131-3 runtime. Supports LD, ST, FBD, SFC, IL. Compiles your IEC program to Arduino firmware. Loader: OpenPLC Editor (desktop, free). Fully accessible for learning.

PLC-HomeBrew / CustomArduino PLC — Alternative approach where you write plain Arduino sketches that emulate a scan cycle. Not IEC-compliant but simpler for small projects.

Arduino PLC Realistic Scope

An Arduino PLC can handle:

  • Small machine control: motor start/stop, conveyor sequencing, traffic lights, irrigation timers, simple pumping systems.
  • Educational scenarios for learning ladder logic and IEC 61131-3.
  • Non-critical monitoring or signalling tasks.
  • Prototyping before committing to a commercial PLC for production.

An Arduino PLC is not suitable for:

  • Anything safety-critical (presses, hazardous chemical handling, people-transporting machines).
  • Deployments expected to run 24/7 for 10+ years without intervention.
  • Applications requiring high I/O counts (100+ points) or sub-millisecond determinism.
  • Customer-facing or auditable production environments.

Option 2: Raspberry Pi as a PLC

Raspberry Pi is more capable than Arduino for PLC applications because it runs a full Linux OS and handles larger programs, network protocols, and concurrent tasks.

Raspberry Pi Hardware Options

Stock Raspberry Pi 4 / 5 — Works for learning with USB or GPIO-based I/O expansion. 3.3 V GPIO logic. No industrial enclosure.

Revolution Pi (Kunbus) — Commercial-grade industrial Pi platform. DIN-rail, 24 V power, modular I/O, CODESYS certified. ~$300-700.

UniPi / UniPi Neuron — Czech-designed industrial Pi with digital / analog / relay I/O, Modbus, OWFS. ~$250-550.

Industrial Shields RPi boards — Industrial-grade Pi carriers with optoisolated I/O and Ethernet. ~$200-450.

Raspberry Pi PLC Software Stack

CODESYS Control for Raspberry Pi — Commercial-grade IEC 61131-3 runtime from CODESYS GmbH. Free trial (2-hour demo mode that auto-stops); perpetual runtime licence ~€50. Full Codesys IDE compatibility. Production-acceptable.

OpenPLC Runtime for Raspberry Pi — Free, open-source. Runs OpenPLC programs from a web-based UI. Good for learning, non-critical production.

Node-RED with industrial palettes — Not a traditional PLC, but covers adjacent territory: protocol translation, flow-based logic, IIoT gateway. Pairs well with a real PLC or as a standalone controller for light duty.

TwinCAT/BSD on BeagleBone — Beckhoff's lightweight TwinCAT variant for BSD-based embedded systems. Similar scope to Codesys on Pi.

Raspberry Pi PLC Realistic Scope

A Raspberry Pi PLC handles:

  • Small to medium machine control: 50-100 I/O is comfortable with expansion boards.
  • IIoT gateway roles: PLC + data-logger + cloud-connector in one device.
  • Educational and training labs — popular in TVET colleges and universities.
  • Small-scale production in low-regulation industries (agriculture, irrigation, small OEM machines).
  • Research and academic ICS security testing (OpenPLC is the reference platform here).

A Raspberry Pi PLC is not suitable for:

  • Hazardous-machinery safety stops (use a certified safety PLC).
  • SIL-rated process industries.
  • Applications where 24/7 uptime over 15 years is expected without intervention.
  • Environments with extreme vibration or temperature that exceed consumer-grade electronics.

Arduino vs Raspberry Pi as PLCs: Which One When

Factor Arduino Raspberry Pi
Cost (controller only) $25-60 $50-80
I/O expansion cost $50-150 $100-300
Max comfortable I/O ~30-40 points ~100-200 points
Runtime options OpenPLC, custom sketches OpenPLC, Codesys Control, TwinCAT/BSD
Real-time determinism Excellent (bare metal) Good (Linux PREEMPT_RT)
Network protocols Ethernet via shield; Modbus RTU/TCP Full Ethernet + WiFi + cellular; all protocols
Data logging to cloud Via ESP32 WiFi or gateway Native (Node-RED, Python, MQTT)
Power consumption 0.5-3 W 3-15 W
Programming complexity Low Medium
Best for Small fixed machines Medium machines + IIoT + gateway

Arduino wins when you need bare-metal determinism, low power, cheap hardware, and a small fixed machine footprint.

Raspberry Pi wins when you need higher I/O count, IIoT / cloud connectivity, concurrent tasks (PLC + data logging + MQTT), or larger program size.

Wiring a DIY PLC Safely: The Non-Negotiables

The biggest mistake DIY PLC builders make is wiring industrial 24 V DC inputs directly to Arduino or Pi GPIO pins. The pins are 5 V or 3.3 V. The industrial side is 24 V DC. Connect them directly and you burn out the microcontroller instantly — often at the worst possible moment.

Inputs: Use optocouplers Every industrial input (push button, proximity sensor, limit switch powered by 24 V) must go through an optocoupler (PC817, 4N35, or an opto-isolated input module). The optocoupler electrically isolates the microcontroller from the field wiring, handles the voltage conversion, and protects against spikes and reverse polarity.

Outputs: Use relays or SSRs Every output that controls a real load (motor, valve, light) goes through a relay (mechanical) or SSR (solid-state relay). The microcontroller output only needs to drive the relay coil, typically 3.3 V / 5 V / 10 mA. The relay contact handles the actual load current and voltage.

Power isolation Never power the microcontroller from the same 24 V rail that powers the field I/O. Use a separate 5 V / 3.3 V supply for the Pi/Arduino and let the 24 V industrial rail stay completely independent. Ground loops between the two cause intermittent chaos that takes days to debug.

E-stops go hardwired For anything that moves, cuts, or presses, put a hardwired E-stop circuit in series with the contactor coil, completely independent of the Arduino/Pi. The microcontroller can monitor the E-stop state for HMI purposes, but it cannot be the stop mechanism itself.

IEC 61131-3 Programming on DIY Hardware

The magic of OpenPLC and Codesys on Pi / Arduino is that you write standard IEC 61131-3 code — Ladder Logic, Structured Text, Function Block Diagram — exactly as you would for a Siemens or Rockwell PLC. The skills are identical; the hardware underneath is just cheaper.

(* Ladder logic motor start/stop in OpenPLC Editor *)
   Start  Stop  Motor
  --| |--|/|---+----(Motor)
               |
   Motor       |
  --| |--------+

This compiles to Arduino firmware or runs on the Raspberry Pi OpenPLC runtime unchanged. Wire the Start button through an optocoupler to GPIO 2, the Stop button through another optocoupler to GPIO 3, and the Motor output through a relay on GPIO 5 — the logic runs every scan cycle, exactly as on a commercial PLC.

When a DIY PLC Is Actually the Right Choice

Sometimes it genuinely is the right answer. Realistic scenarios:

  • Learning PLC programming — nothing beats real hardware with real relays clicking when you hit the "Start" button. A $75 Pi + $30 worth of relays and sensors teaches more than any simulator can.
  • Academic research — OpenPLC on Pi is the standard ICS-security research platform because it's open source and auditable.
  • Hobby and maker projects — home-brewing equipment, greenhouse automation, aquaponics, workshop dust collection. Real automation, not safety-critical, fine on DIY hardware.
  • Prototyping — verify a control strategy on a Pi before sinking $4,000 into a real PLC + integrator hours.
  • Very low-budget small OEM machines — some machine builders in emerging markets ship real products on Revolution Pi + Codesys. Works because the regulatory burden is lower and the customer base accepts it.
  • IIoT gateway + light PLC — a Pi running Node-RED + Codesys is a killer architecture for small process-industry data collection.

When a DIY PLC Is the Wrong Choice

  • Any hazardous machinery — presses, saws, robot cells, anything that can crush or cut a person. Buy a safety PLC.
  • Regulated industries — pharma, food GMP, nuclear — auditors will reject DIY hardware.
  • Mission-critical production — if downtime costs $10,000/hour, the savings on a $4,000 PLC are irrelevant.
  • Expected 15-year service life — commercial PLCs have guaranteed parts availability. Raspberry Pi Foundation has no such commitment.
  • Anything customer-facing with a warranty claim — a blown Pi is your problem. A blown PLC has a vendor RMA process.

Key Takeaways

  • An Arduino or Raspberry Pi becomes a real PLC with the right software (OpenPLC, Codesys) and I/O hardware (optocoupler input modules, relay output modules).
  • Total build cost: ~$100-150 for Arduino-based, $200-400 for Raspberry Pi-based including industrial-grade expansion.
  • IEC 61131-3 programming is identical on DIY vs commercial PLCs — the skills transfer.
  • Wiring isolation is non-negotiable. Optocoupler inputs, relay / SSR outputs, separate field-side PSU, hardwired E-stops.
  • DIY PLCs are perfect for learning, academia, hobbyists, prototyping, and non-critical light production. They are not acceptable for safety, regulated, or high-availability production environments.
  • The skills you build on a DIY PLC transfer cleanly to Siemens, Rockwell, and every other commercial vendor when you land a role that uses them.
#ArduinoPLC#RaspberryPi PLC#OpenPLC#DIYPLC#Codesys#IEC61131-3#IndustrialAutomation#Low-CostPLC
Share this article:

Related Articles