ESP32-S3-Relay-1CH

From Waveshare Wiki
Jump to: navigation, search
ESP32-S3-Relay-1CH
ESP32-S3-Relay-1CH
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Introduction

Introduction

ESP32-S3-Relay-1CH is an industrial-grade 1-channel WiFi network relay based on the ESP32-S3 main controller, supporting WiFi, Bluetooth, RS485, and other peripheral interfaces. It has built-in protection circuits such as power supply isolation and optocoupler isolation, which is safe, stable and reliable, and suitable for the AIoT field.

Features

  • Based on ESP32-S3 microcontroller with Xtensa 32-bit LX7 dual-core processor with frequency up to 240MHz
  • Integrated 2.4GHz WiFi and Bluetooth 5 (LE) dual-mode wireless communication, with superior RF performance
  • High quality relay, contact rating: ≤10A 250V AC or ≤10A 30V DC
  • Onboard isolated RS485 interface, for connecting to various RS485 Modbus industrial modules or sensors
  • Onboard RTC clock chip, supports timing tasks
  • Onboard USB Type-C port for power supply, firmware downloading and debugging, making development more convenient
  • Onboard power supply screw terminal, supports 5V power supply only
  • Onboard optocoupler isolation to prevent interference with control chip from external high-voltage circuit connected to the relay
  • Onboard digital isolation to avoid external signal interference with the control chip
  • Onboard integrated power isolation, providing stable isolation voltage, no extra power supply required for the isolated terminal
  • Onboard RS485 TX/RX indicator for monitoring the operating status of the module
  • Rail-mounted protective enclosure, easy to install, safe to use

Specifications

Microcontroller

ESP32-S3 (default to ESP32-S3R8 chip, customizable)

Wireless communication

2.4GHz Wi-Fi (802.11 b/g/n), Bluetooth 5 (LE)

USB port

Port type

USB Type-C

Supply voltage

5V

Function

Power supply, USB communication, firmware downloading, etc.

Isolated RS485

Port type

Screw terminal

Direction control

Set automatic control through main control hardware flow

Interface protection

Provide TVS diode protection, surge & ESD protection

Matching resistor

NC by default, onboard reserved 120R matching resistor, enabled via jumper

Relay

Allow access to load

≤10A 250V AC or ≤10A 30V DC

Relay channels

1 Channel

Contact form

1NO (Normally Open)

Isolation type

Optocoupler isolation

Indicator

PWR

Red power indicator, lights up when connected to USB and voltage is detected

Relay

Relay indicator, lights up when the normally open contact closes

RS485

RS485 indicator:
lights up green when the RS485 port sends data;
lights up blue when the RS485 port receives data

Screw terminal power supply

Power input range

5V

Product appearance

enclosure

Rail-mounted protective case

Size

91.6 × 23.3 × 58.7 (mm)

Interfaces

ESP32-S3-Relay-1CH-details-17.png

Upper terminal description

Lower terminal description

Power terminal

Power positive: DC 5V

RS485 screw terminal

A+ signal pin

Power negative

Type-C

For module power supply, firmware downloading and USB communication

B- signal pin

SH1.0

GND

Ground (GND)

Relay terminal

Relay common terminal

3V3

3.3V power output

GPIO2

ESP32-S3 IO pin

Relay NO

GPIO1

ESP32-S3 IO pin

ESP32-S3-Relay-1CH-details-15.png

Schematic Diagram of Device Wiring

ESP32-S3-Relay-1CH-details-7.png

Dimensions

ESP32-S3-Relay-1CH-details-size.jpg

Electrical and Relay Safety Instructions

  • This product must be operated by professional electricians or qualified personnel. During use, ensure electrical safety, leakage protection, and proper insulation.
  • Before installing, maintaining, or replacing the relay device, always turn off the power and unplug the device.
  • Do not attempt to disassemble the relay device to avoid damage or the risk of electric shock.
  • Properly install and place the relay device. Do not use it in humid, overheated, flammable, or explosive environments to prevent accidents caused by improper installation or use.

1. Load Matching

  • Ensure the relay's rated voltage and current match the load. Do not exceed the rated capacity.
  • For inductive loads (motors, coils, lamps, etc.), the starting current may be much higher than the rated current. Choose a relay with sufficient current margin.

