E2C Trinity LoRa to Modbus TCP Slave Protocol (Northbound) User Guide

E2C Trinity LoRa to Modbus TCP Slave Protocol (Northbound) User Guide

Document Version: V1.0

Gateways & Firmware Requirement:

SoftwareE2C FieldE2C Facility
Gateways supportingLG3120eLG5120
Firmware Requirement (RobustOS Pro Version)=2.4.111(TBD)

1. Manual Description

1.1 Manual Purpose

This manual guides field technicians to quickly configure the Robustel edge computing gateway to forward collected data from LoRa devices to higher-level systems (such as SCADA, MES, or upper computer software) using the Northbound Modbus TCP Slave protocol.

1.2 Scope of Application

This manual is written for field implementation engineers. You do not need deep theoretical knowledge of the Modbus protocol. By following these step-by-step instructions, you can easily configure the gateway as a Modbus TCP Slave, map internal data tags to Modbus registers, and verify the data using third-party tools.

2. Basic Concepts & Network Topology

Gateway Role: From Collector to Server

In a typical IIoT project, imagine the gateway as a translator between your local sensors and the upper-level system. The data flow consists of two main stages:

First Stage (Southbound): The field LoRa sensors communicate with the gateway wirelessly using radio frequencies. The gateway acts as a LoRaWAN Network Server (LNS), receiving raw data sent by the sensors and parsing/decoding it, then storing the values internally as Tags.

Second Stage (Northbound): The gateway operates as a Modbus TCP Slave on the network. It takes those internal Tags, converts them into standard Modbus register addresses, and exposes them so that a higher-level system, such as SCADA, MES, or a Modbus testing tool like Modbus Slave, can continuously read the values.

3. Preparations

(Note: This document uses the LG3120e gateway and E2C Field software as an example. The configuration process for other supported gateway and software combinations is very similar.)

Before starting the configuration, please ensure the following preparations are met:

3.1 Hardware Device Requirements

DeviceRequirement
GatewayRobustel Gateway with E2C Field / E2C Facility software installed. In this document, we use LG3120e with E2C Field for an example.
Debugging PCA PC used to log into the gateway's Web UI and run the Modbus testing software (Modbus Slave).
Southbound DeviceLoRaWAN sensor(s) (e.g., temperature and humidity sensor) to provide the initial data source.
Ethernet CableStandard Ethernet cable to connect the gateway and the debugging PC.

