RS485 Device Configuration Guide
This guide explains how to connect an RS485 (Modbus) sensor to the Bridge IO, configure polling tasks to collect data, send it via LoRaWAN, and remotely manage RS485 settings using downlink commands.
Prerequisite
Before configuring RS485, prepare the following:
-
An RS485 (Modbus) sensor.
-
External power supply (if required by the sensor).
-
IO.BOX (latest version recommended).
Connect RS485 Device to Bridge IO Device
In this section, we will demonstrate how to use the RS485 interface on the Bridge IO to connect a device. The RK520-02 Soil Moisture, Temperature, and Electrical Conductivity Sensor (supports 12–24VDC wide input voltage) will be used as an example.
-
For other devices, refer to their documentation and connect accordingly.
-
If the sensor is powered by the Bridge IO, ensure the Bridge IO is connected to an external power supply. High-power sensors should be powered directly from an external supply.
Wiring Diagram
Two wiring methods are supported depending on the sensor’s power source.
-
Sensor with Independent Power Supply
Connect the RS485 differential lines (A/B, labeled as D+/D− on some sensors) to the RS485_A and RS485_B interfaces of the Bridge IO. Sensor power is supplied externally.
Figure 1: wiring diagram1 -
Sensor Powered by Bridge IO
-
Connect the RS485 differential lines (A/B or D+/D−) to RS485_A and RS485_B.
-
Power connections:
- Vout (12 V / GND): Sensor power input
- Vin (9–24 V): External power input
-
Enable Power Output in IO.Box.
-
Figure 1: wiring diagram2RS485 Interface Configuration
RS485 interface parameters must exactly match the sensor’s communication settings. Incorrect configuration will result in Modbus communication failure.
-
(Optional) Go to the System tab from the main menu. Enable the DC 12 V Output.
That the power output interface connected to the example sensor is enabled here. Please enable the power output interface that your sensor is actually connected to.
Figure 1: power-enable1- Go to RS485 from the main menu and configure the following parameters.
The parameters shown below are specific to the example sensor. For detailed parameter definitions, refer to RS485 Interface Configuration.
Figure 1: interface-configuration-
Baudrate: Select the RS485 communication speed (bits per second).
-
Databits: Select the number of data bits for each character in the RS485 communication.
-
Stopbits: Select the number of stop bits used in the RS485 communication.
-
Parity: Select the parity setting for the RS485 interface.
Here are the basic communication parameters of the RK520-02 sensor:
| Parameter | Definition |
|---|---|
| Format | 8-bit binary |
| Data bit | 8-bit |
| Parity | No |
| Stop bit | 1 |
| Error checking | CRC |
| Baud rate | 9600 |
Add Modbus Poll Task
This section demonstrates how to create Modbus polling tasks for temperature, humidity, and electrical conductivity (EC). If you need to create a polling task with a raw binary data type, refer to (Optional) Add a Raw Data in Binary Poll Task.
- In the Modbus Poll Task menu, click +Add for a new poll. You will see the Polling Task parameters that need to be configured.
Figure 1: Add poll task-
Fill in the relevant fields according to the specific sensor’s datasheet, as shown in the screenshot and parameter settings below. Here we create a temperature polling task as an example.
NOTEOnly parameters directly related to these polling tasks are described here. Other parameters remain at their default values. For more details, refer to Add Modbus Poll Task.
Figure 1: Add temperature polling task-
Channel ID: Identifier of the polling task.
-
Device Address: The unique address of the connected device on the RS485 bus, obtained from the device manual.
-
Function Code: Specifies the task's Modbus operation type (read or write), obtained from the device manual.
-
Register Address: The target register or coil address used in the Modbus request, obtained from the device manual.
-
Scale: To adjust the raw data from the Modbus response to the desired units.
-
Sensor Type: Select the unit or category that best matches your slave device output (used for correct interpretation and presentation).
Click Check to perform automatic validation. If the returned values are correct, save the polling task.
- Read Request: Displays the Modbus command generated from the selected settings, which is used to communicate with the device.
- Read Response: Displays the response received from the Modbus slave device.
- Read Value: Shows the parsed value extracted from the Response, based on the configuration above.
- Uplink Data: Displays the data payload format that will be sent to the server, based on the configuration above.
- Create moisture and EC polling tasks in the same way.
Figure 1: Add moisture polling task
Figure 1: Add EC polling task
Figure 1: Created polling tasks(Optional) Add a Raw Data in Binary Poll Task
- In the Modbus Poll Task menu click +Add for a new poll. You will see the Polling Task parameters that need to be configured.
Figure 1: Add poll task- Fill in the relevant fields according to the specific sensor's datasheet. Here we create a temperature polling task as an example.
Figure 1: Add temperature polling task-
Channel ID: Enter the identifier for the polling task.
-
Device Address: The unique address of the connected device on the RS485 bus, obtained from the device manual.
-
Function Code: Specifies the Modbus operation type (read or write), obtained from the device manual.
-
Register Address: The target register or coil address used in the Modbus request, as specified in the device manual.
-
Data Type: The data type of the Modbus response. In this document, select
Modbus ADU. -
Sensor Type: Select the unit or category that best matches your slave device output. In this document, set it to
Raw Data in Binary (Modbus ADU).
Click Check to perform automatic validation. If the returned values are correct, save the polling task.
- Request: Displays the Modbus command generated from the selected settings, which is used to communicate with the device.
- Response: Displays the response received from the Modbus slave device.
- Value: Shows the parsed value extracted from the Response, based on the configuration above.
- Uplink Data: Displays the data payload format that will be sent to the server, based on the configuration above.
- Create moisture and EC polling tasks in the same way.
Figure 1: Add moisture polling task
Figure 1: Add EC polling task
Figure 1: Created polling tasksConnect Bridge IO to LoRa Network Server for Uplink
This section provides you with operation guidance for connecting the Bridge IO to different LoRaWAN network servers and forwarding the collected data to the server (uplink).
Before connecting to the LNS, ensure that you have completed Configure LoRaWAN Parameters in IO.BOX.
Built-in Network Server
In this section, the Bridge IO will be connected to an RAKwireless gateway. For the gateway, the built-in LNS will be used.
Set-up the Built-in Network Server
- Start by accessing the gateway. Refer to the appropriate WisGateOS 2 user manual depending on the gateway you are using:
Figure 1: WisGateOS 2 login page- Once logged in, head to the LoRa menu.
Figure 1: LoRa page- By default, the gateway works as a Built-In Network Server. If not, switch the Work mode to Built-in network server.
Adding Application
- Once the gateway is in Built-in network server mode, head to the Applications tab.
Figure 1: Create Application in the Built-In Network Server- Click the Add application button or add one now link to add a new application. On the new page, fill in the following information:
Figure 1: Adding application- Application name: type a name for the application.
- Application Type: Select the application type from the drop-down menu. In this document, choose Unified Application Key.
- Unified Application key: All devices use the same application key. After selecting this option, the Application Key field will appear. This value must match the one configured on the end device. You can manually enter the application key or click Autogenerate to generate one automatically.
Figure 1: Unified application keyThe Auto Add Device switch activates the Application EUI field. The device will be automatically added to the application after the application EUI and key verification.
Figure 1: Auto add device- Payload type: from the drop-down, select CayenneLPP payload type and turn on the Only forward data object feature.
- Once set, click Save application to add the application.
- After the application is added, head to the End devices tab. The devices should automatically register upon join request if you are using the Auto Add Device feature. If that’s not the case, click the Add end device button. On the End device information page fill in the following information:
Figure 1: Successfully created application- Activation Mode: Choose the activation mode of your device.
- OTAA: Selected in this document.
- ABP: This mode pops up two additional fields:
- Application Session Key
- Network Session Key
- End device (group) name: the name of the device.
- Class: the class of the device.
- Frame Counter width: the width of the frame counter. Leave it as default.
- LoRaWAN MAC Version: the LoRaWAN MAC version.
Adding the Device
-
Once everything is set, click Add end devices to go to the page and add the device.
-
On the Adding end devices page, type the device EUI at the End Device EUI (main) and click Add to “End Devices list”.
Figure 1: Adding end device-
If the EUI is correct, the device will show in the End devices list.
-
If the EUI is not correct, the devices will show in the End devices with an error.
- Once the device is added to the End devices list click Add end devices. Confirm you are adding the device.
Figure 1: Confirmation message for adding a device- After the device has successfully joined the LNS, you will see the LoRaWAN status in the IO.Box console toggles as activated. You might need to refresh the page.
Figure 1: Device is online
Figure 1: LoRaWAN statusWait a while and you will see the uplink data from the LoRaWAN network.
The following is an example of RS485 uplink data and its message format:
01 + 67(tem) + 00cb(Hex) 20.5(Dec) 20.5℃ 02 + 70(RH) + 0124(Hex) 292(Dec) 29.2%
03 + 7f(EC) + 0000dea8(Hex) 57000(Dec) 57.000us/cm
Figure 1: Uplink dataThe Things Network (TTN)
Gateway Configuration
RAK gateways can connect to The Things Stack (TTN v3) using the following methods:
Packet Forwarder (UDP)
To connect a gateway to TTN v3 using Packet Forwarder (UDP), see How to Connect RAK Gateways to TTN v3 via UDP.
Basics™ Station (LNS)
To connect a gateway to TTN v3 using Basics™ Station (LNS), see How to Connect RAK Gateways to TTN v3 Using Basics™ Station (LNS).
Basics™ Station (CUPS)
To connect a gateway to TTN v3 using Basics™ Station (CUPS), see How to Connect RAK Gateways to TTN v3 Using Basics™ Station (CUPS).
Bridge IO Configuration
You can create applications and automatically register node devices on the TTN network server through IO.Box. For detailed configuration steps, refer to The Things Stack (TTN v3) Integration.
- After the device is created successfully, you can view the added device in the TTN.
Figure 1: Added device in the TTN- To activate the device, click Apply.
Figure 1: Active the device- After a successful Apply, the device in the TTN is activated and receives data as shown in Figure 62.
Figure 1: Device is online
Figure 1: Data detailsYou will also see the LoRaWAN activation status in the IO.Box console enabled.
Figure 1: LoRaWAN statusChirpStack
This guide will show you how to connect the Bridge IO to a ChirpStack network server. In this tutorial, the ChirpStack v4 network server is used as an example.
Gateway configuration
A gateway can be connected to the ChirpStack v4 server using the following methods:
Packet Forwarder (UDP)
To connect a gateway to ChirpStack v4 using Packet Forwarder (UDP), see How to Connect RAK Gateways to Chirpstack v4 via UDP.
Packet forwarder(MQTT)
To connect a gateway to ChirpStack v4 using Packet Forwarder (MQTT), see How to Connect RAK Gateways to Chirpstack v4 via MQTT.
Basics™ Station (CUPS)
To connect a gateway to ChirpStack v4 using Basics™ Station (LNS), see How to Connect RAK Gateway to Chirpstack v4 Using Basics™ Station (LNS).
Bridge IO Configuration
You can create applications and automatically register node devices on the ChirpStack server through IO.Box. For detailed configuration steps, refer to ChirpStack v4 Integration.
- After the device is created successfully, you can view the added device in the ChirpStack.
Figure 1: Added device in the ChirpStack- To activate the device, click Apply.
Figure 1: Active the device- After a successful Apply, the device in the ChirpStack is activated and receives data.
Figure 1: Device is online
Figure 1: Data detailsYou will also see the LoRaWAN activation status in the IO.Box console enabled.
Figure 1: LoRaWAN statusRemote Device Configuration via LoRaWAN Downlink
The Bridge IO device can be configured remotely through LoRaWAN downlink commands. This method allows you to modify parameters for the RS485 (Modbus), enabling control of connected peripheral devices.
The FPort for configuration commands must be set to 10.
General Command Format
All configuration downlinks follow this structure:
[Channel ID] [Command Code] [Payload]
Command Code Breakdown
The Command Code is a single hexadecimal byte where each bit group defines a specific action. Please refer to the following table for details.
| Bit Position | Function | Value & Meaning |
|---|---|---|
| Bit 7 | Get/Set | 0: Get (Read parameters)1: Set (Write parameters) |
| Bits 3-6 | Channel Type | 0: DI (Digital Input)1: DO (Digital Output)7: Modbus (RS485 interface) |
| Bit 2 | Enable/Disable | 0: Disable 1: Enable |
| Bits 0-1 | Parameter Mode | 00: Combined (Configure all parameters together)01: Individual (Configure parameters individually) |
Command Example
Combined Setting Example
A typical combined write command looks like this:
01 BC 01 03 00 00 00 01 04 3D CC CC CD 67 00 00 00 3C
-
01: Channel ID. Corresponds to the channel number shown in the device management interface. -
BC: Command Code. To understand it, convertBC(hex) to binary:1011 1100.-
Bit 7 =
1→ Set (Write command) -
Bits 3-6 =
0111(decimal 7) → Modbus channel -
Bit 2 =
1→ Enable the channel -
Bits 0-1 =
00→ Combined parameter mode
-
-
01 03 00 00 00 01 04 3D CC CC CD 67 00 00 00 3C: The Payload containing the specific configuration parameters for the channel.
Individual Setting Example
A typical individual write command looks like this:
01 BD 07 00 00 02 58
-
01: Channel ID. -
BD: Command Code. To understand it, convertBD(hex) to binary:1011 1101.-
Bit 7 =
1→ Set (Write command) -
Bits 3-6 =
0111(decimal 7) → Modbus channel -
Bit 2 =
1→ Enable the channel -
Bits 0-1 =
01→ Individual parameter mode
-
-
07 00 00 02 58: Payload. Contains the specific parameter being modified and its corresponding value.-
07→ Parameter ID (Interval) -
00 00 02 58→ Interval value = 600 seconds
-
Command Payload Specification
You can use LoRaWAN downlinks to remotely add a Modbus poll task or modify the parameters of an existing task.
Write Command Example: 01 BC 01 03 00 00 00 01 04 3D CC CC CD 67 00 00 00 3C
Command Structure Breakdown
-
01: Channel ID -
BC: Command Code (Indicates a Set/Write command for configuring an enabled Modbus channel in Combined Parameter Mode) -
Payload:
-
01: Device Address = 1 -
03: Function Code = 3 (Read Holding Register) -
00 00: Register Address = 0 -
00 01: Quantity = 1 -
04: Data Type = INT16_BE - Integer (16bit) - Big-Endian -
3D CC CC CD: Scale Factor = 0.1 -
67: Sensor Type = 0x67 (103, Temperature) -
00 00 00 3C: Interval = 60 seconds (0x3C)
-
You can enter the read command 01 38 in the LoRaWAN Downlink server to retrieve the current parameter configuration payload.
LoRaWAN Downlink Server Configuration
Before configuring LoRaWAN downlinks, ensure that your Bridge IO is connected to a LoRa Network Server and is actively communicating on the network.
This example demonstrates how to remotely change the data type of the Modbus Poll Task for Channel ID 1 to UINT16_BE - Unsigned Integer (16bit) - Big-Endian.
Built-in Network Server
-
Log in to your gateway's web management interface.
-
Go to LoRa > Applications > End devices > Downlink.
-
On the Downlink page, configure the following and click Send to transmit the command.
-
Frame Confirmation: Enable.
-
FPort: Set to
10. -
HEX Bytes: Enter the hexadecimal configuration command without any spaces.
-
Figure 1: LoRaWAN Downlink built in- Verify that the data type for RS485 Channel ID 1 has been updated to
UINT16_BE.
Figure 1: Modbus Poll TaskThe Things Network (TTN)
-
Log in to the TTN Console.
-
Select your Application and the target End Device.
-
Navigate to the Messaging > Schedule downlink tab, configure the parameters, and click Schedule downlink to send the command.
-
Insert Mode:
Replace downlink queue -
FPort:
10 -
Payload type:
Bytes -
Payload: Enter the hexadecimal configuration command.
-
Confirmed downlink: ✔ Check this box.
-
Figure 1: LoRaWAN Downlink TTN- Verify the change in your device's RS485 configuration for Channel ID 1.
Figure 1: Modbus Poll Task- Check the Live data tab in the TTN server to view the acknowledgment message returned by the device.
Figure 1: TTN confirmedChirpStack
-
Log in to the ChirpStack Network Server.
<IP address of ChirpStack>:9480 -
In the left navigation pane, go to Applications, select your target application, and then choose the specific end device.
-
Navigate to the device's Queue tab, configure the downlink parameters, and click Enqueue to send the command.
-
Confirmed: Enable.
-
FPort: Set to
10. -
HEX: Enter the hexadecimal configuration command.
-
Figure 1: LoRaWAN Downlink ChirpStack- Verify in your device's RS485 configuration that the data type for Channel ID 1 has been updated to
UINT16_BE.
Figure 1: Modbus Poll Task- Check the Events tab in the ChirpStack server to view the acknowledgment message returned by the device.
Figure 1: ChirpStack confirmed