ESP32-S3-Relay-6CH

From Waveshare Wiki
Jump to: navigation, search
ESP32-S3-Relay-6CH
ESP32-S3-Relay-6CH.jpg

6CH
RS485, Pico, USB
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Overview

Electrical Safety Precautions

  • This product must be operated and used by professional electricians or technical personnel. During use, please ensure electrical safety and take measures to prevent leakage and insulation.
  • Before installing, maintaining, or replacing relay equipment, be sure to turn off the power and unplug the plug.
  • Do not attempt to disassemble relay equipment to avoid damaging the equipment or causing the risk of electric shock.
  • Please install and place the relay equipment product properly. Do not use it in damp, overheated, or flammable environments to avoid safety incidents caused by improper installation or use.

Parameter

Items Parameters
Supply Voltage 7~36V (or 5V/1A Type-C Interface)
Relay channels 6 CH
Contact form 1NO 1NC
Interface Type-C
Communication Protocol USB Protocol
Dimensions 88(H) x 122(V)mm

Onboard Interface

GPIO Control Function Description
GP0 BOOT Key BOOT Key Control Pin
GP21 BUZZER Buzzer Control Pin
GP38 RGB RGB LED Control Pin
GP1 CH1 Relay No.1 Control Pin
GP2 CH2 Relay No.2 Control Pin
GP41 CH3 Relay No.3 Control Pin
GP42 CH4 Relay No.4 Control Pin
GP45 CH5 Relay No.5 Control Pin
GP46 CH6 Relay No.6 Control Pin
GP17 TXD UART TX pin, converted to RS485
GP18 RXD UART RX pin, converted to RS485

Multifunction Control

Example Analyze

  • Here we provide four examples for performing the following functions. Users can write their examples to realize other functions, these examples provided are only for simple operation of the device.
  • The factory default demo is MAIN_WIFI_AP.
File Function Note
MAIN_WIFI_AP RS485 Interface Control Support directly programmed
Only support when the Web interface connects to WIFI
Bluetooth Control, Bluetooth sends IP
Web Interface Control (Close)
MAIN_WIFI_STA RS485 Interface Control Only support after modify
Require WIFI connection after Modify
Web page for intranet use only
Bluetooth control, Bluetooth sends IP
Web Interface Control (short-distance)
MAIN_WIFI_MQTT RS485 Interface Control Only support after modify
Require WIFI connection after Modify
Require Create device on Waveshare cloud platform
Bluetooth Control, Bluetooth sends IP
Waveshare Cloud Control (long-distance)
MAIN_ALL RS485 Interface Control Only support after modify
Require WIFI connection after Modify
Require Create device on Waveshare cloud platform
Web page for intranet use only
Bluetooth control, Bluetooth sends IP
Web Interface Control (short-distance)
Waveshare Cloud Control (long-distance)

Preparation

Please note that you need to ensure that the ESP32 firmware version is 3.0.0 or below (the current example firmware version is 2.0.11), otherwise it will fail to compile.
ESP32-S3 TO Arduino 3.png

Parameter Setting

  • Set Flash size and partition:

ESP32-S3-Relay-6CH-Para.png

Install Library Files

  • Install ArduinoJson library:

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

  • Install PubSubClient library:

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

  • Install NTPClient library:

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

Demo Modify

  • There is a WS_Information.h file in each example, please change the content of the file to user information.
  • Take MAIN_ALL as an example:

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

  • Open WS_Information.h file:

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

  • Modify the WIFI name "Waveshare-TL" and the WIFI password "waveshare".
  • For example, change the WIFI name to be connected as "Waveshare-WIFI", and the password is "123456789", as shown below:

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

  • If you need to control relays on the Waveshare cloud platform, the device needs to be created first.
  • Modify the related data according to the devices on the Waveshare cloud platform.

ESP32-S3-Relay-6CH TO Burnprocess 4.png

  • The modification is as follows:

ESP32-S3-Relay-6CH TO Burnprocess 5.png

Demo Flash

  • Demo modification is complete, after connecting the device, select the development board and COM port.

