Stufin
Home Quick Cart Profile

Waveshare Modbus RTU 8-channel Relay Module RS485

Buy Now

Communication Protocol

Modbus RTU

Baudrate

1200/2400/4800/9600 bps

Relay Type

SPDT (Single Pole Double Throw)

Relay Rating

5A/250VAC or 5A/30VDC

Power Supply

5-24VDC

Power Consumption

1.5W

Operating Temperature

-20C to 70C

Storage Temperature

-40C to 85C

Humidity

5-95% RH

Dimensions

128mm x 85mm x 25mm

Weight

approximately 160g

Documents and Resources

For more information, please refer to the product datasheet, user manual, and technical documentation available on the Waveshare website.

Warranty and Support

The Waveshare Modbus RTU 8-channel Relay Module RS485 is backed by a one-year warranty and supported by Waveshare's dedicated technical support team.

Pin Configuration

  • Waveshare Modbus RTU 8-channel Relay Module RS485 Pinout Explanation
  • The Waveshare Modbus RTU 8-channel Relay Module RS485 is a powerful IoT component that allows remote control of up to 8 relays via Modbus RTU protocol over RS485 communication. The module features a total of 14 pins, which are explained below:
  • 1. VCC (Red Wire) - Power Supply (5V)
  • Description: This pin provides the power supply to the module.
  • Connection: Connect to a 5V power source.
  • 2. GND (Black Wire) - Ground
  • Description: This pin is the ground connection for the module.
  • Connection: Connect to a ground point on your circuit or a ground pin on your microcontroller.
  • 3. TX (Transmit) - RS485 Transmit
  • Description: This pin is used to transmit Modbus RTU data over RS485.
  • Connection: Connect to the RX pin of your RS485 transceiver or another device.
  • 4. RX (Receive) - RS485 Receive
  • Description: This pin is used to receive Modbus RTU data over RS485.
  • Connection: Connect to the TX pin of your RS485 transceiver or another device.
  • 5. A (Address) - Modbus RTU Address Selection
  • Description: This pin is used to set the Modbus RTU address of the module.
  • Connection: Connect to VCC or GND to set the address (see datasheet for address selection table).
  • 6. B (Baud Rate) - Modbus RTU Baud Rate Selection
  • Description: This pin is used to set the Modbus RTU baud rate of the module.
  • Connection: Connect to VCC or GND to set the baud rate (see datasheet for baud rate selection table).
  • 7. RE (Receive Enable) - RS485 Receive Enable
  • Description: This pin is used to enable or disable the RS485 receive function.
  • Connection: Connect to VCC to enable receive, or GND to disable receive.
  • 8. DE (Data Enable) - RS485 Data Enable
  • Description: This pin is used to enable or disable the RS485 data transmission.
  • Connection: Connect to VCC to enable data transmission, or GND to disable data transmission.
  • 9. CH1 (Relay 1) - Relay 1 Output
  • Description: This pin is the output of Relay 1.
  • Connection: Connect to a load or device to be controlled by Relay 1.
  • 10. CH2 (Relay 2) - Relay 2 Output
  • Description: This pin is the output of Relay 2.
  • Connection: Connect to a load or device to be controlled by Relay 2.
  • 11. CH3 (Relay 3) - Relay 3 Output
  • Description: This pin is the output of Relay 3.
  • Connection: Connect to a load or device to be controlled by Relay 3.
  • 12. CH4 (Relay 4) - Relay 4 Output
  • Description: This pin is the output of Relay 4.
  • Connection: Connect to a load or device to be controlled by Relay 4.
  • 13. CH5 (Relay 5) - Relay 5 Output
  • Description: This pin is the output of Relay 5.
  • Connection: Connect to a load or device to be controlled by Relay 5.
  • 14. CH6-8 (Relay 6-8) - Relay 6-8 Outputs
  • Description: These pins are the outputs of Relays 6-8.
  • Connection: Connect to loads or devices to be controlled by Relays 6-8.
  • Connection Structure:
  • To connect the Waveshare Modbus RTU 8-channel Relay Module RS485, follow these steps:
  • 1. Connect VCC to a 5V power source.
  • 2. Connect GND to a ground point on your circuit or a ground pin on your microcontroller.
  • 3. Connect TX to the RX pin of your RS485 transceiver or another device.
  • 4. Connect RX to the TX pin of your RS485 transceiver or another device.
  • 5. Set the Modbus RTU address and baud rate by connecting A and B pins to VCC or GND according to the datasheet.
  • 6. Connect RE and DE pins to VCC or GND to enable or disable the RS485 receive and data transmission functions.
  • 7. Connect the relay output pins (CH1-CH8) to the loads or devices to be controlled by the relays.
  • Important Notes:
  • Make sure to use a proper RS485 transceiver and follow the RS485 communication protocol to communicate with the module.
  • Refer to the datasheet for more information on Modbus RTU address and baud rate selection, as well as relay operation and control.
  • Use proper wiring and termination to prevent signal reflection and ensure reliable communication over RS485.

