Skip to Content

Compact Arduino PLC · Arduino Leonardo · 12 to 24 Vdc · 20 I/O

Ardbox Arduino PLC: technical features

Complete technical reference of the Ardbox compact Arduino PLC family: power supply, DIP switches, analog and digital I/O, relay and PWM outputs, RS-485, RS-232, I2C and SPI, with switch tables and Arduino IDE code for every function.

Power supply
12 to 24 Vdc, 2 A or higher
Programming
Arduino IDE (Arduino Leonardo)
Communications
RS-485 or RS-232, I2C, SPI
Extras
Wi-Fi and Bluetooth, GPRS, DALI or LoRa options

Ardbox Arduino PLC overview

What is the Ardbox Arduino PLC#

The Ardbox is the compact Arduino PLC from Industrial Shields, based on the Arduino Leonardo. It provides 20 I/O points in a smaller format than the M-Duino, mounted on DIN rail and powered at 12 to 24 Vdc, for machines, compact control panels and distributed systems where space is limited.

The Ardbox is programmed in C and C++ with the Arduino IDE and the Industrial Shields boards package. It includes RS-485 or RS-232 (chosen at purchase), I2C and SPI, and can add Wi-Fi and Bluetooth, GPRS, DALI or LoRa at the time of purchase. Supported protocols include Modbus RTU over RS-485.

Certifications: CE and RoHS. When a project needs more than 20 I/O points or ETL certification, the M-Duino is the larger option. For control plus Linux and AI in one device, see the Ardbox Q, built on Arduino UNO Q: its architecture is different and it is not covered on this page.

Ardbox models and I/O#

Both Ardbox models have 20 I/O points. The Analog model adds analog pins and the Relay model adds relay outputs.

ModelAnalog inDigital inDigital outRelay outTotal I/O
Ardbox Analog8210020
Ardbox Relay642820

Read the Ardbox PLC family overview or download datasheets, user guides and certificates from the technical documentation.

Installation and setup

Programming with the Arduino IDE#

Arduino IDE is the original platform to program Arduino boards. This cross-platform application is available on Windows, macOS and Linux under the GNU General Public License. Arduino IDE supports C and C++ code structuring. Industrial Shields recommends the Arduino IDE to program Arduino based PLCs, although any Arduino compatible software can be used with Industrial Shields controllers.

The Industrial Shields boards package lets you select your Arduino based PLC in the Arduino IDE and compile your sketches for each PLC model.

Download the Arduino IDE:

Official Arduino IDE page

Install the Industrial Shields boards in the Arduino IDE:

How to install Industrial Shields Boards

Related: upload a bootloader on an Ardbox PLC, upload a sketch to an Ardbox from the Linux command line.

Ardbox versions and options#

The Ardbox family consists of 2 main models:

Ardbox Analog

Ardbox Relay

Both models can add the following communications, chosen at the time of purchase:

  • Wi-Fi & Bluetooth
  • GPRS
  • DALI
  • LoRa

RS-485 or RS-232 communication is also chosen at the time of purchase.

The difference between the two PLCs is that the Relay model adds relay outputs, while the Analog model adds analog pins.

Related: Wi-Fi and Bluetooth on the Ardbox PLC.

Power supply: 12 to 24 Vdc#

All Arduino based PLCs can be powered between 12 and 24 Vdc. The Ardbox family needs a power supply that can deliver up to 1.5 A (30 W rated power); the consumption of each model is in the table on this page.

The recommended power supply is 2 A or higher. Any industrial power supply is a good choice to power them.

Remember: our units are designed to be powered between 12 and 24 Vdc. Powered only through USB, the unit cannot perform its functions. USB is only for programming the PLCs, not for powering them.

If, for some reason, you would like to use a power supply lower than 1.5 A, contact Industrial Shields technical support to ensure that your system will complete your functionalities without any power issue.

The following diagram shows how to power any Industrial Shields unit.

Ardbox Arduino PLC power supply wiring diagram

DIP switches: Ardbox Analog#

The Ardbox Analog has three switch zones:

Left zone: communication switch

