Waveshare RS485 TO ETH Manual
Hide thumbs Also See for RS485 TO ETH:

Advertisement

485 TO ETH (B) User Manual
RS485 TO ETH (B)
MQTT and JSON Manual
1 / 36
www.waveshare.com

Advertisement

Table of Contents
loading

Summary of Contents for Waveshare RS485 TO ETH

  • Page 1 485 TO ETH (B) User Manual RS485 TO ETH (B) MQTT and JSON Manual 1 / 36 www.waveshare.com...
  • Page 2: Table Of Contents

    3.11. Data change reporting....................23 3.12. JSON issuance.......................24 3.13. 645 Timing of the agreement..................25 4. JSON to Modbus RTU......................26 5. MQTT............................ 28 5.1. Device configuration......................28 5.2. Data Test.........................33 6. MQTT+JSON to Modbus RTU....................34 7. HTTP POST/GET+JSON....................34 2 / 36 www.waveshare.com...
  • Page 3: Overview

    Suppose there is a Modbus table with a function code of 3 and an address of 1. Its register addresses and parameter names are as follows. Where the byte length is 4, it means that 2 registers need to be read continuously. 3 / 36 www.waveshare.com...
  • Page 4: Device Configuration

    2.3. DEVICE CONFIGURATION We configure the device as a client. Use the serial port tool to monitor a TCP server on port 1883 of the local computer. 4 / 36 www.waveshare.com...
  • Page 5 Figure 1 Socket simulated server receiving data Use Vircom to configure the device. Figure 2 Device configuration Click Modify configuration to connect the device to the SocketDlgTest tool. Enter device editing again dialog box. Click the "Firmware and Configuration" button. 5 / 36 www.waveshare.com...
  • Page 6 The design file will be saved in this directory and can be downloaded to the device by clicking the "download" button later. Click the "JSON Configuration" button. Figure 4 JSON configuration main interface 6 / 36 www.waveshare.com...
  • Page 7 Now click the "Add/View" button. For the first row of the previous Modbus table: Register Parameter name Byte Remarks address length Current total active Unsigned,keep 2 decimal energy places The corresponding configuration is as follows: Figure 5 Register settings 7 / 36 www.waveshare.com...
  • Page 8 Modbus function code: currently supports 03 and 04 function codes. c) Register address: the corresponding 0 here. d) Data length: This corresponds to 4 bytes. e) Data format: This corresponds to an unsigned integer. f) Keep the decimal point: 2 digits are reserved here. 8 / 36 www.waveshare.com...
  • Page 9 Here, click the "Design Next" button to continue designing other registers in the Modbus table. After all the registers in the form are designed, click "Finish Design", and then click "Save JSON Configuration" to exit. Then click the "download button" on the "download web" page 9 / 36 www.waveshare.com...
  • Page 10: Create A New Modbus Analog Meter

    Then click "OK" and the device will automatically restart. If there is no restart, please restart manually. 2.4. CREATE A NEW MODBUS ANALOG METER Here, Modbus Slave is used to simulate a meter Figure 7 Test results 10 / 36 www.waveshare.com...
  • Page 11: Json Complex Example

    NTP_SERVER1 and NTP_SERVER2. After saving, ntp.txt and other files are downloaded to the inside of the device. 3.2. NESTED JSON DESIGN Suppose we need to design the following JSON: {"header":{"DEVID":"285301020304", "time":" 2019-05-13 22:23:31"}, "data": {"id":"MyData123456", "alarm":{"alarm1":123.4C "alarm2":567.8C 11 / 36 www.waveshare.com...
  • Page 12 7. Enter step 2.2.1 to design "alarm1": 123.4C, this is a Modbus data with unit, the function code is 3, the register is 0, then the design is shown in the figure: Figure 8 Register design 12 / 36 www.waveshare.com...
  • Page 13: Read The Bits Of The Byte Register

    0x8183, then bit16, bit9, bit8, bit2 and bit1 are included. All are 1. These bits have different meanings. When they are 1, they indicate different alarms. So you also need to upload with different json keywords. Methods as below: 13 / 36 www.waveshare.com...
  • Page 14: And 02 Function Codes

    01/02 function code itself is read For bit selection, since only 1 bit is read at a time, the position of the Boolean value is generally written with 1, if it is 1, it will display '1', otherwise it will display '0'. 14 / 36 www.waveshare.com...
  • Page 15: Show Design Results

    Now click "Save JSON Design" to design and you can see the content of the designed JSON format in the display box, which is convenient for overview of the design. At the same time, there is an index for comparison when entering "Add/View". Figure 11 shows the results 15 / 36 www.waveshare.com...
  • Page 16: Excel Editing

    EXCELL, then save it as CSV, and then import it. However, CSV has formatting issues: Figure 13 Data format error At this time, you can save the CSV as XLS format for editing. After editing, save as CSV format and import. 16 / 36 www.waveshare.com...
  • Page 17: Brackets And Arrays

    Since reqBody itself is an object, not an array unit, the node type is selected as an object Data, not array data. Since its content is an array, according to the brackets are braces The idea is that the data source of this reqBody is "nested JSON". Then click "Design Nested JSON". 17 / 36 www.waveshare.com...
  • Page 18 "Save all and exit". Go back to the previous interface and click "Save JSON Settings", then download it. The data posted is: {"reqBody":[2,3]}. Now look at a more complicated example: "reqBody": "workshop_id:"1008", "machine_code":"XS114" "workshop_id:"1008", "machine_code":"XS116" 18 / 36 www.waveshare.com...
  • Page 19 Modbus format, but the data content here is a JSON object, so you need to select the data source as "nested JSON", and then click "Design nested JSON". Figure 17 Step 1.1 19 / 36 www.waveshare.com...
  • Page 20 1.1.3), click "Return to the previous level" to enter "1.2". 1.1.3 here is actually a non-existent node. "1.2" is also an array type, and the data source is nested JSON, please refer to step 1.1. After that until "1.2.2", click "Save all and exit" directly. 20 / 36 www.waveshare.com...
  • Page 21: Cannot Read And Clear

    Figure 21 Step 1.1.3 3.8. CANNOT READ AND CLEAR When a register cannot be read, a data value of 0 can be used to indicate that the data has not been read. Figure 22 Clear data 21 / 36 www.waveshare.com...
  • Page 22: Device Offline

    1. In this way, even if the data read is 0, it will be 1 as long as the data read. That is, online1 has only two data, 0 and 1. 1 means online, 0 means offline. 22 / 36 www.waveshare.com...
  • Page 23: Pan And Zoom

    The data change here can be configured for each JSON node, and can be used to 23 / 36 www.waveshare.com...
  • Page 24: Json Issuance

    JSON issuance realizes the matching of a single JSON keyword and the output of the corresponding Modubs command. This does not require that the issued string matches exactly, but as long as there are corresponding JSON keywords and related data in the issued data. 24 / 36 www.waveshare.com...
  • Page 25: 645 Timing Of The Agreement

    The time service of the 645 protocol is 68 99 99 99 99 99 99 68 08 06 SS MM HH DD MM YY CS 16, where SS MM HH DD MM YY are seconds, minutes, hours, days, months, and years. 25 / 36 www.waveshare.com...
  • Page 26: Json To Modbus Rtu

    05 command multiple times. According to the length of the number of bytes, the system will automatically select the 06 or 16 command to send. Here are examples of setting coils and setting registers. 26 / 36 www.waveshare.com...
  • Page 27 02 and the coil starting with register 03. Then in: JSON to Modbus interface, click "JSON Delivery" Figure 28 Enter JSON to send The configuration interface is as follows: pay attention to the alert: "on setting that needs to be written. Figure 29 Configure coil 27 / 36 www.waveshare.com...
  • Page 28: Mqtt

    MQTT. At the same time, the payload of MQTT will be output from the serial port in a transparent way. Realize serial port to MQTT. 5.1. DEVICE CONFIGURATION First search for the device, then click Edit Device: 28 / 36 www.waveshare.com...
  • Page 29 MQTTHTTPD directory, and then click "Clear All" to clear the previous design (note that if the previous design was designed according to JSON, do not clear all, otherwise the previous design will be cleared. JSON design). Then click MQTT configuration. 29 / 36 www.waveshare.com...
  • Page 30 8 Save MQTT settings: After designing, click this button to save, and then click the "download button" in the web page download directory to download. Now click "MQTT advanced parameters" (generally no need to configure advanced parameters): 30 / 36 www.waveshare.com...
  • Page 31 0 to prevent disconnection caused by retransmission. 11 Whether to save the publication: whether the server keeps the last message (if there is a new client subscription, it will be sent to the client) 31 / 36 www.waveshare.com...
  • Page 32 MQTT settings: Figure 36 Automatic modification If there is no automatic modification, you need to set the destination IP, working mode, and destination port in the device edit dialog box. Then click "Edit Settings". 32 / 36 www.waveshare.com...
  • Page 33: Data Test

    After the connection is completed, the LINK light (usually the blue light in the middle) of the device turns on. It indicates that the device is normally connected to the MQTT server. Now open the serial port tool: Figure 38 Serial port sending and receiving 33 / 36 www.waveshare.com...
  • Page 34: Mqtt+Json To Modbus Rtu

    (such as Modbus RTU) commands to the MQTT server. In addition, you can also use the JSON function, using automatic Modbus RTU format collection, and regular JSON format uploading. In addition, you can also find WAVESHARE to customize some non-standard instruments and host computer protocol formats.
  • Page 35 Other JSON structure design methods are the same as the methods introduced before. After clicking the "Save JSON Settings" button, if POST/GET is selected, HTTP header format information will be added in front of the JSON data to support the HTTP transmission protocol. 35 / 36 www.waveshare.com...
  • Page 36 485 TO ETH (B) User Manual This POST/GET design method is simple and practical, and it can simply and quickly realize the transmission of Modbus RTU and other instrument data to the server by means of HTTP POST/GET+JSON. 36 / 36 www.waveshare.com...

Table of Contents