How to Initialize EQSP32 (Industrial ESP32 IoT Controller)

In this tutorial, we will show you how to initialize and configure your EQSP32 industrial ESP32 PLC controller. Before we begin, make sure you have completed the quickstart guide. In the quickstart guide, you will set up your Arduino IDE environment and create your Firebase account for database access.

When the EQSP32 library runs on your EQSP32 IoT controller, it will be discoverable by the EQConnect mobile configuration utility. Using this app, you can set up the Wi-Fi network and password, configure the time zone, monitor pin modes and state, and more. Download EQConnect.

Necessary hardware

  • EQSP32
  • USB-C cable (for EQSP32 side)
Program your EQSP32 industrial iot esp32 plc controller via a standard USB-C cable.
Program EQSP32 via a standard USB-C cable

Initialize EQSP32 without database access

We will start our initialization with a simple example. You can write the code by hand or ask EQ-AI, the pretrained generative AI GPT model, to create it for you. Let’s begin by creating a simple program that initializes the EQSP32 library and enables the verbose option. This will allow the IoT controller’s background tasks to display status and debug messages.

Basic initialization with debug. No iot.

EQ-AI Prompt
Initialize EQSP32 without IoT. Generative AI response. Initialization code requested for EQSP32 industrial esp32 iot controller.
AI generated code for basic initialization without IoT functionality

Explanation:

  1. Including the Library: The #include "EQSP32.h" line includes the EQSP32 library, which provides access to the functionality needed to control the EQSP32 module.
  2. Creating an Instance of EQSP32: The line EQSP32 eqsp32; creates an instance of the EQSP32 class, which will be used to call the various functions provided by the library.
  3. Setup Function:
    • eqsp32.begin(true);: Initializes the EQSP32 module with verbose enabled for debug messages. The true parameter enables verbose mode, allowing you to see debug messages which can be useful for troubleshooting. Set to false to disable verbose mode.
  4. Loop Function:
    • delay(10);: Adds a small delay of 10 milliseconds to ensure the loop runs properly and does not consume too much processing time.

This code initializes the EQSP32 module and enables debug messages without setting up IoT functionality, as requested.

Copy the code in your Arduino IDE and upload it to your EQSP32 to test.

#include "EQSP32.h"

EQSP32 eqsp32;

void setup() {
    // Initialize EQSP32 module with verbose enabled for debug messages
    eqsp32.begin(true);  
}

void loop() {
    // Add a small delay to ensure the loop runs properly
    delay(10);  
}

Initialize EQSP32 for IoT automation

Now that you have a basic understanding of how to initialize your EQSP32 module, let’s move on to the complete IoT initialization example. This time, we will expose all initialization configurations, including those for IoT functionality. By setting up these configurations, you can connect your EQSP32 controller to a Firebase database and customize various settings.

  • First, ensure you have your Firebase database URL and API key ready. These will be used to connect your EQSP32 controller to the cloud. If haven’t created a Firebase account, check out our quickstart guide.
  • You will also need to set the developer system ID. The system ID is a unique parameter that allows the custom mobile app to distinguish between your various different systems and/or versions.
  • Optionally a default user device name may be set. The device name may be change using the EQConnect app. If the user device name is not set, the default value will be “MyEQSP32”.

Initialize exposing all init configurations and explain them.

EQ-AI Prompt
Initialize EQSP32 for IoT. Generative AI response. Initialization code with iot functionality requested for EQSP32 industrial esp32 iot controller.

Explanation

  1. Include the Library: #include "EQSP32.h" to access EQSP32 functionalities.
  2. Create an Instance: EQSP32 eqsp32; creates an instance of the EQSP32 class.
  3. Setup Configuration: Define and set the configuration parameters in EQSP32Configs myEQSP32Configs.
  4. Initialize the Module: Use eqsp32.begin(myEQSP32Configs, true); to initialize the module with the configurations and enable verbose debugging.
  5. Main Loop: The loop function includes a small delay to ensure the loop runs properly and doesn’t consume too much CPU time.

This example demonstrates how to set up and configure the EQSP32 module for IoT applications, making it easier to connect to cloud services and customize settings for your specific needs.

Copy the code in your Arduino IDE and upload it to your EQSP32 to test.

#include "EQSP32.h"

// Create an instance of the EQSP32 class
EQSP32 eqsp32;

void setup() {
    // Define the EQSP32 configuration structure
    EQSP32Configs myEQSP32Configs;

    // Assign values to the configuration parameters
    myEQSP32Configs.databaseURL = "Your database URL"; // The URL for the database
    myEQSP32Configs.databaseAPIKey = "Your API key";  // The API key for the database
    myEQSP32Configs.devSystemID = "SystemV1.0"; // Developer's system ID, a unique identifier for the system
    myEQSP32Configs.userDevName = "DeviceName"; // Device name assigned by the end user (optional)
    myEQSP32Configs.relaySequencer = false; // Experimental feature (default is false, set to true if needed)

    // Initialize the EQSP32 module with verbose enabled for debug messages
    eqsp32.begin(myEQSP32Configs, true);
}

void loop() {
    // Add a small delay to ensure the loop runs properly
    delay(10);  
}

Conclusion

In this tutorial, you have learned how to initialize and configure your EQSP32 industrial ESP32 iot controller. Now, your EQSP32 module is ready to connect with your EQConnect app, has access to the cloud, and you know how to enable debug messages.

We are always available to help you develop your IoT automations. Contact us for consulting and assistance with your projects.

Add a Comment

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