SWITCHONOFF
1 - SCL/Q0.6Q0.6SCL
2 - SDA/I0.0I0.0SDA
3 - RS485 RE/I0.9I0.9RS485 RE
4 - I0.9/RS485 RERS485 REI0.9
5 - RS485 DE/I0.8I0.8RS485 DE
6 - I0.8/RS485 DERS485 DEI0.8

Top zone: RO-DI switch

SWITCHONOFF
1 - Q0.8Q0.8RS (RS485)
2 - RS (RS485)RS (RS485)Q0.9
3 - Q0.9Q0.9RS (RS485)
4 - RS (RS485)RS (RS485)Q0.8

You cannot use both at the same time: if the outputs are ON, RS (RS-485) must be OFF, and vice versa.

Right zone: D/A out switch

SWITCHONOFF
1 - HD - FDHALF DUPLEXFULL DUPLEX
2 - Q0.6DIGITAL (Q0.6)ANALOG (A0.6)
3 - Q0.5DIGITAL (Q0.5)ANALOG (A0.5)
4 - Q0.4DIGITAL (Q0.4)ANALOG (A0.4)
1 - Q0.3DIGITAL (Q0.3)ANALOG (A0.3)
2 - Q0.2DIGITAL (Q0.2)ANALOG (A0.2)
3 - Q0.1DIGITAL (Q0.1)ANALOG (A0.1)
4 - Q0.0DIGITAL (Q0.0)ANALOG (A0.0)

The right zone configures the outputs. If the switch is set to ON, Q0.X works as a digital output. If it is set to OFF, it works as an analog output. One more switch selects half or full duplex for RS-485: ON for half duplex and OFF for full duplex.

DIP switches: Ardbox Relay#

The Ardbox Relay has two switch zones:

Top zone

SWITCHONOFF
1 - RS (RS485)RS (RS485)R8
2 - R8R8RS (RS485)
3 - RS (RS485)RS (RS485)R7
4 - R7R7RS (RS485)

Right zone

SWITCHONOFF
1 - NC--
2 - HD-FDHALF DUPLEXFULL DUPLEX
3 - R5/SCLR5SCL
4 - I0.0/SDAI0.0SDA
1 - RE-RS485RE-RS485I0.4
2 - I0.4I0.4RE-RS485
3 - DE-RS485DE-RS485I0.5
4 - I0.5I0.5DE-RS485

Power consumption by model#

Measured consumption of each model at idle and at full workload.

Ardbox Analog

Current (mA)Power (W)
Idle41,30,99
Full workload76,71,84

Ardbox Relay

Current (mA)Power (W)
Idle31,830,76
Full workload1493,57

Arduino PLC inputs and outputs

Analog inputs: 0 to 10 Vdc#

The analog inputs of the Ardbox accept 0 to 10 Vdc with 10 bits of resolution; they are not isolated and share the internal GND. In Digital and Analog I/O there is self insulation, so it is possible to connect them in a different power supply than 24 Vdc.

Ardbox Analog inputs: 6 or 8 analog (0 to 10 Vdc), configurable by software.

If RS-485 communication is used, which is the default configuration, you will only have 6 analog inputs. If you want to have 8 analog inputs it must be configured in the left switch of the PLC, set I0.8 and I0.9 to ON and RS485 to OFF.

  int IO2 = analogRead(I0_2);
  int IO3 = analogRead(I0_3);
  int IO4 = analogRead(I0_4);
  int IO5 = analogRead(I0_5);
  int IO6 = analogRead(I0_6);
  int IO7 = analogRead(I0_7);
  int IO8 = analogRead(I0_8);
  int IO9 = analogRead(I0_9);

Related: analog inputs of an industrial PLC, convert 4-20 mA to 0-10 V in an Arduino PLC.

Digital inputs: 5 to 24 Vdc#

Digital inputs see a voltage from -Vcc (or GND) to +Vcc, with no intermediate values. Two states: 0 (-Vcc or GND) and 1 (+Vcc). In Digital and Analog I/O there is self insulation, so it is possible to connect them in a different power supply than 24 V.

Ardbox Analog inputs: 8 or 10 digital (5 to 24 Vdc).

