Solid State Relay Module

Last updated 12 days ago

This documentation includes hardware info, installation guidelines and sample code for your hardware.

Overall Info

Turta Solid State Relay Module turns on or off small electronical devices. You can control a DC fan, LED strip or water pump with this module.

Illustration

Top
Bottom

Module Connections

  • GPIO: Relay control, active high.

  • Power: +3.3V, GND.

External Connections

  • NO+: Device GND.

  • GND: Power source GND.

  • Connect Device + to power source +.

Specifications

LCA-717S' technical specifications are as follows:

  • Maximum Voltage: 30V DC.

  • Maximum Current: 2A.

  • On Resistance: 0.023 Ohms.

  • Turn On Time: 0.92ms (3ms max).

  • Turn Off Time: 0.44ms (3ms msx).

  • Output Capacitance: 100pF.

Prerequisites

To get maximum performance from your hardware, please make sure you'll meet the following requirements.

Hardware

Solid State Relay Module is an add-in board for Turta Modular System. You'll need a compatible host device for your module. The following devices support Solid State Relay Module:

  • Turta IoT Node - ESP32

Software

For ESP32 based systems, we're currently supporting Arduino core. Please make sure you've installed the following:

  • Arduino IDE.

  • ESP32 Hardware libraries for the Arduino IDE.

  • Python for the compilation of Arduino projects.

  • Drivers for your host device, e.g., USB Virtual Serial Port driver.

Installation

You'll need to install a library to make Arduino IDE support the module. This library includes drivers for the LCA-717S and sample code for you to jumpstart your project.

Libraries

Please download the library archive from https://github.com/Turta-io/Modular

Then, copy its contents to your Arduino Libraries folder.

You can find the Arduino Libraries folder inside your Arduino sketch directory. It is generally located inside the My Documents folder.

Samples

The library comes with included samples. There is no need to download additional files for the examples.

Source Code

The hardware, its drivers and the sample code are open source. You can use them under the terms of the MIT license. Please feel free to customize and prototype them for your projects.

Arduino Library

Turta_SSRelay_Module library is responsible for controlling the relay.

To use the library on Arduino IDE, add the following #include statement to the top of your sketch.

#include <Turta_SSRelay_Module.h>

Then, create an instance of the Turta_SSRelay_Module class.

Turta_SSRelay_Module ssr

Now you're ready to access the library by calling the ssr instance.

Initialization

To initialize the module, call the begin method.

begin()

This method configures the GPIO pin to control relay.

Basic Members

Read Relay

Returns the state of the relay.

bool readRelay()
  • Parameters

    • None

  • Returns

    • Bool: Relay state.

Write Relay

Controls the relay state.

void writeRelay(bool state)
  • Parameters

    • Bool: state

  • Returns

    • None

Examples

You can open the example from Arduino IDE > File > Examples > Examples from Custom Libraries > Turta SSRelay Module. There is one example of this sensor.

Relay Toggle

This application demonstrates the basic operation of the relay. It uses Arduino IDE's Serial Monitor to display current relay state.

To run the example:

  1. Open the IoT_Node_SSRelay_Toggle sketch from the examples menu.

  2. Select Turta IoT Node from the Tools > Board menu.

  3. Select your device's COM port from Tools > Port menu.

  4. Open Serial Monitor from Tools > Serial Monitor.

  5. Select 115.200 baud from the Serial Monitor's status bar.

  6. Upload the code to your device.

Sample Code

IoT_Node_SSRelay_Toggle.ino
#include <Turta_SSRelay_Module.h>
// Create SS Relay instance.
Turta_SSRelay_Module ssr;
void setup() {
// Initialize SS Relay.
ssr.begin();
// Configure serial port.
Serial.begin(115200);
delay(200);
}
void loop() {
// Read relay state.
bool relayState = ssr.readRelay();
// Toggle relay.
ssr.writeRelay(!relayState);
// Write relay state to serial monitor.
Serial.print("Relay State: ");
Serial.println(ssr.readRelay() ? "On." : "Off.");
// Delay 10.000ms = 10 seconds.
delay(10000);
}

Result

After the application is uploaded to the device, it toggles the relay output every 10 seconds. The application writes current relay state to the Serial Monitor. The LED on the SS Relay Module is lit if the relay is on. The example output should be like this:

Relay State: On.
Relay State: Off.

The application runs forever until you clear it from memory.

Troubleshooting

If you're experiencing difficulties while working with your device, please try the following steps.

Problem: The relay conducts some current, even if it is off. Cause: In case you toggle the power of a high power device like a water pump in a high frequency, the solid state relay overheats and malfunctions. Solution: Please change the solid state relay module. Do not switch high power devices on or off quickly. Wait at least 10 seconds between switching.