Skip to main content

TDM2312 four-channel relay control via ERa (Wi-Fi/4G)

1. Install the ERa library

Open Arduino IDE, select Manage Libraries (Ctrl+Shift+I), search for the ERa library, and click Install.

image.png

image.png

The image shows the ERa library installed successfully.

2. Connect the relay board to ERa over Wi-Fi

2.1. Configure the gateway in Arduino IDE

Open the ERa ESP32_Wifi_Basic example under File/ERa/ESP32/ESP32_Wifi_Basic.

image.png

Enter your Wi-Fi network name and password:

const char ssid[] = "";

const char pass[] = "";

image.png

2.2. Configure the gateway in ERa

Open https://e-ra.io/index.html in your browser.

image.png

Click Sign In to sign in or create an ERa account.

image.png

Create a new unit in ERa: select “All Unit Dashboards” → “Create Location”.

image.png

Select “Manual setup” → “Next”.

image.png

Enter a location name, choose its position, and click “Create”.

image.png

Example location setup.

Go to “All gateways” → “Create new gateway”.

image.png

Enter a gateway name, such as Relay 4 CH.

Select ESP32-C3 as the board.

Select the location you created under “All Unit Dashboards”.

Click “Next step” to open the library setup page.

image.png

Click “Next step” to open the source code page.

image.png

Click “Copy token”.

image.png

Return to Arduino IDE and find #define ERA_AUTH_TOKEN.

Paste the token copied from ERa.

image.png

Example ERa token.

Select the “ESP32C3 Dev Module” board.

Select “Huge APP” under Partition Scheme.

Select the COM port and upload the code from Arduino IDE.

image.png

After flashing succeeds, return to ERa and click “Next step” to open the gateway activation page.

Once the gateway connects, select “Go to Gateway”.

image.png

Open the “Pin Input/Output” tab and select “Setup”.

image.png

Select “New Input/Output device”.

image.png

Enter a device name.

image.png

image.png

Once the new device is created in ERa, click it.

image.png

Open the “Write configuration” tab and select “New write configuration”.

image.png

Configure relay channel 1 as shown below, then click “Done”.

Relay channels 1, 2, 3, and 4 correspond to GPIO 6, 7, 3, and 10, respectively.

image.png

Open the “Actions” tab and select “New action”.

image.png

Configure the actions that turn the relay on and off as shown below:

image.png

image.png

image.png

Click “Return to Dashboard”.

image.png

Click “Edit dashboard”.

image.png

Drag a “Button” widget onto the dashboard and select “Widget settings”.

image.png

Enter a widget name and select the area created earlier.

image.png

Click “Add” under “Displayed devices”.

image.png

Configure the new displayed device as shown below:

image.png

Select the newly created device as the data stream to display its data (for example, Relay 1).

image.png

Configure the “On action” and “Off action”.

image.png

image.png

Click “OK”.

image.png

Select “Done”.

A widget for controlling the new device appears on the dashboard.

image.png

3. Connect the relay board to ERa over 4G

3.1. Configure the gateway in Arduino IDE

Open the ESP32_GMS_Basic example under File/Examples/ERa/ESP32/ESP3232_GMS_Basic.

image.png

Comment out #define TINY_GSM_MODEM_SIM800.

Define the modem as SIM7600 instead.

Set the carrier for the SIM card in use (for example, Viettel).

image.png

3.2. Configure the gateway in ERa

Follow the same ERa gateway setup steps described in section 2.2.