If RS-485 communication is used, which is the default configuration, you will only have 8 digital inputs. If you want to have 10 digital inputs it must be configured in the left switch of the PLC, set I0.8 and I0.9 to ON and RS485 to OFF.

  int IOO = digitalRead(I0_0);
  int IO1 = digitalRead(I0_1);
  int IO2 = digitalRead(I0_2);
  int IO3 = digitalRead(I0_3);
  int IO4 = digitalRead(I0_4);
  int IO5 = digitalRead(I0_5);
  int IO6 = digitalRead(I0_6);
  int IO7 = digitalRead(I0_7);
  int IO8 = digitalRead(I0_8);
  int IO9 = digitalRead(I0_9);

Related: digital inputs of an industrial controller, PNP digital inputs on an industrial PLC.

Interrupt input (I0.0)#

An interrupt service routine (ISR) is a mechanism that allows a function to be associated with the occurrence of a particular event. When the event occurs the processor exits immediately from the normal flow of the program and runs the associated ISR function ignoring any other task.

Ardbox Analog inputs: 1 interrupt input (5 to 24 Vdc), which can also work as a digital input (24 Vdc).

Ardbox pinArduino Leonardo pinSwitch
I0.0 (INT1)2SDA/I0.0 at ON Position


In this example we activate INT1 using pin I0_0.

  #define INTERRUPT I0_0 // other pins: I0_3, I0_2, I0_1

  volatile bool state = false;

  void setup() {
    pinMode(INTERRUPT, INPUT_PULLUP);
    attachInterrupt(digitalPinToInterrupt(INTERRUPT), function_call_back, CHANGE);
  }

  void loop() {
    if (state == true){
      Serial.println("Interrupt activated");
      state = false;
    }
  }

  void function_call_back(){ //Change led state
    state = true;
  }

Analog outputs: 0 to 10 Vdc#

An analog output can take any value between -Vcc (or GND) and +Vcc: it provides a voltage set by a digital value coded with an N-bit number. In Digital and Analog I/O there is self insulation, so it is possible to connect them in a different power supply than 24 V.

Ardbox Analog outputs: 7 analog outputs (0 to 10 Vdc): 7 digital outputs can be converted to analog outputs with the right zone switch.

  analogWrite(A0_0, 255);
  analogWrite(A0_1, 10);
  analogWrite(A0_2, 0);
  analogWrite(A0_3, 240);
  analogWrite(A0_4, 124);
  analogWrite(A0_5, 100);
  analogWrite(A0_6, 200);
  analogWrite(A0_6, 20);

  // CONFIGURE THE RIGHT SWITCH WITH ALL OUTPUT AS ANALOG(OFF)
  analogWrite(Q0_0, 182);
  analogWrite(Q0_1, 30);
  analogWrite(Q0_2, 50);
  analogWrite(Q0_3, 10);
  analogWrite(Q0_4, 0);
  analogWrite(Q0_5, 100);
  analogWrite(Q0_6, 255);

Related: analog outputs of an industrial PLC.

Digital outputs: 5 to 24 Vdc#

A digital output switches between -Vcc (or GND) and +Vcc, with no intermediate values. Two states: 0 (-Vcc or GND) and 1 (+Vcc). In Digital and Analog I/O there is self insulation, so it is possible to connect them in a different power supply than 24 V.

Ardbox Analog outputs: 10 digital outputs (5 to 24 Vdc); 7 of them can provide PWM (5 to 24 Vdc).

  // CONFIGURE THE RIGHT SWITCH WITH ALL OUTPUT AS DIGITAL(ON)
  digitalWrite(Q0_0, HIGH);
  digitalWrite(Q0_1, LOW);
  digitalWrite(Q0_2, HIGH);
  digitalWrite(Q0_3, LOW);
  digitalWrite(Q0_4, HIGH);
  digitalWrite(Q0_5, HIGH);
  digitalWrite(Q0_6, LOW);
  digitalWrite(Q0_7, LOW);
  digitalWrite(Q0_8, LOW);
  digitalWrite(Q0_9, HIGH);

Related: digital outputs of an industrial PLC, optoisolated outputs on the Ardbox.

Relay outputs (Ardbox Relay)#

A relay is an electromagnetic switch controlled by an electric signal. In Industrial Shields units these devices are already integrated in their boards and can be accessed directly with the function digitalWrite(RX, HIGH). Industrial Shields relays are normally open and can handle a maximum current of 4 A at up to 230 Vac and 2 A at up to 24 Vdc.