ESP32-S3-Relay-6CH TO Burnprocess 6.png ESP32-S3-Relay-6CH TO Burnprocess 7.png

  • Click to flash.

ESP32-S3-Relay-6CH TO Burnprocess 8.png

RS485 Control

Connect the RS485 device to ESP32-S3-Relay-6CH, send commands to ESP32-S3-Relay-6CH for each relay ON/OFF, and the baud rate is 115200 by default.

Command Function
06 05 00 01 55 00 A2 ED Switch CH1 relay ON/OFF
06 05 00 02 55 00 52 ED Switch CH2 relay ON/OFF
06 05 00 03 55 00 03 2D Switch CH3 relay ON/OFF
06 05 00 04 55 00 B2 EC Switch CH4 relay ON/OFF
06 05 00 05 55 00 E3 2C Switch CH5 relay ON/OFF
06 05 00 06 55 00 13 2C Switch CH6 relay ON/OFF
06 05 00 FF FF 00 BD BD All relays ON
06 05 00 FF 00 00 FC 4D All relays OFF

Hardware Connection

   Take USB TO 4CH Serial Converter for example:

ESP32-S3-Relay-6CH USB TO 4CH Serial Converter - PORT B
RS485 - A+ Port B - A+
RS485 - B- Port B - B-

Software Operation

  • Sending data through SSCOM.
  • Open SSCOM, and select the COM port corresponding to Port B connected as above.

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

  • Open COM, and use the multiple send function to quickly send commands.

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

  • With the following commands, you can control the relays.

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

Web Interface control

Connect your mobile phone to ESP32-S3-Relay-6CH with Bluetooth Debugging Assitant, and then get the IP after the WIFI connection, you can enter the Web interface with this IP.

AP Mode

  • Connect to ESP32-S3-Relay-6CH's WIFI, and the WIFI name is "ESP32-S3-Relay-6CH", and the password is "waveshare".
  • Get Current IP through Bluetooth Debugging Assistant.
  • Enter the Web interface, and you can control relays. (It takes a little while to configure the device after powering up, and the first time you enter the web page after each power-up may be slow.)

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

STA Mode

  • After power on, it automatically connects to the configured WIFI ( Before programming, you need to Modify WIFI to be Connected)
  • Get Current IP through Bluetooth Debugging Assistant.
  • Enter the Web interface, and you can control relays. (It takes a little while to configure the device after powering up, and the first time you enter the web page after each power-up may be slow.)

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

Bluetooth Control

Use your mobile phone to connect ESP32-S3-Relay-6CH through Bluetooth Debugging Assistant, and send commands to ESP32-S3-Relay-6CH for controlling all relays ON/OFF.
Please note that some Bluetooth debugging assistants send data in ASCII form by default, you need to enter the correct control commands according to the Bluetooth debugging assistant before controlling the device.

Command Function
ASCII Hex
1 0x31 Switch CH1 Relay ON/OFF
2 0x32 Switch CH2 Relay ON/OFF
3 0x33 Switch CH3 Relay ON/OFF
4 0x34 Switch CH4 Relay ON/OFF
5 0x35 Switch CH5 Relay ON/OFF
6 0x36 Switch CH6 Relay ON/OFF
7 0x37 ALL Relays ON
8 0x38 ALL Relays OFF

Software Operation (Get IP)

  • Use nRF Connect on your phone to control relays (or you can use other Bluetooth Debugging Assistants).
  • Take nRF Connect as an example:
  • Bluetooth name: ESP32 S3 Relay 6CH.

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

  • After connection, select "Unknown Service", and click to read the data. If the WIFI fails to be connected for a long time, the RGB turns red and is always on. This step does not have any response.
  • After connecting to WIFI, it receives the device IP. As shown below, the Device IP is 192.168.6.133.

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

  • Bluetooth control relay commands are characters 1~8, i.e. hexadecimal 0x31 ~ 0x38.
  • Click to "send", fill in the data to be sent (currently sent in hexadecimal), and enter 0x31 as follows:

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

  • Send "0x31" to switch the CH1 relay status.

ESP32-S3-Relay-6CH TO Bluetooth 4.png

  • Send "0x38" to control all relays OFF.

