• sales

    +86-0755-88291180

Modbus POE ETH Relay MQTT User Guide

Hardware Connection

  • Connect the Modbus POE ETH Relay to the LAN via a network cable and power it through the power port or through POE.


Software Preparation

Get Started to Communicate

  • Register an account to access the Alibaba Cloud IoT Platform and activate a public instance.


  • Click Device Management -> Products -> Create a product, enter the product name, the example name is Waveshare, and choose a custom category to belong to. Other defaults are available.


  • After creating the product, click View Product Details below to enter the product page and select the Topic category list to go to the Topic page to add a custom topic.


  • Select Topic class list -> Custom Topic -> Define Topic class, create a publish topic send to send data.


  • To subscribe to a topic and receive data.


  • Select Device Management -> Devices -> Add Device. Add a device named 'Relay', which is a relay module.


  • For testing, you can add a device named mqttx device, the Ali cloud web page can only send text data and can not send binary data, so use mqttx software to facilitate debugging.


  • After adding the devices, you can view two devices named "mqttx" and "relay" in the device list. Click on "View" to enter the page for the "Relay" device.


  • Select "Device Information" -> "MQTT Connection Parameters" to view the MQTT connection parameters.


  • Open Vircom -> Device Management -> left mouse click on the corresponding device -> Firmware and Configuration -> MQTT Configuration and enter the configuration page.


  • Configure the connection parameters based on the Relay device MQTT connection information. When the configuration is complete, select Save MQTT Settings and click Download again.



    • Note: You can get the AliCloud IP address by pinging mqttHostUrl.


    • Set the target IP and target port, and click Modify Settings to save. Note: If the local port is 0 then you need to modify a non-zero port, otherwise you cannot connect.


    • After a successful connection, you can see that the Relay device has gone from inactive to online.


    • Download the MQTTX software and install it, creat a new connection after successful installation.


    • Create a new connection based on the mqttx device MQTT connection parameters.


    • Add a subscription after a successful connection.


    • Enter the sent topic, select hex to send and hex display, and send the data.


    • Select Monitor Ops -> Log Services -> Cloud Operation Log to check the information received from the cloud and select hex to display.


    • At this point, both the Relay device and the mqttx device have been connected to the cloud platform, but it is not yet possible to control the relays through the mqttx software, and finally, message forwarding needs to be added.
    • Select Message Forwarding -> Cloud Product Flow -> Data Source -> Create Data Source, the data source name is mqttx-send.


    • Go to edit page, add Topic, select custom, waveshare product, mqttx device, user/send topic.


    • Select Message Forwarding -> Cloud Product Flow -> Data Source -> Create Data Source and then add a data source with the name of relay-send.


    • Go to edit page, add Topic, select custom, waveshare product, relay device, user/send topic.


    • Select Message Forwarding -> Cloud Product Flow -> Data Destination -> Create Data Destination, the data destination name is mqttx-receive.


    • Select Message Forwarding -> Cloud Product Flow -> Data Source -> Create a data source and then add a data destination with the name of relay-receive.


    • Select Message Forwarding -> Cloud Product Flow -> Parser -> Create a parser with the name mqttx-to-relay.


    • Open mqttx-to-relay edit page -> Data Source -> Associated Data Source,Data Source select mqttx-send


    • Data destination -> associate data destination->data destination selection relay-receive


    • Parser script, add the following code and publish, where 1005 is the relay-receive data destination ID, /ipl390TLRtl/Relay/user/receive is the relay receive topic, needs to be more practical to modify.
    //Through the payload function, get the message content reported by the device and convert the payload data into binary variables for pass-through
    var data = payload("binary");
    //Forwarding data to relays
    writeIotTopic(1005, "/ipl390TLRtl/Relay/user/receive", data);
    


    • Select Message Forwarding -> Cloud Product Flow -> Parser -> Create Parser then create a parser with the name relay-to-mqttx.


    • Open mqttx-to-relay edit page -> data source -> associate data source, data source select relay-send.


    • Data Destination -> Associate Data Destination -> Data Destination Select mqttx-receive.


    • Parser script, add the following code and publish, where 1004 is the mqttx-receive data destination ID, /ipl390TLRtl/mqttx/user/receive is the mqttx receive topic, need to be more practical to modify.
    //Through the payload function, get the message content reported by the device and convert the payload data into binary variables for pass-through
    var data = payload("binary");
    //Forwarding data to relays
    writeIotTopic(1004, "/ipl390TLRtl/mqttx/user/receive", data);
    


    • Finally, select Start Parser to implement data forwarding. Message forwarding is configured and enabled.


    • At this point, you can send commands to control the relays via MQTTX. Send the relay flip command as shown below. Under normal circumstances, the relay will be flipped and the command data will be returned.


    • The operation is now complete. You can try to send more Modbus commands to test. The data flow is shown below.
    • MQTTX sends the command -> AliCloud receives the data and forwards it to relay -> relay receives the data to execute the action and return the data to AliCloud -> Ali cloud receives data and forwards to mqttx -> MQTTX receives the return data.
    TAG: X1003 Raspberry Pi 5 PCIe to M.2 NVMe SSD MINI Adapter Board HAT Pi5 2242 2230 RP2040 DDSM115 Direct Drive Servo Motor All-In-One Design Hub RS485 Motor Raspberry Pi 7 inch HMI industrial DSI Display LCD 7inch TouchScreen Computer 720×1280 Raspberry Pi Touch Display 2 Official Original Capacitive TouchScreen 7 inch LCD TFT 720x1280 HDMI to RGB 2.8inch Round LCD USB Monitor Computer Monitor Display Screen USB Type C Secondary Screen PC CPU GPU Raspberry Pi 5 Pure-Copper Active Cooler ESP32 S3 Development Board 1.75 inch AMOLED Display TouchScreen SD slot 6-axis sensor Xiaozhi AI Deepseek Serial UART Bus Servo ST3215-HS 20KG.CM High Speed Magnetic Encoder 360° Large Torque Serial UART Bus Servo ST3215 30KG.CM/19.5KG.CM Magnetic Encoder 360° High Precision And Large Torque ESP32-P4-ETH RJ45 POE DSI/MIPI 10.1 inch LCD Display Touchscreen/CSI Camera/Audio Speaker AI Deepseek Program WiFi Wireless ESP32 DDSM Motor Driver HAT For Direct Drive Servo Hub Motors For Raspberry Pi SpotPear ESP32-S3 1.43inch AMOLED Display AI Development Board 466×466 1.43 inch TouchScreen Deepseek Raspberry Pi Pico Screen Tang-Nano-20K-FPGA-Unboxing ESP32-S3 Industrial-Grade WiFi Relay IOT RS485 Communicator Bluetooth ESP32-S3