2. Short Circuit and Overcurrent Protection

  • Install a fuse or circuit breaker in the relay circuit to prevent damage due to short circuits or accidental overcurrent.
  • Ensure the load circuit has no short circuits during wiring, and select protection components with appropriate current ratings if necessary.

3. Arc and Switching Protection

  • Relay switching generates arcs, which can cause contact wear or welding.
  • For inductive loads, it is recommended to use RC snubber circuits or varistors for arc suppression.

4. Installation Environment

  • Do not use the relay in humid, high-temperature, flammable, explosive, or dusty environments.
  • Install the relay securely to avoid vibrations or shocks that may cause misoperation or damage.

5. Power-Off Operation

  • Always cut off power before maintenance, wiring, or replacing the relay to ensure personnel and device safety.
  • Latching relays are only powered when changing state. Avoid strong vibrations or strong magnetic fields while the relay is unpowered.

6. Status Confirmation

  • After powering on, confirm or reset the relay status as needed to prevent abnormal operation caused by transportation, installation, or external disturbances.
  • Avoid power interruption during relay operation to prevent uncertain status or contact damage.

7. Regular Inspection

  • Periodically inspect relay contacts, terminals, and insulation to ensure proper operation.
  • If abnormal heating, odor, or burn marks are detected, immediately cut off power and replace the relay.

Usage Guide

ESP32-S3-Relay-1CH currently provides Arduino IDE development tool and framework, and you can choose the right development tool according to your project needs and personal habits.

Development Tool

270px-Arduino-IDE-logo.jpg

Arduino IDE

Arduino IDE is an open source electronic prototyping platform, convenient and flexible, easy to get started. After a simple learning, you can start to develop quickly. At the same time, Arduino has a large global user community, providing an abundance of open source code, project examples and tutorials, as well as rich library resources, encapsulating complex functions, allowing developers to quickly implement various functions.


Components Preparation

Before operating, it is recommended to browse the table of contents to quickly understand the document structure. For smooth operation, please read the FAQ carefully to understand possible problems in advance. All resources in the document are provided with hyperlinks for easy download.

Working with Arduino

This chapter introduces setting up the Arduino environment, including the Arduino IDE, management of ESP32 boards, installation of related libraries, program compilation and downloading, as well as testing demos. It aims to help users master the development board and facilitate secondary development.
Arduino-flow-04.png

Environment Setup

Download and Install Arduino IDE

  • Click to visit the Arduino official website, select the corresponding system and system bit to download
    ESP32-S3-AMOLED-1.91-Ar-software-01.png
  • Run the installer and install all by default

Install ESP32 Development Board

  • Regarding ESP32-related motherboards used with the Arduino IDE, the 'esp32 by Espressif Systems library must be installed first.
  • According to Board installation requirement, it is generally recommended to use Install Online. If online installation fails, use Install Offline
  • For the installation tutorial, please refer to Arduino board manager tutorial
  • ESP32-S3-Relay-1CH required development board installation instructions
Board name Board installation requirement Version number requirement
esp32 by Espressif Systems "Install Offline" / "Install Online" 3.0.x

Install Library

  • When installing Arduino libraries, there are usually two ways to choose from: Install online and Install offline. If the library installation requires offline installation, you must use the provided library file
    For most libraries, users can easily search and install them through the online library manager of the Arduino software. However, some open-source libraries or custom libraries are not synchronized to the Arduino Library Manager, so they cannot be acquired through online searches. In this case, users can only manually install these libraries offline.
  • For library installation tutorial, please refer to Arduino library manager tutorial
  • ESP32-S3-Relay-1CH library file is stored in the demo, click here to jump: ESP32-S3-Relay-1CH Demo
  • ESP32-S3-Relay-1CH library file installation instructions
Library Name Description Version Library Installation Requirement
ArduinoJson Lightweight JSON library v6.21.4 "Install Online" or "Install Offline"
PubSubClient MQTT message subscription publishing library v2.8.0 "Install Online" or "Install Offline"
NTPClient Network time synchronization client library v3.2.1 "Install Online" or "Install Offline"

Run the First Arduino Demo

If you are just getting started with ESP32 and Arduino, and you don't know how to create, compile, flash, and run Arduino ESP32 programs, then please expand and take a look. Hope it can help you!