ESP32-S3-Relay-6CH TO Bluetooth 5.png

Waveshare Cloud Platform

Create Device

ESP32-S3-Relay-6CH TO Cloud 0.png

  • Then, enter "Devices Manager" to "Add New" device, and fill in "Type Name":

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

  • Created successfully.

ESP32-S3-Relay-6CH TO Cloud 73.png

  • Create another device by "One-click Add" -> "Common Device Template".

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

  • Edit "Enter Device Name":

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

  • Click to edit and select its device type.

ESP32-S3-Relay-6CH TO Cloud 4.png ESP32-S3-Relay-6CH TO Cloud 6.png

  • Save.

ESP32-S3-Relay-6CH TO Cloud 7.png

  • Then, you can see the device details. Modify WS_Information.h file and Flash it before using.

ESP32-S3-Relay-6CH TO Burnprocess 4.png

Software Operation

ESP32-S3-Relay-6CH TO Waveshare cloud 1.png

  • Select the corresponding device option and "Enter Development".

ESP32-S3-Relay-6CH TO Waveshare cloud 2.png

External Expansion

RS485 Expand Relay Channel

  • Use Modbus RTU Relay to expand the 8-ch relay.
  • The 4 main example files are already compatible with this operation, you need to set Extension_Enable in WS_imformation.h to 1 (default is 1).
  • Externally expandable relays can be controlled via Bluetooth.
Operation Command Function
06 01 Switch Modbus RTU Relay's CH1 relay ON/OFF
06 02 Switch Modbus RTU Relay's CH2 relay ON/OFF
06 03 Switch Modbus RTU Relay's CH3 relay ON/OFF
06 04 Switch Modbus RTU Relay's CH4 relay ON/OFF
06 05 Switch Modbus RTU Relay's CH5 relay ON/OFF
06 06 Switch Modbus RTU Relay's CH6 relay ON/OFF
06 07 Switch Modbus RTU Relay's CH7 relay ON/OFF
06 08 Switch Modbus RTU Relay's CH8 relay ON/OFF
06 09 ALL Modbus RTU Relay's relays ON
06 0A ALL Modbus RTU Relay's relays OFF
  • Bluetooth control relay commands are characters 1~8, i.e. hexadecimal 0x06 0x01 ~ 0x38 0x0A.
  • Click to send, fill in the data to be sent (currently sent in hexadecimal), as follows: 0x06 0x01.

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

  • Send 0x06 0x01 to switch CH1 relay status.

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

  • Send 0x06 0x0A to switch all relays OFF.

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

Working with Pico for Timer Switch Function

  • Use Pico-RTC-DS3231 to expand the timer switch function.
  • Connect Pico-RTC-DS3231 to ESP32-S3-Relay-6CH.
  • The 4 main example files are already compatible with this operation. What you need to do is to set "RTC_Enable" in "WS_imformation.h" to 1 (The default setting is 0, please make sure it is connected to Pico-RTC-DS3231).

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

  • Set RTC_OPEN_Time_Hour, RTC_OPEN_Time_Min, RTC_Close_Time_Hour, and RTC_Close_Time_Min in WS_imformation.h to the operation time.
Items Parameters
RTC_OPEN_Time_Hour All relay timing switch ON --in hours
RTC_OPEN_Time_Min All relay timing switch ON --in minutes
RTC_Closs_Time_Hour All relay timing switch OFF --in hours
RTC_Closs_Time_Min All relay timing switch OFF --in minutes
  • The following settings are set to open at 08:06 and close at 16:30 every day.

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

Working with Pico for Expanding CAN Interface

  • Use Pico-CAN-B to expand the CAN communication interface.

Preparation

  • Install mcp_can library:

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

User Manual

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

  • In the main program, use the files WS_MCP2515.c and WS_MCP2515.h.
  • After including, you can use the functions receiveCANData(uint32_t* canId, uint8_t* data) and sendCANData(uint32_t canId, uint8_t len, uint8_t* data) in the main program for CAN data receiving and CAN data sending, respectively.

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

Working with Pico For Expanding Environment Monitoring Function