Ardbox Relay Arduino PLC relay outputs

Ardbox Relay outputs: 8 relay outputs, R1 to R8 (230 Vac, 4 A).

  // Close the relay contacts (relay on)
  digitalWrite(R1, HIGH);
  digitalWrite(R2, HIGH);
  digitalWrite(R3, HIGH);
  digitalWrite(R4, HIGH);
  digitalWrite(R5, HIGH);
  digitalWrite(R6, HIGH);
  digitalWrite(R7, HIGH);
  digitalWrite(R8, HIGH);

  delay(500);

  // Open the relay contacts (relay off)
  
  digitalWrite(R1, LOW);
  digitalWrite(R2, LOW);
  digitalWrite(R3, LOW);
  digitalWrite(R4, LOW);
  digitalWrite(R5, LOW);
  digitalWrite(R6, LOW);
  digitalWrite(R7, LOW);
  digitalWrite(R8, LOW);

Related: internal relays and relay outputs in a PLC.

PWM outputs and avr-Pulses#

Pulse width modulation (PWM) activates a digital output for part of a period and keeps it off for the rest. The average output voltage, over time, will be equal to the desired analogue value. The pulse frequency stays the same while the pulse width changes.

A PWM Output gives a Vcc value during a certain time.
Pay attention to the supply voltage, because the PWM output will have the same voltage difference.

Ardbox pinArduino Leonardo pin
Q0.63
Q0.55
Q0.46
Q0.39
Q0.210
Q0.111
Q0.013

Q0.0, Q0.1, Q0.2, Q0.3, Q0.4, Q0.5 and Q0.6 Digital/PWM out also as A0.0, A0.1, A0.2, A0.3, A0.4, A0.5 and A0.6 Analog out.

Pulse trains with the avr-Pulses library

The Pulses module of the avr-Pulses library provides functions for starting and stopping a train of pulses at the desired frequency using PWM pins.

The startPulses(pin, frequency, precision) function starts the train of pulses at the specified frequency and precision. The default frequency is 1 kHz and the default precision is 3.

pinMode(3, OUTPUT);
startPulses(3, 2000, 3);

The stopPulses(pin) function stops the train of pulses.

stopPulses(3);

Important: it is not possible to have different frequencies on pins that share the same timer. Some outputs share the same timer, so they work at the same frequency.

Caution: when the TIMER0 pins are used, the time functions such as delay(), millis(), micros() and delayMicroseconds() change their behaviour.

Recommended precision for each frequency range:

PrecisionFrequency Range (Hz)
130 - 150
2150 - 500
3500 - 4k
44k - 32k
532k - 4

To have a high precision on the desired frequency, use the precision that matches the range in the table above. See the example code in Pulses module library for Arduino based PLCs.

The Ardbox Relay has no PWM outputs.

Communications: RS-485, RS-232, I2C, SPI

RS-485: half and full duplex#

RS-485, also known as TIA-485(-A), EIA-485, is a standard defining the electrical characteristics of drivers and receivers for use in serial communications systems. The electrical signaling is balanced, and multi-point systems are supported.

Make sure you have your switches and jumpers configured properly before using this serial communication.

RS-485 Arduino examples

Basic RS-485 write example (send):

// Include Industrial Shields libraries
#include 

//// IMPORTANT: check switches configuration

////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
  // Begin serial port
  Serial.begin(9600);

  // Begin RS485 port
  RS485.begin(38400);
}

////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
  // Wait bytes in the serial port
  if (Serial.available()) {
    byte tx = Serial.read();

    // Echo the byte to the serial port again
    Serial.write(tx);

    // And send it to the RS-485 port
    RS485.write(tx);
  }
}

Basic RS-485 read example (receive):

// Include Industrial Shields libraries
#include 

//// IMPORTANT: check switches configuration

////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
  // Begin serial port
  Serial.begin(9600);

  // Begin RS485 port
  RS485.begin(38400);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
  // Print received byte when available
  if (RS485.available()) {
    byte rx = RS485.read();

    // Hexadecimal representation
    Serial.print("HEX: ");
    Serial.print(rx, HEX);

    // Decimal representation
    Serial.print(", DEC: ");
    Serial.println(rx, DEC);
  }
}

