Modbus POE ETH Relay
| ||
Hardware Sescription
Hardware Connection
- Connect the Modbus POE ETH Relay to the LAN via a network cable, and supply power through the power port or the POE.
Electrical Safety Precautions
- This product should be operated and used by professional electricians or technical personnel. During use, please ensure electrical safety and take protective measures such as anti-leakage and insulation.
- Before installing, maintaining, or replacing relay equipment, make sure to turn off the power and unplug the device.
- Do not attempt to dismantle relay equipment to avoid damaging the device or risking electric shock.
- Please properly install and place the relay equipment. Avoid using it in damp, overly hot, or flammable environments to prevent safety accidents due to improper installation or use.
Indicator Light Description
Indicator | Status description |
RUN indicator | Ethernet port running indicator, outputs a square wave with a period of 2 seconds when the Ethernet port working normally. |
STA indicator | MCU indicator, blinking when the MCU working normally. |
TXD indicator | Send indicator, lights up when sending data. |
RXD indicator | Receive indicator, lights up when receiving data. |
Ethernet port green indicator | The green indicator will be on when TCP connection is established, which can be used to determine whether the module has established a communication link with the host software. |
Ethernet port yellow indicator | Data activity indicator, when data is transmitted through the Ethernet port, the yellow indicator changes its state, which can be used to determine if there is data transmission. |
Software Installation
Vircom can be used to configure parameters such as device IP and create virtual serial ports. If you don't need the virtual serial port function, you can download the installation-free version of the configuration software only.
- VirCom_en : Configuration software (English version)
- Virtual-serial-port : Virtual serial port driver
- Sscom5.13.1_for_Modbus_POE_ETH_Relay: Sscom Software
- Modbus Poll : Modbus Poll software
To install the driver, you need to unzip it, double-click the software to install. If the virtual serial port is not displayed in Vircom, restart it and check again.
Example Demonstration
TCP Communication Test
Software Preparation
Host Computer Setting
Modbus POE ETH Relay connects to the hardware and connects to the network. Run the Vircom software (the computer on which Vircom is installed must be on the same LAN as the module).
The operation is as follows:
- ① Click
Device
- ② Click
Auto Search
- ③ The software search identifies the Modbus POE ETH Relay device connected to the LAN
- ④ Select the device, and then click
Edit Device
or double-click the searched device directly - ⑤ Set the working parameters of the device:
- Click the "Local IP" button to identify the IP address of the computer, modify the "IP address" to a static assigned address, and note that the static IP address entered is not used by other devices, and it needs to be on the same LAN as the computer.
- The working mode is TCP server. The serial port setting is 115200 by default and cannot be modified.
- The "Transfer Protocol" in
Advanced Settings
defaults to none, which means using the Modbus RTU protocol; if you select Modbus_TCP protocol, then Modbus TCP protocol is selected.
- Click the "Local IP" button to identify the IP address of the computer, modify the "IP address" to a static assigned address, and note that the static IP address entered is not used by other devices, and it needs to be on the same LAN as the computer.
- ⑥ Once the settings are complete, click
Modify Setting
- ⑦ Click
Restart Dev
, wait for the module to restart, and the new settings will take effect.
See the figure below for details:
- Finally click "Modify Setting" to save and apply the setting.
TCP Communication Test
- Open the serial debugging assistant window, select TCPClient for the port number, modify the remote IP and port number according to the above Vircom settings, click the "Connect" button to connect to the TCP server, the green light of the network port will light up after successful connection.
- Click on multiple strings, and you can open multiple string-sending windows, clicking on the functions will send the corresponding commands.
- For detailed control commands, please see the development protocol.
Modbus Poll Software
- The serial port software is not convenient to observe the data, you can choose Modbus Poll software to read the data. Download and install the Modbus Poll software.
- Open the software, select Setup->Read/Write Definition, select the actual device address for Slave ID, select 01 Read Coils function code for Function, and change Quantity to 8 channels. Click OK to confirm.
- Select Connection->Connect..., select Modbus RTU/ASCII Over TCP/IP for Connection, select RTU for Mode, and enter the correct IP address and port number. Click OK to connect.
- After the connection is normal, you can check the current relay status. Select the corresponding channel, then double-click the status value to pop up the send page. Choose On or Off, then Click Send to control the relay opening and closing.
Virtual Serial Port Test
The SSCOM2 in the diagram communicates directly with the serial port server via TCP. In order to allow users to communicate with the serial port server using their existing serial port software, a virtual serial port needs to be added between the user program and the serial port server. As shown in the diagram, Vircom and the user program run on the same computer. Vircom virtualizes a COM port that corresponds to the serial port server. When the user program opens the COM communication, it can send data to the user's serial port device through the Vircom serial port server. The following steps demonstrate this operation:
- Click on "Serial Port Management" on the Vircom main interface, then click "Add" and select to add COM2. Among them, COM2 is the newly emerging COM port on the computer.
- Then enter the device management and double-click the device that needs to be bound to COM2. As shown in the diagram, select COM2 from the Virtual Serial Port list in the top left corner. Then click on "Modify Setting" and then click on "Restart Dev".
- Return to the main interface of Vircom. You can see that COM2 is already connected to the device with IP 192.168.1.200. At this point, you can use COM2 to communicate instead of SSCOM2.
- Open it on the computer, open the corresponding port number, and set the baud rate as 115200. Click Multi-String to open the Multi-String Send window, and click the function to send the corresponding command.
MODBUS TCP Test
By default, data is transparently transmitted using the Modbus RTU protocol. If you need to implement Modbus TCP to RTU conversion, you need to select the Transfer protocol as "Modbus TCP Protocol" in the Device Settings dialog, as shown in the diagram below. In this case, the device port automatically changes to 502. Users can connect their Modbus TCP tool to the IP of the serial port server on port 502, and the Modbus TCP commands they send will be converted to RTU commands and outputted through the serial port.
For example, if the server's Ethernet port receives a Modbus TCP command of 00 00 00 00 00 06 01 05 00 00 FF 00 (to turn on the first relay), the host controller will receive the Modbus RTU command of 01 05 00 00 FF 00 8C 3A.
- Click on "More Advanced Settings..." and select the Modbus Gateway Type as a non-storage Modbus gateway.
Note: The default Modbus gateway type is storage type, which will automatically send query commands several times, which may cause the controller chip not to respond, and the query commands will not be affected. Therefore, you need to set it as Multi-host non-storage type.
- Open the Sscom software, click on the Import ini button in the Send Multi-Char column, and select the Modbus tcp.ini file to import.
If the error "A component named HEX0 already exists" is displayed, close the software and reopen it, then re-import the file.
- After successful import, the following is displayed, click on the function to send the corresponding command.
- Please refer to the Modbus TCP protocol section later for more details on Modbus TCP conversion.
WEB Configuration
Using Vircom, you can search and configure device parameters in different network segments. For Web configuration, you must first ensure that the computer and the serial server are in the same IP segment, and you need to know the IP address of the serial server in advance. But web configuration can be done on any computer without Vircom. (Different products have different web interfaces, which can be switched between Chinese and English)
1. Enter the IP address of the serial server in the browser, such as http://192.168.1.200 to open the following web page
2. Enter password in "Password": There is no login password set by default in the factory, you can enter a password at will, and click the Login button to log in. After setting the password to log in, the settings at "Modify Web Login Key" will take effect:
3. The serial server parameters can be modified on the web page that appears. For the relevant parameters, please refer to Table 4 for the meaning of the parameters.
4. After modifying the parameters, click the "Submit" button.
5. If the configuration web page files are overwritten during the configuration and downloading of MQTT and Jetson Modbus firmware, causing the configuration web page to be inaccessible, please follow these steps to re-download the web page files:
- Configuration Interface Web Files to Modbus POE ETH Relay.
Demos
Raspberry Pi
Connect the Raspberry Pi and the ModBus POE ETH Relay module to the same LAN.
Open the Raspberry Pi terminal and run the program by entering the following command:
sudo apt-get install unzip wget https://files.waveshare.com/wiki/Modbus%20POE%20ETH%20Relay/Modbus_POE_ETH_Relay_Code.zip unzip Modbus_POE_ETH_Relay_Code.zip cd Modbus_POE_ETH_Relay_Code #modbus rtu protocol vi modbus_rtu.py #Change the IP address and port number according to the actual situation sudo python3 modbus_rtu.py #modbus tcp protocol vi modbus_tcp.py #Change the IP address and port number according to the actual situation sudo python3 modbus_tcp.py
Note: To run this demo, you need to modify the demo file to change the IP address and port number to the actual IP address and port number of the ModBus POE ETH Relay.
Modbus RTU Development Protocol V2
Function Code Introduction
Function Code | Description | Note |
---|---|---|
01 | Read coil status | Read relay status |
03 | Read holding register | Read the address and version |
05 | Write single coil | Write single relay |
06 | Write single register | Set the baud rate and address |
0F | Write multiple coils | Write all relays |
Register Address Introduction
Address (HEX) | Address storage content | Register value | Permission | Modbus Function Code |
---|---|---|---|---|
0x0000 …… 0x0007 |
Channel 1~8 relay address | 0xFF00: relay on 0x0000: relay off 0x5500: relay toggle |
Read/Write | 0x01, 0x05, 0x0F |
0x00FF | Control all relays | 0xFF00: all relays on 0x0000: all relays off 0x5500: all relays toggle |
Write | 0x05 |
0x0100 …… 0x0107 |
Channel 1~8 relay toggle address | 0xFF00: relay toggle 0x0000: relay unchanged |
Write | 0x05, 0x0F |
0x01FF | Control all relays toggle | 0xFF00: all relays toggle 0x0000: all relays unchanged |
Write | 0x05 |
0x0200 …… 0x0207 |
Channel 1~8 relay flash on | Interval time: data*100ms Value: 0x0007, Interval time: 7*100MS = 700MS |
Write | 0x05 |
0x0400 …… 0x0407 |
Channel 1~8 relay flash off | Interval time: data*100ms Value: 0x0007, Interval time: 7*100MS = 700MS |
Write | 0x05 |
4x4000 | Device Address | Directly store Modbus address Device address: 0x0001 |
Read | 0x03 |
4x8000 | Software Version | Converting to decimal and then shifting the decimal point two places to the left will represent the software version 0x0064 = 100 = V1.00 |
Read | 0x03 |
Operation Command Introduction
Control Single Relay
Send code: 01 05 00 00 FF 00 8C 3A
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Relay control |
00 00 | Address | The register address of the relay to be controlled, 0x0000-0x0007 |
FF 00 | Command | 0xFF00: relay on; 0x0000: relay off; 0x5500: relay toggle |
8C 3A | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Return code: 01 05 00 00 FF 00 8C 3A
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Relay control |
00 00 | Address | The register address of the relay to be controlled, 0x0000-0x0007 |
FF 00 | Command | 0xFF00: relay on; 0x0000: relay off; 0x5500: relay toggle |
8C 3A | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example:
[Address 1 device]:
Relay 0 on: 01 05 00 00 FF 00 8C 3A Relay 0 off: 01 05 00 00 00 00 CD CA Relay 1 on: 01 05 00 01 FF 00 DD FA Relay 1 off: 01 05 00 01 00 00 9C 0A Relay 2 on: 01 05 00 02 FF 00 2D FA Relay 2 off: 01 05 00 02 00 00 6C 0A Relay 3 on: 01 05 00 03 FF 00 7C 3A Relay 3 off: 01 05 00 03 00 00 3D CA Relay 0 toggle: 01 05 00 00 55 00 F2 9A Relay 1 toggle: 01 05 00 01 55 00 A3 5A Relay 2 toggle: 01 05 00 02 55 00 53 5A Relay 3 toggle: 01 05 00 03 55 00 02 9A
Control All Relays
Send code: 01 05 00 FF FF 00 BC 0A
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Relay control |
00 FF | Address | Fixed 0x00FF |
FF 00 | Command | 0xFF00: relay on; 0x0000: relay off; 0x5500: relay toggle |
BC 0A | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Return code: 01 05 00 FF FF 00 BC 0A
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Relay control |
00 FF | Address | Fixed 0x00FF |
FF 00 | Command | 0xFF00: relay on; 0x0000: relay off; 0x5500: relay toggle |
BC 0A | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example: [Address 1 device]:
All relays on: 01 05 00 FF FF 00 BC 0A All relays off: 01 05 00 FF 00 00 FD FA All relays toggle: 01 05 00 FF 55 00 C2 AA
Read Relay Status
Send code: 01 01 00 00 00 08 3D CC
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
01 | 01 Command | Query relay status |
00 00 | Relay Start Address | The register address of the relay, 0x0000 - 0x0007 |
00 08 | Relay Number | The number of relays to be read, which must not exceed the maximum number of relays |
3D CC | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Receive code: 01 01 01 00 51 88
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
01 | 01 Command | Query relay status |
01 | Byte Number | The number of all bytes of the returned status information |
00 | Query status | Received relay status Bit0: the first relay status; Bit1: the second relay status; And so on, with the idle high bit being zero |
51 88 | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example: [Address 1 device]
Send: 01 01 00 00 00 08 3D CC Receive: 01 01 01 00 51 88 //all relays off Send: 01 01 00 00 00 08 3D CC Receive: 01 01 01 01 90 48 //Relay 0 is on, others are off Send: 01 01 00 00 00 08 3D CC Receive: 01 01 01 41 91 B8 //Relay 0 and 6 are on, others are off
Write Relay Status
Send code: 01 0F 00 00 00 08 01 FF BE D5
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
0F | 0F Command | Write relay status |
00 00 | Relay Start Address | The register address of the relay to be controlled, 0x0000 - 0x0007 |
00 08 | Relay Number | The number of relays to be operated, which must not exceed the maximum number of relays |
01 | Byte Number | The byte number of the status |
FF | Relay Status | Bit0: the first relay status; Bit1: the second relay status; And so on, with the idle high bit being zero |
BE D5 | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Receive code: 01 0F 00 00 00 01 94 0B
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
0F | 0F Command | Control all registers |
00 00 | Relay Start Address | The register address of the relay to be controlled, 0x0000 - 0x0007 |
00 08 | Relay Number | The number of relays to be operated |
54 0D | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example: [Address 1 device]
All relays on: 01 0F 00 00 00 08 01 FF BE D5 All relays off: 01 0F 00 00 00 08 01 00 FE 95 0-1 on; 2-7 off: 01 0F 00 00 00 08 01 03 BE 94
Relay Flash ON/OFF Command
Send code: 01 05 02 00 00 07 8D B0
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Single control command |
02 | Command | 02: flash on, 04: flash off |
00 | Relay Address | The address of the relay to be controlled, 0x00~0x07 |
00 07 | Interval Time | The interval time: data*100ms Value: 0x0007, Interval time: 7*100MS = 700MS The maximum setting for the flash-on flash-off time is 0x7FFF |
8D B0 | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Receive code: 01 05 02 00 00 07 8D B0
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Single control command |
02 | Command | 02: flash on, 04: flash off |
00 | Relay Address | The address of the relay to be controlled, 0x00~0x07 |
00 07 | Interval Time | The interval time: data*100ms Value: 0x0007, Interval time: 7*100MS = 700MS |
8D B0 | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example: [Address 1 device]
Relay 0 flash on: 01 05 02 00 00 07 8D B0 //700MS Relay 1 flash on: 01 05 02 01 00 08 9C 74 //800MS Relay 0 flash off: 01 05 04 00 00 05 0C F9 //500MS Relay 1 flash off: 01 05 04 01 00 06 1D 38 //600MS
Read Software Version Command
Send code: 01 03 80 00 00 01 AD CA
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
03 | 03 Command | Read Holding Register |
80 00 | Command register | 0x8000: read software version |
00 01 | Byte Number | Fixed 0x0001 |
AD CA | CRC16 | The CRC16 checksum of the first 6 bytes of data |
Receive code: 01 03 02 00 64 B9 AF
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
03 | 03 Command | Read Holding Register |
02 | Byte Number | The number of bytes returned |
00 64 | Software Version | Converting to decimal and then shifting the decimal point two places to the left will represent the software version 0x0064 = 100 = V1.00 |
F0 B8 | CRC16 | The CRC16 checksum of the first 6 bytes of data |
For example:
Send: 01 03 80 00 00 01 AD CA Receive: 01 03 02 00 C8 B9 D2 //0x00C8 = 200 =V2.00
Exception Function Code
When the received command is incorrect or the device is abnormal, an exception response will be returned in the following format:
Receive: 01 85 03 02 91
Field | Description | Note |
---|---|---|
01 | Device Address | 0x00 indicates the broadcast address, 0x01-0xFF indicates the device address |
85 | Exception Function Code | Exception function code = Request function code + 0x80 |
03 | Byte Number | Exception Code |
02 91 | CRC16 | The CRC16 checksum of the first 6 bytes of data |
An exception code is a single-byte value that indicates the type of error. Several commonly used exception codes defined by the Modbus protocol:
Exception Code | Name | Description |
---|---|---|
0x01 | Illegal Function | The requested function code is not supported |
0x02 | Illegal Data Address | The requested data address is incorrect |
0x03 | Illegal Data Value | The requested data value or operation cannot be executed |
0x04 | Server Failure | Server equipment failure |
0x05 | Response | The request has been received and is being processed |
0x06 | Device Busy | The device is currently busy and cannot perform the requested operation |
Modbus TCP Development Protocol
Here is a brief introduction to Modbus TCP and Modbus RTU protocol conversion using the above commands to open the first relay as an example.
- Modbus RTU command: 01 05 00 00 FF 00 8C 3A
Field | Description | Note |
---|---|---|
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Relay control |
00 00 | Address | The register address of the relay to be controlled, 0x00, that is, the first relay |
FF 00 | Command | 0xFF00: Relay on |
8C 3A | CRC16 | The CRC16 checksum of the first 6 bytes of data |
- Modbus TCP command: 00 00 00 00 00 06 01 05 00 00 FF 00
Field | Description | Note |
---|---|---|
00 00 | Message Label | Both be 0x00 |
00 00 | modbus Label | Must both be 0, which means this is Modbus communication |
00 06 | Byte Length | Indicates the number of all bytes that follow, followed by 6 bytes |
01 | Device Address | Fixed 0x01 |
05 | 05 Command | Relay control |
00 00 | Address | The register address of the relay to be controlled, 0x00, that is, the first relay |
FF 00 | Command | 0xFF00: Relay on |
By comparing the commands above, we can observe that to convert a Modbus RTU command to Modbus TCP protocol, the CRC check is removed, and the command is prefixed with five 0x00 bytes followed by a byte representing the length.
Advanced Applications - MQTT Connected Cloud Platform
Resources
Demo
Software
- VirCom
- Virtual-serial-port : Virtual serial port driver
- Sscom5.13.1_for_Modbus_POE_ETH_Relay: Sscom Software
- Modbus Poll software
- SecureCRT software
Related resources
FAQ
Operating temperature: -15℃ ~ 70℃
{{{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)