Preparation

  • Install Adafruit BME280 library:

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

  • Select "Install All".

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

  • Install Adafruit TSL2591 library:

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

  • Select "Install All":

ESP32-S3-Relay-6CH TO Extension4 4.png

  • Install Adafruit LTR390 library:

ESP32-S3-Relay-6CH TO Extension4 8.png

  • Select "Install All":

ESP32-S3-Relay-6CH TO Extension4 9.png

  • Install Adafruit SGP40 library:

ESP32-S3-Relay-6CH TO Extension4 10.png

  • Select "Install All":

ESP32-S3-Relay-6CH TO Extension4 11.png

How to Use

Working with Pico for Expanding RS232/RS485 Interface

  • Please note that when using the Pico-2CH-RS485 expansion with the RS485 interface, only Channel 1 is supported. Channel 0 is not available for use.
  • Use Pico-2CH-RS232 to expand RS232 interface.

How to Use

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

  • Currently, real-time printing of received characters is enabled.
  • Call the initialization function Extension_Init() in setup.
  • After calling, you can send data in the main loop demo using the functions SetData2(uint8_t* data, size_t length) and SetData3(uint8_t* data, size_t length).

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

Use in Micropython

Flash Firmware Demo

  • Download and unzip the MicroPython firmware: (Flash Tool and Firmware).
  • Connect the device to the PC.
  • Open the flash_download_tool_3.9.4.exe software, select ESP32-S3 and USB.

ESP32-S3-Relay-6CH TO MicroPython Firmware 1.png

  • Select the corresponding COM port, as we have configured it well, just click on "Start" to download. (If the COM port is not identified, please press and hold the BOOT key, press the RESET key, and then release the RESET key first.)

ESP32-S3-Relay-6CH TO MicroPython Firmware 2.png

  • If you encounter downloading delays or the download doesn't start, you can enter Download mode, press and hold the BOOT key while pressing the RESET key, and then release the RESET key first. Try to download it again, and wait for the flashing process to complete.

ESP32-S3-Relay-6CH TO MicroPython Firmware 3.png

Preparation

Thonny

  • Install Thonny (Thonny IDE)
  • Open Thonny, click on "Python x.x.x" at the bottom right, and select "Configure interpreter".

ESP32-S3-Relay-6CH TO MicroPython Environment 1.png

  • In the popup window, select "Interpreter" -> Interpreter select "MicroPython (ESP32)".

ESP32-S3-Relay-6CH TO MicroPython Environment 2.png

  • Save the setting.

ESP32-S3-Relay-6CH TO MicroPython Environment 3.png

  • Click to stop, Shell window appears "MicroPython v1.22.1 on 2024-01-05;Generic ESP32S3 module with ESP32S3 Type "help()" for more information.", which means the connection is successful.

ESP32-S3-Relay-6CH TO MicroPython Environment 4.png

Demo Upload

ESP32-S3-Relay-6CH TO MicroPython Environment 5.png

  • View the file path.

ESP32-S3-Relay-6CH TO MicroPython Environment 6.png

  • Enter Path to the example file on Thonny.

ESP32-S3-Relay-6CH TO MicroPython Environment 7.png

  • Press Ctrl and select all files on the directory, right-click and select "Upload to/".

ESP32-S3-Relay-6CH TO MicroPython Environment 8.png

  • Waiting for the uploading to finish.

ESP32-S3-Relay-6CH TO MicroPython Environment 9.png

  • After uploading successfully, you can see the uploaded file in the device file window, the current example can realize the Bluetooth control device, according to your own needs for secondary development.

ESP32-S3-Relay-6CH TO MicroPython Environment 10.png

Resource

Schematic

Document

Demo

Software

Related application

FAQ

 Answer:

Please try moving the jumper cap to the 120R position. Some RS485 devices require a 120-ohm resistor to be connected in series for proper communication.

{{{5}}}


 Answer:

To resolve most of the download issues, you can try the following steps:
While keeping the BOOT button pressed, press the RESET button.
Release the RESET button first, then release the BOOT button.
This will put the module into download mode and should resolve most download issues.

{{{5}}}


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)