Basic RS-485 full-duplex example:

// Include Industrial Shields libraries
#include 
//// IMPORTANT: check switches configuration
//// IMPORTANT: Full duplex mode is only available when device supports it
////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
  // Begin serial port
  Serial.begin(9600);
  // Begin RS485 port
  RS485.begin(38400, FULLDUPLEX);
}

////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
  // Wait bytes from the RS-485
  if (RS485.available()) {
    byte tx = RS485.read();
    // In full-duplex mode it is possible to send and receive data
    // at the same time in a secure way
    RS485.write(tx);
    // Echo the byte to the serial port
    Serial.write(tx);
  }
}

To test full duplex, connect A and B (receivers) to Y and X (transmitters).

Related: RS-485 basics, RS-485 with Arduino and ESP32 based PLCs, connect two PLCs through RS-485.

RS-232#

RS-232, also known as TIA-232-F, EIA-232-F, or V.24, is a standard for serial communication transmission of data. It specifies the voltage levels, signal timing, and data protocol for communication between devices.

Make sure you have your switches and jumpers configured properly before using this serial communication.

RS-232 Arduino examples

Basic RS-232 write example

// Include Industrial Shields libraries
#include 
//// IMPORTANT: check switches configuration
//////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
  // Begin serial port
  Serial.begin(9600);
  // Begin RS232 port
  RS232.begin(38400);
}

///////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
  // Wait bytes in the serial port
  if (Serial.available()) {
    byte tx = Serial.read();
    // Echo the byte to the serial port again
    Serial.write(tx);
    // And send it to the RS-232 port
    RS232.write(tx);
  }   
}

Basic RS-232 read example

// Include Industrial Shields libraries
#include 

//// IMPORTANT: check switches configuration

//////////////////////////////////////////////////////////////////////////////////////////////

void setup() {

  // Begin serial port
  Serial.begin(9600);

  // Begin RS232 port
  RS232.begin(38400);

}

//////////////////////////////////////////////////////////////////////////////////////////////

void loop() {
  // Print received byte when available
  if (RS232.available()) {
    byte rx = RS232.read();

    // Hexadecimal representation
    Serial.print("HEX: ");
    Serial.print(rx, HEX);

    // Decimal representation
    Serial.print(", DEC: ");
    Serial.println(rx, DEC);
  }
}

Related: RS-232 basics, RS-232 test on the Ardbox.

I2C#

I2C is a synchronous protocol that uses only 3 wires: clock (SCL), data (SDA) and ground (GND). This means that the master and the slave send data through the same cable, which is controlled by the master, who creates the clock signal. I2C uses addressing to select slaves.

I2C is a serial communications bus. The speed is 100 kbit/s in standard mode, but also allows speeds of 3.4 Mbit/s. It is a very used bus in the industry, mainly to communicate microcontrollers and their peripherals in integrated systems, or to communicate integrated circuits on the same PCB.

Make sure you have your switches and jumpers configured properly before using this serial communication.

I2C scanner example

Important: make sure the Industrial Shields boards package is installed in the Arduino IDE.

Simple example of scanning I2C:

#include 

void setup() {
  Wire.begin();
  Serial.begin(9600);
  while (!Serial); // Leonardo: wait for Serial Monitor
  Serial.println("\nI2C Scanner");
}

void loop() {
  int nDevices = 0;
  Serial.println("Scanning...");

  for (byte address = 1; address < 127; ++address) {
    Wire.beginTransmission(address);
    byte error = Wire.endTransmission();

    if (error == 0) {
      Serial.print("I2C device found at address 0x");
      if (address < 16) {
        Serial.print("0");
      }
      Serial.print(address, HEX);
      Serial.println("  !");
      ++nDevices;
    } else if (error == 4) {
      Serial.print("Unknown error at address 0x");
      if (address < 16) {
        Serial.print("0");
      }
      Serial.println(address, HEX);
    }
  }

  if (nDevices == 0) {
    Serial.println("No I2C devices found\n");
  } else {
    Serial.println("done\n");
  }
  
  delay(5000); // Wait 5 seconds for next scan
}

