EQSP32 ADIO pin modes (Industrial ESP32 IoT Controller)

In this tutorial, we will demonstrate the different ADIO pin modes of the EQSP32.

By completing the examples, you will learn:

  • All available modes of operation
  • How to configure a pin to any ADIO mode
  • How to read from and write to each pin based on the operating mode

EQSP32 is an industrial IoT controller based on the ESP32S3. It provides a variety of analog and digital IO modes (also referred to as ADIO). Depending the type of sensors and actuators, different modes will be more suitable.

If you are not familiar with how to initialize EQSP32, refer to EQSP32 initialization tutorial or ask EQ-AI to generate and explain the code for you.

Detailed explanations of each ADIO mode and wiring diagrams are available in EQSP32 datasheet.

Inputs

Digital Input (DIN)

Digital Input (DIN) mode is used for reading digital signals where the pin can be either HIGH or LOW. All pins (1 to 16) can be configured as Digital Input.

#include "EQSP32.h"

EQSP32 eqsp32;

void setup() {
    eqsp32.begin();
    eqsp32.pinMode(1, DIN); // Configure pin 1 as Digital Input
}

void loop() {
    int digitalState = eqsp32.readPin(1); // Read digital state from pin 1
    if (digitalState == HIGH) {
        // Perform action when pin 1 is HIGH
    }
    delay(10); // Small delay
}

Switch (SWT)

Switch (SWT) mode is a special digital input mode with a debouncing timer, designed for handling momentary switch inputs and preventing false triggering. All pins (1 to 16) can be configured as Switch.

#include "EQSP32.h"

EQSP32 eqsp32;

void setup() {
    eqsp32.begin();
    eqsp32.pinMode(3, SWT); // Configure pin 3 as Switch
    eqsp32.configSWT(3, 150); // Set debounce time to 150 ms
}

void loop() {
    int switchState = eqsp32.readPin(3); // Read switch state from pin 3
    if (switchState) {
        // Perform action when switch is pressed
    }
    delay(10); // Small delay
}

Analog Input (AIN)

Analog Input (AIN) mode is used for reading analog signals, providing a continuous range of values between 0 mV and 5000 mV. Only pins 1 to 8 support analog input functionality.

#include "EQSP32.h"

EQSP32 eqsp32;

void setup() {
    eqsp32.begin();
    eqsp32.pinMode(2, AIN); // Configure pin 2 as Analog Input
}

void loop() {
    int analogValue = eqsp32.readPin(2); // Read analog value from pin 2
    // Process analogValue as needed
    delay(10); // Small delay
}

Temperature Input (TIN)

Temperature Input (TIN) mode is a special analog input mode for automatic temperature conversion in Celsius. Only pins 1 to 8 support temperature input functionality.

For this mode to function properly, it is important to configure the correct NTC thermistor parameters.

#include "EQSP32.h"

EQSP32 eqsp32;

void setup() {
    eqsp32.begin();
    eqsp32.pinMode(4, TIN); // Configure pin 4 as Temperature Input
    eqsp32.configTIN(4, 3988, 10000); // Set NTC parameters for pin 4
}

void loop() {
    int temperature = eqsp32.readPin(4); // Read temperature from pin 4
    // Process temperature value as needed
    delay(10); // Small delay
}

Relative Analog Input (RAIN)

Relative Analog Input (RAIN) mode measures the input voltage and returns a value relative to the 5V power output supply, from 0 to 1000 representing 0% to 100% of the 5V output supply voltage. Only pins 1 to 8 support relative analog input functionality.

#include "EQSP32.h"

EQSP32 eqsp32;

void setup() {
    eqsp32.begin();
    eqsp32.pinMode(7, RAIN); // Configure pin 7 as Relative Analog Input
}

void loop() {
    int relativeAnalogValue = eqsp32.readPin(7); // Read relative analog value from pin 7
    // Process relativeAnalogValue as needed
    delay(10); // Small delay for non-blocking operation
}

Outputs

Power PWM Output (POUT)

Power PWM Output (POUT) mode is used for generating a power-controlled PWM signal to drive various loads. All pins (1 to 16) can be configured as Power PWM Output.

#include "EQSP32.h"

EQSP32 eqsp32;

void setup() {
    eqsp32.begin();
    eqsp32.pinMode(5, POUT); // Configure pin 5 as Power PWM Output
}

void loop() {
    eqsp32.pinValue(5, 500); // Set pin 5 to 50% PWM
    delay(1000); // Wait for 1 second
    eqsp32.pinValue(5, 0); // Turn off PWM
    delay(1000); // Wait for 1 second
}

Relay (RELAY)

Relay (RELAY) mode is a special power PWM output mode for relay control, starting with a set power and dropping to holding power after a specified time. All pins (1 to 16) can be configured as Relay.

#include "EQSP32.h"

EQSP32 eqsp32;

void setup() {
    eqsp32.begin();
    eqsp32.pinMode(6, RELAY); // Configure pin 6 as Relay
    eqsp32.configRELAY(6, 350, 1500); // Set relay holding power and delay
}

void loop() {
    eqsp32.pinValue(6, 1000); // Turn on relay
    delay(2000); // Wait for 2 seconds
    eqsp32.pinValue(6, 0); // Turn off relay
    delay(2000); // Wait for 2 seconds
}

This tutorial covers the basic usage of all ADIO modes available in the EQSP32 library. For each mode, we have provided a separate example showing how to configure the pin, read from inputs, and write to outputs. Remember to adjust the pin numbers and parameters as needed for your specific application.

You can use the EQConnect app to monitor EQSP32 pin modes and values wirelessly over Bluetooth.

Contact us for consulting and assistance with your projects.

Add a Comment

Your email address will not be published. Required fields are marked *