In this blog post, we will execute a test using the Arduino IDE platform to check the proper functioning of the inputs, outputs, and relays of an ESP32 PLC 14 IOs.
Setting up Arduino IDE for the ESP32 PLC 14
Before proceeding, ensure that you're using the Arduino IDE platform and verify that the boards and model correspond to your ESP32 PLC 14. For this purpose, Industrial Shields provides a board tailored to this specification.
- Install the Industrial Shields ESP32 board on the Arduino IDE, follow these steps:
- Navigate to Tools > Board > Boards Manager.
- Search for "industrialshields-esp32" in the Boards Manager.
- Select the board by choosing Tools > Board > Industrial Shields ESP32 > 14 IOS PLC Family.
I/O test sketch for the ESP32 PLC 14
You have to use Arduino IDE platform to execute the following code. To do it you can download the code in a inout_test.ino file.
int i = 0;
int value;
void setup() {
Serial.begin(9600);
/* Digital outputs */
pinMode(Q0_0, OUTPUT);
pinMode(Q0_1, OUTPUT);
pinMode(Q0_2, OUTPUT);
pinMode(Q0_3, OUTPUT);
/* Digital/Analog outputs */
pinMode(I0_0, INPUT);
pinMode(I0_1, INPUT);
pinMode(I0_2, INPUT);
pinMode(I0_3, INPUT);
pinMode(I0_4, INPUT);
pinMode(I0_5, INPUT);
pinMode(I0_6, INPUT);
pinMode(I0_7, INPUT);
pinMode(I0_8, INPUT);
/* Relay output */
delay(33);
pinMode(R0_0, OUTPUT);
}
void outputsTest(void){
if (i == 0) {
digitalWrite(Q0_0, HIGH);
i++;
}
else if (i == 1) {
digitalWrite(Q0_1, HIGH);
i++;
}
else if (i == 2) {
digitalWrite(Q0_2, HIGH);
i++;
}
else if (i == 3) {
digitalWrite(Q0_3, HIGH);
i++;
}
else {
digitalWrite(Q0_0, LOW);
digitalWrite(Q0_1, LOW);
digitalWrite(Q0_2, LOW);
digitalWrite(Q0_3, LOW);
i = 0;
}
delay(1000);
}
void inputsTest(void){
if (digitalRead(I0_0)){
Serial.println("I0.0 HIGH");
}
else if (digitalRead(I0_1)){
Serial.println("I0.1 HIGH");
}
else if (digitalRead(I0_2)){
Serial.println("I0.2 HIGH");
}
else if (digitalRead(I0_3)){
Serial.println("I0.3 HIGH");
}
else if (digitalRead(I0_4)){
Serial.println("I0.4 HIGH");
}
else if (digitalRead(I0_5)){
Serial.println("I0.5 HIGH");
}
else if (digitalRead(I0_6)){
Serial.println("I0.6 HIGH");
}
else if (value = analogRead(I0_7)){
Serial.print("I0.7: ");
Serial.println(value);
}
else if (value = analogRead(I0_8)){
Serial.print("I0.8: ");
Serial.println(value);
}
}
void relayTest(void){
digitalWrite(R0_0, HIGH);
delay(500);
digitalWrite(R0_0, LOW);
delay(500);
}
void loop() {
outputsTest();
inputsTest();
relayTest();
}
Verifying the results
After executing the test, to verify functionality, you will observe the LEDs toggling between on and off states. Furthermore, by utilizing the serial monitor, you can confirm inputs by checking if they are true. For digital inputs, you will see a verification such as "I0.0 HIGH", while for analog inputs, it will display "I0.8: value", where value represents the analog input reading.

Testing inputs, outputs and relay on the ESP32 PLC 14