ESP32-S3-Relay-6CH
| ||
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.
Parameter Setting
- Set Flash size and partition:
Install Library Files
- Install ArduinoJson library:
- Install PubSubClient library:
- Install NTPClient library:
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:
- Open WS_Information.h file:
- 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:
- 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.
- The modification is as follows:
Demo Flash
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.
- Open COM, and use the multiple send function to quickly send commands.
- With the following commands, you can control the relays.
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.)
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.)
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.
- 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.
- 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:
- Send "0x31" to switch the CH1 relay status.
- Send "0x38" to control all relays OFF.
Create Device
- Login to Waveshare cloud.
- Then, enter "Devices Manager" to "Add New" device, and fill in "Type Name":
- Created successfully.
- Create another device by "One-click Add" -> "Common Device Template".
- Edit "Enter Device Name":
- Click to edit and select its device type.
- Save.
Software Operation
- Go to Waveshare website, and enter Waveshare Cloud.
- Complete registration and create device.
- Modify the corresponding MQTT and WIFI.
- Demo Flash.
- Enter "Dashboard" on the Waveshare Cloud Platform.
- Select the corresponding device option and "Enter Development".
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.
- Send 0x06 0x01 to switch CH1 relay status.
- Send 0x06 0x0A to switch all relays OFF.
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).
- 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.
Working with Pico for Expanding CAN Interface
- Use Pico-CAN-B to expand the CAN communication interface.
Preparation
- Install mcp_can library:
User Manual
- Connect Pico-CAN-B to ESP32-S3-Relay-6CH.
- Download Pico-CAN-B example demo.
- Modify it according to your needs.
- 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.
Working with Pico For Expanding Environment Monitoring Function
- Use Pico-Environment-Sensor to expand the environment monitoring function.
Preparation
- Install Adafruit BME280 library:
- Select "Install All".
- Install Adafruit TSL2591 library:
- Select "Install All":
- Install Adafruit LTR390 library:
- Select "Install All":
- Install Adafruit SGP40 library:
- Select "Install All":
How to Use
- Connect the Pico-Environment-Sensor to ESP32-S3-Relay-6CH.
- Download Pico-Environment-Sensor sample demo
- Use Environment_Sensor.c and Environment_Sensor.h in the main demo.
- Modify them according to your needs.
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
- Connect Pico-2CH-RS232 or Pico-2CH-RS485 to ESP32-S3-Relay-6CH.
- Download Pico-2CH-RS232 example demo (This demo is compatible with the above two devices.)
- In the main program, include the file WS_UART.h.
- Modify it according to your needs.
- 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).
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.
- 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.)
- 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.
Preparation
Thonny
- Install Thonny (Thonny IDE)
- Open Thonny, click on "Python x.x.x" at the bottom right, and select "Configure interpreter".
- In the popup window, select "Interpreter" -> Interpreter select "MicroPython (ESP32)".
- Save the setting.
- 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.
Demo Upload
- Download MicroPython sample demo.
- Open the file window on Thonny.
- View the file path.
- Enter Path to the example file on Thonny.
- Press Ctrl and select all files on the directory, right-click and select "Upload to/".
- Waiting for the uploading to finish.
- 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.
Resource
Schematic
Document
Demo
Software
Related application
FAQ
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}}}
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)