New Project

  • Run the Arduino IDE and select File -> New Sketch
    ESP32-S3-AMOLED-1.91-Ar-study-01.png
  • Enter the code:
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Hello, World!");
  delay(2000);
}
  • Save the project and select File -> Save As.... In the pop-up menu, select the path to save the project, and enter a project name, such as Hello_World, click Save

ESP32-S3-AMOLED-1.91-Ar-study-02.png

Compile and Flash Demos

  • Select the corresponding development board, take the ESP32S3 motherboard as an example:

①. Click to select the dropdown menu option Select Other Board and Port;
②. Search for the required development board model esp32s3 dev module and select;
③. Select COM Port;
④. Save the selection.
ESP32-S3-AMOLED-1.91-Ar-study-03.png

  • If the ESP32S3 mainboard only has a USB port, you need to enable USB CDC, as shown in the following diagram:

ESP32-S3-AMOLED-1.91-Ar-study-04.png

  • Compile and upload the program:

①. Compile the program; ②. Compile and download the program; ③. Download successful.
ESP32-S3-AMOLED-1.91-Ar-study-05.png

  • Open the Serial Monitor window, and the demo will print "Hello World!" every 2 seconds, and the operation is as follows:

ESP32-S3-AMOLED-1.91-Ar-study-06.png

Demo

Demo-flow-01.png

  • ESP32-S3-Relay-1CH demos
Demo Basic Description Dependency Library
01_MAIN_WIFI_AP RS485 interface control, Bluetooth control, Bluetooth send IP, Web page control (short distance) Can be flashed directly
Web pages are only available if they are connected to device WIFI
02_MAIN_WIFI_STA RS485 interface control, Bluetooth control, Bluetooth send IP, Web page control (short distance) Need to modify the WIFI network to connect to
Web pages can only be used within the intranet
03_MAIN_WIFI_MQTT RS485 interface control, Bluetooth control, Bluetooth transmit IP, Waveshare cloud control (long distance) Need to modify the WIFI network to connect to
The device must be created in the Waveshare cloud
04_MAIN_ALL RS485 interface control, Bluetooth control, Bluetooth send IP, Web page control (short distance), Waveshare cloud control (long distance) Need to modify the WIFI network to connect to
The device must be created in the Waveshare cloud
Web pages can only be used within the intranet

Arduino Project Parameter Setting

ESP32-S3-Relay-6CH-demo-10.png

01_MAIN_WIFI_AP

Demo description


  • This demo implements the control of 1 relay switch through WiFi, Bluetooth, and RS485. The AP mode of WiFi is enabled in this demo

Precautions


  • Can be flashed directly
  • Web pages are only available if they are connected to device WIFI

RS485 Control


Bluetooth Control


Web Page Control


02_MAIN_WIFI_STA

Demo description


  • This example implements the control of 1 relay switch through WiFi, Bluetooth, and RS485. The STA mode of WiFi is enabled in this example

Precautions


  • Need to modify the WIFI network to connect to
  • The Web page only supports controlling the device and this product to be used under the same network, if you use the mobile phone control, you need to turn off the mobile network

RS485 Control


Bluetooth Control


Web Page Control


03_MAIN_WIFI_MQTT

Demo description


  • This example controls 1 relay through MQTT, Bluetooth, and RS485 communication methods. It uses ESP32 as the main control unit, supports Wi-Fi and Bluetooth connections, and provides remote control based on the MQTT protocol

Precautions


  • Need to modify the the WIFI network to connect to
  • Must create the device in Waveshare Cloud

RS485 Control


Bluetooth Control


Waveshare Cloud Control


04_MAIN_ALL

Demo description


  • This example is a collection of RS485 interface control, Bluetooth control, Web page control (near distance), and Waveshare cloud control (long distance).

Precautions


  • Need to modify the the WIFI network to connect to
  • The Web page only supports controlling the device and this product to be used under the same network, if you use the mobile phone control, you need to turn off the mobile network
  • Must create the device in Waveshare Cloud

RS485 Control


Bluetooth Control


Web Page Control


Waveshare Cloud Control


External Expansions