Related: I2C bus on an Arduino based PLC, set up external I2C.

SPI#

SPI is a synchronous communication protocol bus that has a master-slave architecture. Slave devices cannot initiate communication, nor exchange data with each other directly. Only the master can select the slave it communicates with through the SS (slave select) pin.

SPI example

// include the SPI library:
#include 

// set pin 10 as the slave select for the digital pot:
const int slaveSelectPin = 10;

void setup() {
  // set the slaveSelectPin as an output:
  pinMode(slaveSelectPin, OUTPUT);
  // initialize SPI:
  SPI.begin();
}

void loop() {
  // go through the six channels of the digital pot:
  for (int channel = 0; channel < 6; channel++) {
    // change the resistance on this channel from min to max:
    for (int level = 0; level < 255; level++) {
      digitalPotWrite(channel, level);
      delay(10);
    }
    // wait a second at the top:
    delay(100);
    // change the resistance on this channel from max to min:
    for (int level = 0; level < 255; level++) {
      digitalPotWrite(channel, 255 - level);
      delay(10);
    }
  }
}

void digitalPotWrite(int address, int value) {
  // take the SS pin low to select the chip:
  digitalWrite(slaveSelectPin, LOW);
  // send in the address and value via SPI:
  SPI.transfer(address);
  SPI.transfer(value);
  // take the SS pin high to de-select the chip:
  digitalWrite(slaveSelectPin, HIGH);
}

Related: SPI bus on Industrial Shields PLCs.

Extra features: direct pins and 5 V signals

Direct Arduino Leonardo pins#

To add another serial port, some digital pins can be used to create a software serial port. The SoftwareSerial library has been developed to allow serial communication on other digital pins of the Arduino, using software to replicate the functionality. It is possible to have multiple software serial ports with speeds up to 115200 bps. A parameter enables inverted signaling for devices which require that protocol.

Only the 5 V I/O of the Ardbox can be used.

Ardbox pinsArduino Leonardo pins
MISO14
MOSI16
SCK15

5 Vdc signals#

These pins can be programmed according to Arduino features such as I/Os operating at 5 V or any additional features present in the pins.

I2C pins SDA/SCL: The I2C protocol is meant to work in a pull-up configuration. In this case it reads 5 V when nothing is connected.

SPI pins MISO/MOSI/SCK: These pins can work as 5 V pins only when no expansion module is using the SPI bus.

Pin 2/Pin 3: On the Ardbox, Leonardo pin 2 is input I0.0, and on the Ardbox Relay pin 3 is input I0.1.

Projects and resources

Ardbox case studies#

See all projects in the Arduino PLC case studies library.

Courses, examples and documents#

Arduino PLC FAQ#

What is the Ardbox Arduino PLC?

The Ardbox is the compact Arduino PLC from Industrial Shields, based on the Arduino Leonardo. It provides 20 I/O points on DIN rail, for machines, compact control panels and distributed systems where space is limited.

How do you program the Ardbox Arduino PLC?

With the Arduino IDE and the Industrial Shields boards package, in C and C++. Each terminal has its own name in code: input I0.2 is read as I0_2 and relay output R1 is written as R1.

What power supply does the Ardbox need?

An external 12 to 24 Vdc supply, 2 A or higher recommended. USB is only for programming the PLC, not for powering it.

Which communications does the Ardbox include?

RS-485 or RS-232, chosen at purchase, plus I2C and SPI. Wi-Fi and Bluetooth, GPRS, DALI or LoRa can be added at the time of purchase.

What is the difference between Ardbox Analog and Ardbox Relay?

Both have 20 I/O points. The Ardbox Analog has 8 analog inputs, 2 digital inputs and 10 digital outputs, 7 of them configurable as 0 to 10 Vdc analog outputs. The Ardbox Relay has 6 analog inputs, 4 digital inputs, 2 digital outputs and 8 relay outputs.

When should I choose an M-Duino instead of an Ardbox Arduino PLC?

When the project needs more than 20 I/O points or ETL certification, which is only available on the M-Duino 21, 42 and 58. The Ardbox is CE and RoHS.

No section matches your search. Try a pin name, a protocol or a component.