How to Achieve Modbus RTU to/over TCP between Linovision LoRaWAN Gateways and Controllers

Andy Chen

Description

Modbus RTU bridge LoRaWAN is a feature which can set up Modbus-LoRaWAN data transmission between Linovision controllers and Modbus TCP/TCP clients via  Linovision LoRaWAN gateways. The basic procedures are as follows:

  1. Send Modbus TCP/RTU reading or writing commands from a TCP client or Modbus TCP client
  2.  Linovision gateways receive commands and translate them to Modbus RTU commands, then forward to  Linovision controllers via LoRaWAN
  3.  Linovision controllers receive and response the commands and return the results
  4.  Linovision gateways receive the results and send to TCP client directly or translate to Modbus TCP results and send to Modbus TCP client

 

Requirements
  • Linovision Controllers: IOT-C501
  • IOT-G6x LoRaWAN Gateways 
  • Toolbox Software
  • NetAssit (TCP Client simulate tool or Modbus Doctor (Modbus TCP client simulate tool)
  • Modbus Slave or other Modbus RTU devices (meters, sensors, etc.)

 

Step-by-step:

1. Linovision Controller Configuration

2. Linovision Gateway Configuration

3. TCP Client/Modbus TCP Configuration

3.1 TCP Client Configuration

3.2 Modbus TCP Configuration

4. Test

4.1 Transmission between Controllers and RS485 Devices

4.2 Send Query from Gateway

4.3 Send Query from TCP Client

4.4 Read to Modbus TCP

4.5 Write from Modbus TCP

Configuration

1. Linovision Controller Configuration

Before powering on Linovision controllers, please connect your Modbus RTU devices to RS485 port of controllers.

With Linovision controllers connected to PC with USB cable, open Toolbox. Select the USB port and type login password. The default password is 123456.

Navigate to General > RS485 page, enable Modbus RS485 bridge LoRaWAN and configure the port which is specified for bridging. In this example we use 200 as Modbus RS485 bridge LoRaWAN port.

 

 

 

Navigate to LoRaWAN page and select the working mode as Class C. You could also find essential attributes of the controllers and you would need them to register it onto Linovision gateways.

 

 

2. Linovision Gateway Configuration

Connect Linovision controllers to gateway following article How to Connect LoRaWAN Node/Sensor to Linovision Gateway. When registering devices in Network Server->Device page, select Modbus RTU Data transmission mode as required and type necessary information. If you connect TCP client to gateway and send Modbus RTU commands, select Modbus RTU over TCP; if you connect Modbus TCP client to gateway and send Modbus TCP commands, select Modbus RTU to TCP.

NOTE: Please type the Fport as Modbus RS485 bridge LoRaWAN port (In this example Fport is 200). TCP Port is used for allowing TCP client or Modbus TCP master connection.

3. TCP Client/Modbus TCP Configuration

3.1 TCP Client Configuration

Open NetAssist on PC, type in IP address of gateway as IP address of TCP server, Server Port should be the same as the TCP Port in gateway. Click Connect to connect the client to gateway.

 

3.2 Modbus TCP Configuration

Open Modbus Doctor on PC, type in IP address of gateway as IP address of Modbus TCP server, NumPort should be the same as the TCP Port in gateway. Click CLOSE, choose CONNECTION.

 

 

 

 

4. Test

Modbus over/to TCP share the same topology, except that the protocol in TCP client side is different. Testing Modbus over TCP is using original Modbus and TCP/IP. While testing Modbus to TCP we introduce Modbus TCP/IP (also Modbus-TCP) which is simply the Modbus RTU protocol with a TCP interface that runs on Ethernet.

 

4.1 Transmission between Controllers and RS485 Devices

Connect controller RS485 port to PC and stimulate serial data with Modbus Slave.

In Toolbox, configure a Modbus channel to poll data from Modbus Slave tool. If you can read data, the communication is on.

 

 

 

4.2 Send Query from Gateway

Use the following Modbus example to test the communication between gateway and controller.

Query frame:

 

Slave ID Function Address Length Parity
0x01 0x03 0x00 0x00 0x00 0x02 0xC4 0x0B

 

Response frame:

Slave ID Function Length Data Parity
0x01 0x03 0x04 0x00 0x01 0x00 0x02 0x2A 0x32

 

Go to Network Server > Packets page, put in controller Device EUI and Port 200, select type as hex, then click Send to send Modbus command to controller.

 

 

A: gateway sends Modbus downlink successfully

B: Reply from controllers

C: ACK package from controllers

 

The details of reply packet is shown below:

 

4.3 Send Query from TCP Client

Send Modbus RTU format command 010300000002c40b to read first two digit of data, gateway (TCP server) will respond the Modbus reply 010304000100022A32.

In web GUI of gateway, you can check the details that sending the message from TCP client and receiving the replies from controllers.

 

 

Click the exclamation mark to see packets details, payload in hex matches what TCP client receives and is correctly “1,2”.

 

4.4 Read to Modbus TCP

Enable SPY MODE and click CONNECTION, see it’s printed in status:

Status: Connecting to 192.168.23.226:9099...

Status: Connected

 

As Modbus Slave has 10 addresses for default so we set Length as 10 too, click READING. You can see the query frame in darker blue and response frame in lighter one in the traffic communication block on the right.

 

 

Here is a data table of Modbus TCP communication protocol.

 

Query Frame Response Frame
Byte Content Byte Content
0-4 Start 0-4 Start
5 Whole Length 5 Whole Length
6 Slave ID 6 Slave ID
7 Function Code 7 Function Code
8, 9 Start Address 8 Data Length
9, 10 Data
10, 11 Address Length 11, 12 Data
... Data

 

According to the table we can tell the data read from Modbus RTU is 1,2 which is correct. In web GUI of gateway, you can check the details that sending the message from TCP client and receiving the replies from controllers.

 

 

4.5 Write from Modbus TCP

Modbus Doctor supports writing to Modbus RTU. You can input random number in Value of each Register, click WRITING. You can read the communication traffic according to the table above.

 

 

In Modbus Slave, you can see the value has changed correspondingly.

Read more →

How to Connect LoRaWAN Nodes to Linovision Gateway

Andy Chen

Description

Linovision IoT gateway has built-in network server. When network server is enable, users can add LoRAWAN nodes/sensors to gateway and check the data directly. This article will guide you how to connect LoRaWAN nodes/sensors to Linovision Gateway.


Requirement

  • Linovision LoRaWAN Gateway IOT-G6x or G8x.
  • LoRaWAN Node/Sensor (take Linovision IOT-S500TH as example).

Make sure sensor and gateway support the same LoRa frequency such as US915.


Configuration

1. Before configuration, make sure the LoRaWAN node/sensor is not activated in other network servers. Take IOT-S500-TH as example, run Linovision Toolbox App on smart phone via NFC or open Toolbox on PC via USB Type-C to makes sure Join Status of the sensor is De-Activate.

 

 

2. Go to Packet Forwarder -> General to enable localhost server.

Click Save & Apply.

 

3. Go to Network Server -> General to enable built-in Network Server.

Click Save & Apply.

 

4. Go to Network Server -> Applications to add application.

Name & Description: user-defined.

 

5. Go to Network Server -> Profiles to add a profile.

Name: user-defined.

Join Type & Class Type: same as the ones on the sensor.

 

6. Go to Network Server -> Deviceto add sensors.

Device Name & Description: user-defined.

Device EUI: the Device EUI of the sensor. For Linovision sensors, you can find it on the label or  ToolBox.

Device-Profile & Applications: the ones you added in the above steps.

Application Key (AppKey): the application key of the sensor. For Linovision sensors, it’s a general one (5572404c696e6b4c6f52613230313823). You can also find it on user guide.

 

If Join Type is ABP, please fill in  below parameters:

Device Address: the 5th to 12th digits of SN of sensor.

Network Session Key (NwkSKey)/Appcation Session Key (AppSKey): for Linovision sensors, it’s a general one (5572404C696E6B4C6F52613230313823). You can also find it on user guide.

Click Save & Apply.

 

7. After the sensor joins the gateway successfully, you can see it’s Activated.

 

Go to Network Server -> Packets of Linovision Gateway to check uplink data that sensor reports.

 

You can also see Join Status is Activate from corresponding software.

--END--

Read more →