RS485 Extended Relay Channels

  • Use Modbus RTU Relay to extend 8-ch relay
  • The 4 main example files are compatible with this operation, and the Extension_Enable in WS_imformification. h needs to be set to 1 (default is 1)
  • Externally extended relays can be controlled via Bluetooth
Operation Command Command Function
06 01 Switch the CH1 relay status of Modbus RTU Relay
06 02 Switch the CH2 relay status of Modbus RTU Relay
06 03 Switch the CH3 relay status of Modbus RTU Relay
06 04 Switch the CH4 relay status of Modbus RTU Relay
06 05 Switch the CH5 relay status of Modbus RTU Relay
06 06 Switch the CH6 relay status of Modbus RTU Relay
06 07 Switch the CH7 relay status of Modbus RTU Relay
06 08 Switch the CH8 relay status of Modbus RTU Relay
06 09 Turn on all relays of Modbus RTU Relay
06 0A Turn off all relays of Modbus RTU Relay
  • The commands for Bluetooth control relay are characters 1-8, which are hexadecimal 0x06 0x01 ~ 0x38 0x0A
  • Click the SEND button and fill in the data to be sent (currently hexadecimal sending), enter 0x06 0x01 as below

ESP32-S3-Relay-6CH TO Extension 1.png

  • Send 0x06 0x01 to control relay CH1 for status reversal

ESP32-S3-Relay-6CH TO Extension 2.png

  • Send 0x06 0x0A to control to turn off all relays

ESP32-S3-Relay-6CH TO Extension 3.png


Flash Firmware Flashing and Erasing

  • The current demo provides test firmware, which can be used to test whether the onboard device functions properly by directly flashing the test firmware
  • bin file path:
    ..\ESP32-S3-Relay-1CH\Firmware\Factory bin

Working with Homeassistant

The product can be controlled online through the Homeassistant built on the Raspberry Pi, and the relevant operations can be found in Reference link

Resources

Demo

Schematic

Datasheets

ESP32-S3

Software Tools

Arduino

VScode

Thonny

Debugging Tools

Other Resource Links

FAQ

 Answer:
  • Long press the BOOT button, press RESET at the same time, then release RESET, then release the BOOT button, at this time the module can enter the download mode, which can solve most of the problems that can not be downloaded.


 Answer:
  • It may be due to Flash blank and the USB port is not stable, you can long-press the BOOT button, press RESET at the same time, and then release RESET, and then release the BOOT button, at this time the module can enter the download mode to flash the firmware (demo) to solve the situation.


 Answer:
  • It's normal for the first compilation to be slow, just be patient


 Answer:
  • If there is a reset button on the development board, press the reset button; if there is no reset button, please power it on again


 Answer:
  • Some AppData folders are hidden by default and can be set to show.
  • English system: Explorer->View->Check "Hidden items"
  • Chinese system: File Explorer -> View -> Display -> Check "Hidden Items"


 Answer:
  • Windows system:

①View through Device Manager: Press the Windows + R keys to open the "Run" dialog box; input devmgmt.msc and press Enter to open the Device Manager; expand the "Ports (COM and LPT)" section, where all COM ports and their current statuses will be listed.
②Use the command prompt to view: Open the Command Prompt (CMD), enter the "mode" command, which will display status information for all COM ports.
③Check hardware connections: If you have already connected external devices to the COM port, the device usually occupies a port number, which can be determined by checking the connected hardware.

  • Linux system:

①Use the dmesg command to view: Open the terminal.
①Use the ls command to view: Enter ls /dev/ttyS* or ls /dev/ttyUSB* to list all serial port devices.
③Use the setserial command to view: Enter setserial -g /dev/ttyS* to view the configuration information of all serial port devices.



 Answer:
  • Check the schematic diagram for different development boards with Type-C interfaces, and handle the output accordingly:
    • For development boards with direct USB output, printf function is supported for printing output. If you want to support output via the Serial function, you will need to enable the USB CDC On Boot feature or declare HWCDC.
    • For development boards with UART to USB conversion, both printf and Serial functions are supported for printing output, and there is no need to enable USB CDC On Boot.


 Answer:
  • The factory demo is for learning only, if it is used for practical application, please optimize the demo logic by yourself.


 Answer:
  • Please move the jumper cap to 120R and try again. Some RS485 devices require a 120R resistor to be connected in series


Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)