Code Examples

Waveshare Modbus RTU 8-channel Relay Module RS485 Documentation
Overview
The Waveshare Modbus RTU 8-channel Relay Module RS485 is an IoT component designed to control up to 8 relays remotely through a Modbus RTU protocol using an RS485 communication interface. This module is ideal for industrial automation, building automation, and IoT projects that require remote relay control.
Hardware Specifications
8-channel relay module with LED indicators
 Modbus RTU protocol support
 RS485 communication interface
 Supports 9600, 19200, 38400, and 57600 baud rates
 Power supply: 12V DC
 Operating temperature: -20C to 75C
Software Library
To interact with the Waveshare Modbus RTU 8-channel Relay Module RS485, a Modbus RTU library is required. For this example, we will use the popular pyModbusRTU library.
Code Examples
### Example 1: Controlling Relays using Python (with pyModbusRTU)
In this example, we will use Python to control the relays using the pyModbusRTU library.
```
import pyModbusRTU
# Set up the Modbus RTU connection
modbus = pyModbusRTU.ModbusRTU('COM3', 9600, 8, 'N', 1)  # Replace 'COM3' with your serial port
# Set up the relay module address and function code
slave_address = 1
function_code = 0x05  # Write single coil
# Turn on relay 1
modbus.send(slave_address, function_code, 0x00, 0xFF00)  # Coil 0 is relay 1
# Turn off relay 1
modbus.send(slave_address, function_code, 0x00, 0x0000)
# Close the Modbus connection
modbus.close()
```
### Example 2: Automating Relay Control using a Python Script (with pyModbusRTU and scheduling)
In this example, we will create a Python script that uses the pyModbusRTU library to control the relays at specific times using the schedule library.
```
import pyModbusRTU
import schedule
import time
# Set up the Modbus RTU connection
modbus = pyModbusRTU.ModbusRTU('COM3', 9600, 8, 'N', 1)  # Replace 'COM3' with your serial port
# Set up the relay module address and function code
slave_address = 1
function_code = 0x05  # Write single coil
def turn_on_RELAY_1():
    modbus.send(slave_address, function_code, 0x00, 0xFF00)  # Coil 0 is relay 1
def turn_off_RELAY_1():
    modbus.send(slave_address, function_code, 0x00, 0x0000)
# Schedule the relay control tasks
schedule.every(1).minutes.do(turn_on_RELAY_1)  # Turn on relay 1 every 1 minute
schedule.every(2).minutes.do(turn_off_RELAY_1)  # Turn off relay 1 every 2 minutes
while True:
    schedule.run_pending()
    time.sleep(1)
# Close the Modbus connection when the script is stopped
modbus.close()
```
### Example 3: Controlling Relays using C++ (with libmodbus)
In this example, we will use C++ to control the relays using the libmodbus library.
```
#include <modbus.h>
int main() {
    // Set up the Modbus RTU connection
    modbus_t ctx = modbus_new_rtu("/dev/ttyUSB0", 9600, 'N', 8, 1);  // Replace '/dev/ttyUSB0' with your serial port
    modbus_set_slave(ctx, 1);
// Set up the relay module address and function code
    uint8_t slave_address = 1;
    uint8_t function_code = 0x05;  // Write single coil
// Turn on relay 1
    uint16_t coil = 0x0001;
    modbus_write_bit(ctx, slave_address, function_code, 0x00, &coil);
// Turn off relay 1
    coil = 0x0000;
    modbus_write_bit(ctx, slave_address, function_code, 0x00, &coil);
// Close the Modbus connection
    modbus_free(ctx);
return 0;
}
```
Note: The above code examples are for illustration purposes only and may require modifications to fit your specific project requirements. Additionally, ensure to replace the serial port and other configuration parameters with your actual setup.