3.2 Environment and Network Requirements

  • LAN Connectivity: The gateway and the debugging PC must be connected to the same Local Area Network (LAN) (e.g., connected to the same switch or the gateway's LAN ports). LoRa sensors communicate with the gateway wirelessly via radio frequencies and do not require an Ethernet cable.
  • IP Allocation: Ensure all devices requiring IP addresses have valid IP addresses in the same subnet (e.g., 192.168.0.x) and there are no IP conflicts.
  • Port Accessibility: Ensure the PC's firewall allows TCP traffic on the Modbus TCP port you configured (default 502).
  • Modbus Testing Tool: Download and install Modbus Slave on your debugging PC. It is a free, industry-standard tool used to search and verify Modbus TCP Slave data.

4. Prerequisite: Southbound Data Collection

Before forwarding data via Modbus, the gateway must first collect data from the field devices. In this guide, we will use a LoRaWAN temperature and humidity sensor as an example to collect two tags: Temperature and Humidity.

4.1 Logging into E2C Field

  1. Connect your PC to the gateway's LAN port.
  2. Open a web browser and enter the gateway's IP address (the default is usually 192.168.0.1).
  3. Log in with your credentials and click【Edge Computing】 in the gateway's Web GUI to enter the E2C Field interface.
  4. Workflow Overview To set up a new sensor, you need to complete the following steps:
    1. Check if the codec is pre-integrated (Step 1).
    2. If not pre-integrated, obtain and import the codec (Step 2).
    3. Create a Device Profile (Step 3).
    4. Add the LoRaWAN device and associate tags (Step 4).

4.2 Step 1: Check for Payload Codecs

The purpose of this step is to provide the gateway with a "translator" script to convert raw hexadecimal data sent by the sensor into readable data points (e.g., temperature, humidity, or battery level). You only need to do this once per sensor model. Please follow the path below based on your sensor's current status:

Please navigate to LNS Configuration > 【Payload Codecs】.

  • If your sensor model is listed, the codec is already built into the system; please proceed directly to 【4.4 Step 3】.
  • If your sensor is not listed, please proceed directly to 【4.3 Step 2】.

4.3 Step 2: Importing a Payload Codec

The system supports creating custom Codec files through either Add or Copy methods. These operations require the operator to have a technical background in Codec development. This step explains the method of importing a file, which has a lower barrier to entry and broader applicability, to complete the creation of a Payload Codec for the vast majority of standard use cases.

  1. Obtain the Raw Codec File:
    1. Primary Source: Contact the sensor manufacturer directly to obtain the raw Codec file compatible with your specific model.
    2. Public Resources: If the manufacturer does not provide the file directly, you may search for it in these common community repositories:
      - Milesight: https://github.com/Milesight-IoT/SensorDecoders
      - Dragino: https://github.com/dragino/dragino-end-node-decoder
      - Other vendors: https://github.com/TheThingsNetwork/lorawan-devices
  2. Convert Codec File Format: Use the conversion tool to process the raw Codec file into the TOML format supported by E2C Field.
    1. Place the e2c-trinity-codec-converter.exe tool and the extracted raw Codec folder into the same directory.
    2. Run the tool, then select the appropriate 【Vendor】 and 【Model】.
    3. Click 【Generate Codec TOML】 to complete the conversion.

  1. Import to E2C Field:
    1. Navigate to 【LNS Configuration】 > 【Payload Codecs】 > 【Import Codec】 > 【Import from file】.
    2. Upload the generated TOML file.
    3. Mandatory Testing (Critical Step): This step verifies the decoding logic and determines which data points are available for your device.
      1. Go to the 【Uplink Test】 tab, input the sample hex payload provided in your sensor’s manual, and click 【Run Decode】.
      2. You must ensure the system successfully outputs the JSON result. Please note that the data points available to your device are entirely dependent on the output of this Run Decode process. For example, if your Codec file theoretically supports 50 data points, but the hex payload only successfully parses 2 points during the test, then the device will only possess those 2 data points after binding to this Profile.
      3. If your sensor supports downlink control, please perform the same test under the 【Downlink Test】 tab.
      4. Once the test is successful, you must click 【Publish】 to save the codec; otherwise, it will not take effect.

4.4 Step 3: Create a Device Profile

Purpose of this step: To define the shared network settings for a specific model of sensor. Instead of typing the frequency and join settings for 100 identical sensors, you create one Profile and apply it to all of them.

  1. Go to 【LNS Configuration】>【Device Profiles】>【Create New】.
  2. Configure the parameters based on your sensor's manual according to the table below:
Parameter NameConfiguration DescriptionRecommended / Example Value
Payload CodecThe translator script you verified in Step 1.e.g., AM102_Codec
NameA recognizable name for this model template.e.g., Profile_AM102_EU868
Description(Optional) Brief details about this profile's purpose.e.g., Milesight AM102 sensor profile
RegionThe LoRa radio frequency band applicable to your physical location.e.g., EU868, US915, AS923
MAC VersionThe LoRaWAN protocol version supported by the sensor (check the sensor datasheet).e.g., 1.0.3
Regional parameters revisionThe revision of the LoRaWAN Regional Parameters specification the sensor complies with. Must be correct to avoid MAC errors.e.g., A, B, or RP002-1.0.0
ADR algorithmThe Adaptive Data Rate algorithm used by the network server to optimize data rates. Usually left as default.e.g., Default ADR algorithm
Flush queue on activateClears any pending downlink messages when the device re-joins the network. Highly recommended for OTAA.e.g., Checked (Yes)
RX1 DelayThe delay in seconds for the first receive window. Keep the default unless specified otherwise by the sensor manual.e.g., 1
Expected Uplink interval (seconds)The expected time interval between regular sensor data reports.e.g., 3600 (for 1 hour)
Activation MethodHow the sensor securely connects to the gateway. OTAA is highly recommended for security.OTAA
Device ClassThe LoRaWAN operating class. Class A (battery-powered/sleeps) or Class C (mains-powered/always listening).e.g., Class A
  1. Click 【Publish】 to finish the profile.

4.5 Step 4: Add a Device and Associate Tags

Purpose of this step: To register the actual, physical sensor to the gateway using its unique IDs, and select which data points (Tags) you want to collect.

  1. Go to 【Data Collection】>【LoRaWAN Device】>【Add Device】.
  2. Configure the physical device identity:
Parameter NameConfiguration DescriptionRecommended / Example Value
Device ProfileSelect the pre-configured template for this sensor model (created in Step 2). This automatically applies the correct network and decoding rules.e.g., Profile_AM102_EU868
NameA custom, recognizable name for this specific physical sensor to easily identify it in the system.e.g., MeetingRoom_Sensor_01
Description(Optional) Additional notes about the device's installation location, purpose, or physical condition.e.g., 3rd Floor Meeting Room A
Device EUI (HEX)The globally unique 16-character hexadecimal identifier of the sensor. Typically found on the device's physical label or its packaging.e.g., 24E124128C012345
Join EUI (AppEUI)The globally unique 16-character hexadecimal identifier used to identify the Join Server during the OTAA process. Provided by the manufacturer.e.g., 5572404C696E6B4C
Application Key (AppKey)The 32-character AES-128 root key specific to this device, used to secure the OTAA activation. This is highly sensitive information provided by the vendor.e.g., 5572404C696E6B4C6F52613230313823
  1. Click 【Next】 to enter Tag Verification.
  2. The system will automatically list all available data points (Tags) this sensor can provide (e.g., temperature, humidity, battery). Check the boxes for the tags you need.
  3. Click 【Confirm】, then click the 【Publish LoRa】 button at the top right of the screen to apply changes.

4.6 Data Collection Verification

Once added, power on or reboot your physical sensor to force it to join the gateway.

1. Verifying Uplink Data (Reading from Sensor)

  • Check Connection: Go to 【Data Collection】>【LoRaWAN Device】. Look at the 【Status】 column. A green icon means the sensor has successfully joined the gateway.
  • View Data: Click the 【View Tags】 icon (eye symbol) next to your device.
  • Observe the 【Latest Value】 and 【Update Time】 columns. If you see real numbers (e.g., 25.5 for temperature) updating periodically, your sensor is successfully online and sending data.

2. Verifying Downlink Data (Writing to Sensor)

If your sensor supports receiving commands (like turning on a relay or changing report intervals):

  • In the Tag list window (View Tags), find a tag with 【Read & Write】 permission.
  • Click the 【Modify Tag Value】 icon (paper airplane symbol).
  • Enter the new command/value (e.g., "off") and click 【Confirm】.
  • Note: Because LoRaWAN sensors sleep to save battery, downlink commands are queued and will be executed the next time the sensor wakes up to communicate.

5. Northbound Configuration: Modbus TCP Slave

This is the core step where we expose our internal tags to the Modbus network.

5.1 Creating the Modbus TCP Slave

  1. Go to【Data Forwarding】.
  2. Click the【+ Create】 button at the top, select【Modbus TCP Slave】, and click【Save】.
  3. You will enter the Modbus TCP Configuration page. Enable Modbus TCP Configuration and configure the Basic Settings:
ParameterDescription & Action
Modbus TCP Slave ConfigurationSwitch for Modbus TCP slave configuration. Default: Off (disabled). When enabled, cloud service configuration becomes available.Off (disabled), On (enabled)
Port NumberThe TCP port number on which the Modbus TCP server listens. Required. Range: 1-65535.502 (standard port)
16-bit Integer Byte OrderByte order for 16-bit integers. Default: AB. Required. Options: AB (big-endian), BA (little-endian).AB
32-bit Integer Byte OrderByte order for 32-bit integers. Default: ABCD. Required. Options: ABCD (big-endian), CDAB, BADC, DCBA (little-endian).ABCD
32-bit Float Byte OrderByte order for 32-bit floating point values. Default: ABCD. Required. Options: ABCD (big-endian), CDAB, BADC, DCBA (little-endian).ABCD
64-bit Integer Byte OrderByte order for 64-bit integers. Default: ABCDEFGH. Required. Options: ABCDEFGH (big-endian), GHEFCDAB (little-endian), etc., depending on system support.ABCDEFGH
Maximum ConnectionsMaximum number of concurrent Modbus TCP client connections. Required. Range: 1-32.10
Mapped Value SettingsMapped value settings. Default option: Data Operation Value. When enabled, the system transforms data according to the device point configuration in Data Collection and forwards the transformed data by default. Currently only the Data Operation Value option is available.Data Operation Value (default option)
  1. Click 【Submit】 to save the basic settings.

5.2 Mapping Tags to Modbus Registers (Crucial Step)

After completing the basic settings, you need to add a slave and map the tags created during data collection to specific register addresses under this slave.

5.2.1 Mapping Strategy Guide (Read before Configuration)

Before you start mapping, please review the following planning principles:

  • Address Continuity: To minimize reads from your SCADA, map tags that are polled together to consecutive register addresses. For example: Temperature → 40001, Humidity → 40002.
  • Data Type Footprint: An int16 consumes 1 register. A float32 consumes 2 consecutive registers (e.g., 40001-40002). A string consumes multiple registers by byte. Plan your address space to avoid overlaps.
  • Function Code Selection: Most SCADA systems use 03 Holding Register for analog values. 04 Input Register is read-only and suitable for device status. 01/02 are for boolean values.
  • Naming Convention: Use meaningful names for slaves and mapping tables (e.g., Slave_SCADA_Room1) for easier maintenance.

5.2.2 Adding a Slave

  1. In the "Modbus TCP Slave List" section, click 【Add Slave】.
  2. Configure the following parameters:
ParameterDescriptionExample
Mapping Table NameA unique, identifiable name for this slave. Required.Slave_For_SCADA
Slave AddressThe Modbus unit identifier (Slave ID / Unit ID). The upper-level system must specify this address when reading data. Required. Range: 1-247. No default; must be filled.1

5.2.3 Adding Mappings

After adding the slave, you need to add tag mappings for this slave. The upper-level system (e.g., Modbus Slave) does not understand internal tag names like "Temperature"; it only recognizes standard Modbus register addresses (e.g., 40001). The system supports two methods: 【Add Mapping】 (single) and 【Batch Add Mapping】 (bulk creation).

Method 1: Add Mapping (Single)

Use this method to map tags one by one.

  1. In the row of the newly created slave, click the 【Add】 button on the right.
  2. Fill in the mapping parameters according to the table below, then click 【Save】:
ParameterDescriptionExample
DeviceSelect the southbound device from which the data originates. Required. Choose from the dropdown.MeetingRoom_Sensor_01
TagSelect the specific data tag to map. Required. After selection, 【R/W Permission】 and 【Original Data Type】 are automatically displayed. R/W Permission Note: If Read & Write is displayed, the upper-level system (e.g., Modbus Slave) can read the value and also write to modify the tag value on the gateway (i.e., write-back). If Read Only is displayed, the upper-level system can only read; write operations will have no effect.Temperature
Mapped Data TypeDetermines the data type exposed to the upper-level system via the Modbus register. Required. Should match or be compatible with the original data type.int16
Initial Mapping Function CodeDetermines which Modbus function code the upper-level system uses to access this register. Required. - 03 (Holding Register): Most common; used for reading/writing 2-byte data. - 04 (Input Register): Read-only; used for reading 2-byte data. - 01 (Coil): Used for reading/writing 1-bit (boolean) data. - 02 (Discrete Input): Read-only; used for reading 1-bit (boolean) data.03
Initial Mapped AddressThe starting Modbus logical register address (e.g., 0, 1, 100) to which you want to map this tag. Required. Range: 1-65535. No default. Note: This address is the offset relative to the function code.1
Mapped Address (Auto-calculated)The final Modbus address automatically calculated by the system based on the "Initial Mapping Function Code" and "Initial Mapped Address". This field is for confirmation and cannot be edited.If function code is 03 and initial address is 1, this field shows 40001

Method 2: Batch Add Mapping (Bulk Creation)

Use this method to map multiple tags from the same device at once, saving significant configuration time.

  1. In the row of the newly created slave, click the 【Batch Add Mapping】 button.
  2. In the pop-up window, configure the following:
ParameterDescriptionExample
Initial Mapping Function CodeSelect the Modbus function code for all tags in this batch. Required. The system will only display tags from the selected device that support this function code.03 (Holding Register)
Initial Mapped AddressThe starting logical register address for the first tag in the batch. Required. Range: 1-65535.1
DeviceSelect the southbound device whose tags you want to map. Required.MeetingRoom_Sensor_01
  1. After selecting the device, the table below will automatically display all tags from that device that match the selected function code. Check the boxes next to the tags you want to map (multiple selection allowed).
  2. The system will automatically calculate the 【Mapped Address】 for each selected tag based on the starting address and the data type size. For example, if you select 3 tags starting from address 1, the mapped addresses will display as 40001 ~ 40004 (the exact range depends on the number and data types of the selected tags).
  3. Click 【Save】 to complete the batch mapping.

Final Steps

  1. Repeat steps 5.2.1 and 5.2.2 to create all required slaves and complete the mapping configuration for all tags you need to forward (e.g., Humidity).
  2. All configurations take effect immediately upon saving; no need to click the 【Publish】 button.

6. Verifying Configuration with Modbus Slave

Now, let's test if our gateway is successfully working as a Modbus TCP Slave.

  1. Open the Modbus Slave software on your PC.
  2. Click 【Connection】>【Connect】 on the menu bar.
  3. In the pop-up window, configure the following parameters:
    1. Connection Type: Select 【Modbus TCP/IP】
    2. IP Address: Enter the gateway's IP address (e.g., 192.168.0.1)
    3. Port: Enter 502 (or the port number you configured in Basic Settings)
    4. Click 【OK】
  4. Click 【Setup】>【Slave Definition】 on the menu bar, and configure the following parameters:
    1. Slave ID: Enter the slave address you configured (e.g., 1)
    2. Function: Select 03 Holding Register (4x)
    3. Address: Enter 1 (corresponding to mapped address 40001)
    4. Quantity: Enter the number of registers to read (e.g., 1 for Temperature)
    5. Click 【OK】
  5. In the Modbus Slave main window, you should see real-time data displayed at address 40001. If the displayed values match the values collected from the southbound LoRa device, your Modbus TCP Slave data forwarding is successful.

  1. Testing Write-Back Function (Only for Read & Write points). If a mapped point shows 【Read & Write】 in the Mapping Table, you can use Modbus Slave to write a value to the gateway, and the gateway will write this value back to the corresponding southbound LoRa device.
    + In Modbus Slave, locate the register address you want to write to (e.g., 40001).
    + Double-click the 【Value】 cell for that address.
    + Enter a new value in the pop-up window and click 【OK】.
    + Observe whether the value changes. If it updates successfully, the write-back function is working. If the value does not change or reverts to the original value, check:
    1. Whether the point's 【R/W Permission】 is Read & Write (if Read Only, write-back is not supported).
    2. Whether the southbound LoRa device supports write operations.

7. Common Troubleshooting

Debugging Workflow (Check in this order)

1. Network Layer: From your SCADA/upper computer, run ping [gateway IP address] in CMD/Terminal.

  • Fails? Check cable connections, IP address configuration, and whether your firewall allows the Modbus TCP port you configured.

2. Service Layer: Use the Modbus Slave software to try connecting to the gateway.

  • Timeout? Check whether the Modbus TCP Slave Configuration switch on the gateway is enabled and whether the port number matches your configuration (default 502).

3. Data Layer: Connected but reads 0 or error values?

  • a. Go back to the gateway Web UI → Data Collection. Check if the Tag you mapped has live, updating values.
  • b. If the Tag is fine, check if the Slave ID in your configuration matches the one in Modbus Slave.
  • c. Check the Mapped Address: The offset address you configured (e.g., 1) maps to Modbus address 40001. Does the address in Modbus Slave match?
Issue / PhenomenonPossible CauseSolution
Modbus Slave cannot connect to the gatewayPC and gateway are not on the same network subnet.Ping the gateway's IP address from your PC to verify network connectivity. Check if Windows Firewall is blocking the Modbus TCP port you configured.
Modbus Slave connects successfully, but values are 0 or frozenSouthbound LoRa device collection failed, so the tag has no data.Go to 【Data Collection】 to verify that the LoRaWAN device is online and data is updating normally.
Modbus Slave reports "Timeout"Incorrect Slave ID or register address configuration.Check that the Slave ID in Modbus Slave matches the slave address configured in the gateway. Verify that the register address mapping is correct.
Modbus Slave reads data successfully for some addresses but reports errors or incorrect values for othersThe Quantity (number of registers to read) in Modbus Slave cuts across non-continuous mapping ranges. For example, if your mappings occupy addresses 1-2, 3, 4-5 (three discontinuous segments), setting Quantity to 4 attempts to read across segment boundaries, causing errors.The Quantity value must fully cover a set of continuous mapped addresses without truncation. Valid quantities in the above example: 2 (covers 1-2 only), 3 (covers 1-3), or 5 (covers 1-5). Invalid quantities: 1 (truncates 1-2) or 4 (cuts across 1-2 and 3 incorrectly). Ensure Quantity aligns exactly with the start and end of your mapping segments.
After writing a new value in Modbus Slave, the value does not change or reverts to the original valueThe 【R/W Permission】 of this mapped point is Read Only, which does not support write-back.Go to 【Data Forwarding】>【Modbus Mapping Table】 to check the R/W permission of this point. Only points marked Read & Write support write-back.
A point shows Read & Write in Data Collection, but appears as Read Only in the Mapping TableThe original data type of this point is 【RAW-DATA】, 【STRING】, or 【BCD】. According to system rules, these three data types are forced to read-only when forwarded.This is normal system behavior, not a configuration error. The three data types mentioned above are defaulted and forced to read-only during forwarding. No action is required.
When configuring a mapping, the "Mapped Data Type" dropdown only shows STRING, with no other types availableThe original data type of this point is 【RAW-DATA】, 【STRING】, or 【BCD】. According to system rules, these three types can only be converted to STRING when forwarded.This is normal system behavior, not a configuration error. The system automatically restricts the available options. Simply use the default selection.