Skip to Content

DIY: Assemble your industrial PLC with only 7 components

A DIY Arduino Leonardo controller with 8 relays (4 pairs unless you rewire one shield) and 9 isolated inputs: the parts, the assembly, its limits and when a DIN rail PLC is the better choice
May 19, 2020 by
DIY: Assemble your industrial PLC with only 7 components
Joan F. Aubets - Industrial Shields

Complete guide: Choosing an industrial controller

You can build a basic Arduino controller with 7 components: an Arduino Leonardo, three Proto Shield Rev3 boards with the optocoupler circuits for 9 isolated 24 V inputs, two Arduino 4 Relays Shields for 8 relay outputs, external connectors, cables and a plastic case. It takes about 5 hours of soldering and assembly. It is a good project to learn, but it has limits: the relays of the 4 Relays Shield are for loads up to 48 V (2 A at 30 Vdc per contact), the two shields use the same Arduino pins 4, 7, 8 and 12, so the 8 relays work as 4 pairs unless you rewire one shield, and the result has no DIN rail housing or CE declaration. For a machine, a ready-made PLC such as the Ardbox Relay, built around the same Arduino Leonardo, gives 10 inputs, 8 relays for 250 Vac 5 A / 30 Vdc 3 A, RS-485 and RS-232.

What you need: the 7 components

ComponentQuantityWhat it does
Arduino Leonardo1The controller (ATmega32u4, 16 MHz, 32 KB flash, 2.5 KB SRAM)
Proto Shield Rev33Boards to solder the input circuits, 3 inputs on each one
Components for the isolated inputs9 inputsOne optocoupler circuit per 24 V input
Arduino 4 Relays Shield24 relays on each shield, 8 in total
External connectors17Terminals to wire the field signals
Development cables1 setConnections between the boards
Plastic case1Housing for the stack of boards

Use original boards: in a controller, the quality of the parts decides how long it works without faults.

How to assemble it

The relay shields already have the relays on the board: stack them on top of the Arduino Leonardo. The isolated inputs take more work, because you buy and solder every component. Each input uses an optocoupler: the 24 V field signal lights the LED of the optocoupler through a series resistor, and the transistor on the other side gives a logic signal to the Arduino pin, with no electrical connection between the two sides.

Optocoupler input circuit: input resistor R1 and protection diode on the field side, transistor output with pull-up to Vcc on the logic side
A simple optocoupler input: the field side on the left, the logic side on the right.

In our lab tests this simple circuit worked. For reasons of space, 3 Proto Shields are needed to solder the components of 9 inputs, 3 on each shield. External plug-in connectors make the wiring to the machine easier. Count about 5 hours to solder the components and stack the shields, depending on your soldering experience.

Check the pins before you stack the relay shields. The Arduino 4 Relays Shield drives its relays from pins 4, 7, 8 and 12. Two shields stacked without changes switch together in pairs. To get 8 independent relays, the control lines of the second shield must go to other free pins of the Leonardo.

DIY controller or Ardbox Relay: what is the difference?

DIY controllerArdbox Relay
ControllerArduino LeonardoArduino Leonardo (ATmega32u4) inside
Power supply5 Vdc from USB12 to 24 Vdc, with fuse and polarity protection
Inputs9 isolated, 24 Vdc10: 6 analog/digital (0 to 10 V) and 4 isolated digital (5 to 24 Vdc)
Relay outputs8 relays for loads up to 48 V, 2 A at 30 Vdc, driven as 4 pairs without rewiring8 independent relays, 250 Vac 5 A / 30 Vdc 3 A (resistive)
Other outputsNone2 analog/PWM (0 to 10 V)
CommunicationsTTL serial, I2C, SPIRS-485, RS-232, TTL serial, I2C, SPI
MountingPlastic caseDIN rail, IP20, 100 x 45 x 115 mm
CertificationNone for the assembled deviceCE and UKCA certificates
Assembly timeAbout 5 hoursReady to wire

Both are programmed with the Arduino IDE, so a sketch written for the DIY controller is a good start for the Ardbox Arduino PLC, once you change the pin names.

When does a DIY controller make sense?

  • Yes: to learn electronics and PLC logic, for a bench prototype, for a home project with low voltage loads.
  • No: to switch mains voltage, in a machine that must have certified equipment, or where a stop costs money. There, use a DIN rail PLC with protected inputs and outputs and its certificates.

FAQ about building a PLC with Arduino

Can I build my own PLC with an Arduino?

Yes, a basic one: an Arduino Leonardo with isolated input circuits and relay shields gives 9 inputs and 8 relays. It works for learning and prototypes, but not as certified industrial equipment.

Can the Arduino 4 Relays Shield switch 230 Vac?

No. Arduino rates its relays for loads up to 48 V, with 2 A at 30 Vdc per contact. To switch 230 Vac, use relays rated for it, such as the 250 Vac 5 A relays of the Ardbox Relay.

Why do two stacked relay shields switch together?

Both shields use pins 4, 7, 8 and 12 of the Arduino. Without rewiring, relay 1 of both shields follows pin 4, and so on.

Can I program the controller in ladder logic?

With the Arduino IDE you write C++ sketches. For IEC 61131-3 languages such as ladder, see the OpenPLC guide for industrial PLCs.

Which Industrial Shields PLC is closest to this project?

The Ardbox Relay: it has the same Arduino Leonardo inside, 8 relays and 10 inputs in a 45 mm wide DIN rail housing.

Take it further

The ready-made alternative: a real project with an Ardbox Arduino PLC and the Ardbox Relay product page.

​Search in our Blog

DIY: Assemble your industrial PLC with only 7 components
Joan F. Aubets - Industrial Shields May 19, 2020
Share this post

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.

PLC Comparison