how to connect a third-party 4–20 ma analog sensor to the rak sensor hub

The RAK2560 Sensor Hub is a modular device that connects multiple sensors to a single LoRaWAN network node. It is designed to work easily with official RAKwireless sensors for quick and reliable data transmission.

For use cases that require other sensor types, the Sensor Hub also supports third-party 4–20 mA analog sensors through the generic Probe IO adapter. This allows integrators to connect various analog-output devices common in industrial and environmental monitoring.

To demonstrate the integration process, this guide provides step-by-step instructions for connecting a Huamo RG202011170 water pressure sensor, covering:

  • Hardware setup and wiring
  • Power requirements
  • Sensor configuration via WisToolBox

Requirements

  • RAK2560 Sensor Hub
  • Generic Probe IO
  • A power supply
  • WisToolBox
  •  Smartphone with NFC
  • Third-party 4-20 mA sensor, with:
    • Wiring/connection diagram
    • Communication parameters
    • Register description
‼️
IMPORTANT

It is crucial to have detailed information about the sensor. The most reliable source is the sensor manufacturer, typically provided in in the sensor datasheet. 

Without a sensor connection diagram, communication parameters and a register description, establishing a connection with the Sensor Hub is not possible. 

Gather the Third-Party 4-20 mA Sensor Specifications

Before connecting the water pressure sensor to the RAK2560 Sensor Hub, it is imperative to review the sensor’s datasheet. Accurate setup depends on having complete technical specifications.

Electrical Parameters

The 4-20 mA sensors translate measured values into a direct current (DC) signal. To ensure proper operation with the Sensor Hub, configure the device based on:

  • Output signal type
  • Measurement range
  • Power requirements

For example, the Huamo RG202011170 water pressure sensor outputs a 4–20 mA signal and has a pressure range of 0 to 100 kPa. It requires a 12–24  VDC supply for reliable operation.

Here’s the full product specifications, taken from the manufacturer’s datasheet:

PARAMETER SPECIFICATIONS
Measurement Range -100 KPa ~ 100 MPa (Selectable Range)
Output Signal 4~20 mA (Default), 0~5 V, 0~10 V, RS485
Mounting Thread M20*1.5 (Default), G1/2, G1/4, M14*1.5, etc.
Power Supply 12~24 V (Default), 5 V, 3.6 V
Compensation Temperature -10~70° C
Measurement Accuracy 0.5%FS (Default), 0.2%FS, 0.1%FS
Operating Temperature -20~70° C
Protection Level IP65
Medium Compatibility Compatible with various medium that are non-corrosive to 316 stainless steel
Measurable Medium Gas, Liquid, Water, Oil
Overload Capacity 150%FS
Long-Term Stability ±0.2%FS/year

 

Connection Diagram

The sensor cable connects to the Sensor Probe IO using screw terminals. If the sensor has a pre-installed connector, you’ll need to remove it to access the individual wires.

Most 4-20 mA sensors typically use a 2- or 3-wire configuration. The Huamo RG202011170 uses a 3-wire setup:

  • Power (+V)
  • Ground (GND)
  • Signal Output

water-pressure-three-wire-wiring-diagram

Figure 1: Three-wire wiring diagram

At this point, you should have all the essential information needed to wire the sensor to the Sensor Hub, including:

  • The correct wiring diagram
  • The sensor’s supply voltage requirements
  • The measurement range and output type

You can now proceed to connect the sensor wires to the Probe IO.

Connect the 4-20 mA Sensor to the Sensor Hub Probe IO

To connect the sensor wires to the Probe IO, follow the steps below:

1. Open the Probe IO
Remove the four screws to open the lid and access the internal screw terminals.

2.Identify the Terminals
Locate the two screw terminals and refer to the pin labels printed on the side of the enclosure for correct terminal assignment.

Sensor-Connection-1.png

Figure 2: Sensor Probe IO

3.Prepare and Connect the Wires

Using the sensor’s datasheet, match each wire to the correct pin based on the signal type. A 4–20 mA sensor uses only three terminals. Use the wire color references from the datasheet and the Sensor Hub screw terminal description to ensure correct alignment.

 

water-pressure-sensor-probeio-connection.png

Figure 3: Probe IO and 4 - 20mA power and communication pins

 

ℹ️
INFO
  • The yellow wire shown in the manufacturer’s datasheet may appear as green in the actual sensor. Always refer to the pin function, not just the color.
  • For detailed pin definitions, refer to the Probe IO datasheet.

 

‼️
IMPORTANT

Do not connect the Probe IO to the Sensor Hub during wiring. Complete all connections and check for exposed wires before powering on. 

 

4. Check and Finalize

Ensure no bare wires are exposed or touching adjacent terminals or the PCB. Then, close the Probe IO and connect it to the Sensor Hub.

water-pressure-sensor-probeio-wiring.png

Figure 4: 4-20 mA sensor to Sensor Hub Probe IO connection

Configure the 4-20 mA Sensor for the Sensor Hub in WisToolBox

Since the Generic Probe IO does not contain any predefined information about the connected sensor, you must configure both the connection parameters and sensor data settings manually using WisToolBox.

There are two ways to do this:

  1. Manual Setup in WisToolBox: Configure the sensor directly by entering the parameters in the UI. 
  2. Sensor Profile File Setup: Create a reusable sensor profile file that can be imported into WisToolBox and applied to the Probe IO.

Manual configuration is ideal for setting up a single sensor, such as for testing purposes. However, when deploying multiple units, using a sensor profile file is a more efficient and scalable option, allowing the same configuration to be applied consistently across all devices.

Manual Setup in WisToolBox

Once the generic Probe IO is connected to the Sensor Hub, it will be automatically detected in the WisToolBox as Generic Probe IO. If the Probe IO has not been configured, it will display only the standard IO options. 

To configure the connected water pressure sensor, refer to the instructions below: 

1. Navigate to the Analog Input: 4-20 mA tab in WisToolBox.

water-pressure-sensor-setup-1.png

Figure 5: Analog Input: 4-20 mA tab

2. Configure the analog input data interface parameters, and set the following:

    • Name: WaterPressure
    • Offset: 0.000000
    • Min Value: 0 kPA
    • Max Value: 160 kPA

water-pressure-sensor-setup-2.png

Figure 6: Analog input data interface parameters

3. In the Unit drop-down menu, select Pressure for the water pressure sensor data, then click SAVE SELECTION.

water-pressure-sensor-setup-3.png

Figure 7: Select the sensor type and save

4. Once all 4-20 mA settings have been configured and saved, press REMOVE SENSOR PROBE to forcibly disconnect the Probe IO.

WisToolBox-Manual-Setup-4.png

Figure 8: Temporarily remove the sensor probe 

The Probe IO will automatically reconnect with the new configuration. The new sensor values will now be visible in WisToolBox.

water-pressure-sensor-setup-4.png

Figure 9: New sensor value

5. On the initial refresh, the sensor values might still display as "0". Click the FETCH DATA button to manually trigger a sensor read.

ℹ️
INFO

The FETCH DATA function only reads and displays the sensor data in the app. It does not transmit the values over LoRa or cellular networks.

 

Sensor Profile File Setup for the Sensor Hub

The second method to configure custom sensors for the Sensor Hub is to create a sensor profile file.

This method not only simplifies configuration when deploying multiple identical sensors but also enables advanced control of the sensor’s power supply behavior.

Creating a Sensor Profile File

A profile file is a JSON format that defines the sensor configuration, containing five entries:

SensorName A unique name for the sensor, such as WPA.
TemplateVersion 1
ProbeioVersion 1.2.7
Interface

Select the interface of the generic Probe IO to configure. Available options are:

  • RS485 for RS485/Modbus
  • RS232 for RS232 serial interface
  • SDI12 for SDI-12 serial interface
  • AI for analog in, e.g., 4-20 mA
  • DI for digital input
  • DO for digital output
Content

An array with AT commands to define the sensor actions.

Here is the sensor profile file created for the Huamo water pressure sensor type RG202011170 used in this tutorial:

{
    "SensorName": "WPA",
    "TemplateVersion": "1",
    "ProbeioVersion": "1.2.7",
    "Interface": "AI",
    "Content": [
      "atc+io_psm={PRB_ID}:9:1:10000:0:1",
      "ATC+SNSR_CONF={PRB_ID}:8:{SNSR_INTV}:2",
      "atc+io_decode={PRB_ID}:ai:1:115:100:0:{PROFILE_NAME}:0",
      "atc+prb_del={PRB_ID}"
      ]
}

 

AT Command Reference for the Sensor Interface Setup

The following AT commands are used to set up the sensor interface, such as configuring power management, data interface settings. 

ℹ️
INFO
  • Values enclosed in braces {...} are assigned automatically while deploying the sensor profile.
  • Values enclosed in angle brackets <..> are values that have to be setup in the profile.

 

1. ATC+IO_PSM

Defines how the sensor’s power supply is managed. Two power mechanisms are available:

  1. Always On: The sensor remains powered continuously.
  2. Interval-Based Power: The sensor remains off until a reading is triggered. Power is then enabled for <SensorWarningTime> milliseconds before the data is read, after which the sensor is powered off again.

Parameters of the atc+io_psm command:

ATC+IO_PSM={PRB_ID}:<UartPSM>:<SensorPSM>:<SensorWarningTime>:<SensorVolt>:<method>
{PRB_ID}
Default identifier assigned by WisToolBox. Keep {PRB_ID} unchanged.
<UartPSM>

UART power mechanism:

  • 8 = power always on
  • 9 = automatic power-off mode
<SensorPSM>

Sensor power mechanism:

  • 0 = power always on
  • 1 = automatic power-off mode
<SensorWarningTime>

The duration, in milliseconds, that the sensor remains powered in automatic power-off mode before the sensor data is read.

Otherwise, it’s 0.

<SensorVolt>

 Voltage selector for sensor supply:

  • 0 = 12 V
  • 1 = 24 V
  • 2 = 0 V (sensor has its power supply)
<method>
  • 0 = Enforce to use {SensorWarningTime}
  • 1 = Use the {SensorWarningTime} or existing device setting, whichever is greater.

Example
Periodic power-off mode with 5-second sensor power on:

ATC+IO_PSM={ProbeID}:9:1:5000:0:1

 

2. ATC+IO_CFG

Defines the interface parameters.

ATC+IO_CFG={PRB_ID}:<if>:<value1>:...:<valueN>
{PRB_ID}
Default identifier assigned by WisToolBox. Keep {PRB_ID} unchanged.
<if>

Interface ID:

  • 0 = RS485
  • 1 = RS232
  • 2 = SDI12
  • 3 = DI
  • 4 = DO
  • 5 = AIC (current)
  • 6 = AIV (voltage)
  • 7 = PT100
<value1>:...:<valueN> Depends on the interface type

 

For RS485, RS232, and SDI12, the value fields are:

ATC+IO_CFG={PRB_ID}:<if>:<baudrate>:<databit>:<stopbit>:<parity>
<baudrate>
Supported values include 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200.
<databit>
The number of data bits supported is 7 and 8.
<stopbit>
The number of stop bits supported is 1, 1.5, and 2.
<parity>

Parity:

  • 0 = None
  • 1 = Even
  • 2 = Odd

Example
RS485 connection with 4800 baud, 8 data bits, 1 stop bit, and no parity:

ATC+IO_CFG={PRB_ID}:RS485:4800:8:1:0

 

3. ATC+SNSR_CONF

Sensor rules for sending data packets

ATC+SNSR_CONF={PRB_ID}:<snsr_rule>:{SNSR_INTV}:<method>
{PRB_ID}
Default identifier assigned by WisToolBox. Keep {PRB_ID} unchanged.
<snsr_rule>
The sensor template only supports 8 for the periodic time.
{SNSR_INTV}
Default identifier assigned by WisToolBox. Keep {SNSR_INTV} unchanged.
<method>
  • 0 = Change setting if existing
  • 1 = Force change setting
  • 2 = Change the setting if it does not exist

Example
Periodic sending of data every 5 minutes:

ATC+SNSR_CONF={PRB_ID}:8:{SNSR_INTV}:1

 

4. ATC+IO_ADDPOLL

Definition of an RS485/Modbus register read command

ATC+IO_ADDPOLL={PRB_ID}:<if>:{TASK_ID2}:{DEV_ADDR}<reg_type><reg_addr><data_len>:<period>:{timeout>:{retry>:{data_type>:{scale>:{snsr_type>:{PROFILE_NAME}

 

{PRB_ID}
Default identifier assigned by WisToolBox. Keep {PRB_ID} unchanged.
<if>
Interface type: Options include RS485, RS232, and SDI-12.
{TASK_IDn}
Task Identifier: Must start with {TASK_ID1}, followed by {TASK_ID2}, {TASK_ID3}, and so on.
{DEV_ADDR} Default identifier assigned by WisToolBox. Keep {DEV_ADDR} unchanged.
<reg_type> Specifies the register type. Use 03 for a Holding Register.
<reg_addr>
Modbus register address: 4-byte hex value.
<data_len> Data length in hexadecimal (4 bytes). Common value: 0001.
<period> Register poll intervals in seconds, with a minimum of 60 seconds.
<timeout> Time to wait for a sensor response, in milliseconds.
<retry> Number of attempts to read the value.
<data_type> The data type of the register, where 6 represents a 16-bit signed integer.
<scale> Divider/Multiplier for scaling sensor data.
<snsr_type> Specifies the sensor type and its unit of measurement. Refer to the table of sensor types.
{PROFILE_NAME} Default identifier assigned by WisToolBox. Keep {PROFILE_NAME} unchanged.

Example
RS485/Modbus register read from device 0x01. It uses a holding register (03) with the following parameters:

  • Register Address: 0
  • Data Length: 1
  • Poll Interval: 60 seconds
  • Max Wait Time: 1000ms
  • Max retries: 2
  • Data Type: 16-bit unsigned integer
  • Scale: 0.1
  • Sensor Type: Moisture

AT command syntax:

ATC+IO_ADDPOLL={PRB_ID}:RS485:{TASK_ID1}:{DEV_ADDR}0300000001:60:1000:2:6:0.1:188:{PROFILE_NAME}

Parameter Details:

  • {DEV_ADDR}: The RS485/Modbus address of the device. This is a 2-byte hexadecimal value, assigned when the sensor profile is imported.
  • <reg_type>: Indicates the type of action to be performed on the Modbus. It occupies 2 bytes.
reg_type ACTION
01 Read coils or digital outputs
02 Read digital inputs
03 Read registers or analog outputs
04 Read analog inputs
05 Write a single coil or output
06 Write a single register
15 Write multiple coils or outputs
16 Write multiple registers
  • <reg_addr>: The start address of the end device to read or write to. It occupies 4 bytes in hexadecimal value format.
  • <data_len>: The number of registers or coils to read or write to. It occupies 4 bytes in hexadecimal format.
ℹ️
INFO

{DEV_ADDR}, <reg_type>, <reg_addr> and <data_len> form the ModBus command for data polling. They are written together without a separating colon between them.

 

Sensor Types

SENSOR VALUE TYPE SENSOR VALUE TYPE

Air Quality Index

105 Analog Input 2

BOD (Biochemical Oxygen Demand)

26 Battery Level (Voltage) 186
CO2 concentration

 

125 Battery Capacity 184
COD (Chemical Oxygen Demand) 22 DC Current (Battery Charging) 185
Digital Input 0 Digital Output 1
EC (Electrical Conductivity) uS/cm 192 Humidity 104
Moisture 188 Illuminance 101
NO3 24 NH4+ 25
Noise 233 Nitrogen 16
PM10 227 PM2.5 228
Percentage 120 Orientation 229
Potassium 18 Phosphorus 17
Presence 102 Precipitation 119
Salinity 19 Pressure 115
Temperature 103 Strikes 145
VOC 138 Turbidity 23
Wind Direction 159 DC Voltage 154
Wind Speed 158 Pressure 130

 

5. ATC+IO_DECODE

Definition for DI, DO, and analog interface

ATC+IO_DECODE={PRB_ID}:<ifname>:<Channel>:<value1>:...:<valueN>
{PRB_ID}
Default identifier assigned by WisToolBox. Keep {PRB_ID} unchanged.
<ifname>
Interface name (e.g., ai, di, or do).
<Channel>

Channel number

  • for ai = 1
  • for di = 1
  • for do = 1 or 2
<value1>:...:<valueN> Depends on the interface type

 

Values for the analog interface:

<ipso>
Type of sensor as the IPSO code
<max>
Min input value
{PROFILE_NAME}
Default identifier assigned by WisToolBox. Keep {PROFILE_NAME} unchanged.
<method>
  • 0 = Change setting if existing
  • 1 = Force change setting
  • 2 = Change the setting if it does not exist

Example
Analog interface on channel 1, sensor type 130, max value 5, min value 0:

ATC+IO_DECODE={PRB_ID}:ai:1:130:5:0:{PROFILE_NAME}:1

 

Values for digital input:

<ipso>
Type of sensor as the IPSO code
<trigger_mode>

When to trigger

  • 0 = no trigger (read-only value in intervals)

  • 1 = Rising edge trigger

  • 2 = Falling edge trigger

  • 3 = Rising and falling edge trigger

<debounce>
Debounce time
{PROFILE_NAME}

Default identifier assigned by WisToolBox. Keep {PROFILE_NAME} unchanged.

<method>

0 = Change setting if existing

1 = Force change setting

2 = Change the setting if it does not exist

 

Values for digital input:

<ipso>
Type of sensor as the IPSO code
<reserved>
Reserved field, use 0
{PROFILE_NAME}
Default identifier assigned by WisToolBox. Keep {PROFILE_NAME} unchanged.
<method>
  • 0 = Change setting if existing
  • 1 = Force change setting
  • 2 = Change the setting if it does not exist

 

6. ATC+PRB_DEL

Force removal of the Probe IO after setup. Probe IO will automatically reconnect with the new interface settings.

ATC+PRB_DEL={PRB_ID}
{PRB_ID}
Default identifier assigned by WisToolBox. Keep {PRB_ID} unchanged.

 

Importing a Sensor Profile File

Additional Requirement:

A text editor or viewer on the mobile phone that supports JSON files.

Preparation

1. Write a sensor profile and save it as a .json file. For example, the Huamo water pressure sensor type RG202011170 content may look like this:

{
    "SensorName": "WPA",
    "TemplateVersion": "1",
    "ProbeioVersion": "1.2.7",
    "Interface": "AI",
    "Content": [
      "atc+io_psm={PRB_ID}:9:1:10000:0:1",
      "ATC+SNSR_CONF={PRB_ID}:8:{SNSR_INTV}:2",
      "atc+io_decode={PRB_ID}:ai:1:115:100:0:{PROFILE_NAME}:0",
      "atc+prb_del={PRB_ID}"
      ]
}
 

2. Save this file as WPA.json and transfer it to your mobile phone. Alternatively, the file can be sent to the phone via email or a messaging app. 

Import the Sensor Profile

1. Connect WisToolBox to the Sensor Hub and navigate to the Sensor Probe tab.

2. Open the Generic Probe IO section, scroll down to locate the IMPORT SETTINGS option, and click it.

 

WisToolBox-Profile-Setup-1.png

Figure 10: Import the sensor file

3. A new window will appear, prompting a QR code scan or to open the RAKwireless URL.

WisToolBox-Profile-Setup-2.png

Figure 11: Scan QR code

4. Keep the WisToolBox app page open in the background and switch to the text editor or viewer on your mobile phone.

5. Open the email or message with the sensor profile and copy the sensor profile.

 

water-pressure-sensor-copy-profile.png

Figure 12: Copy the WPA.json code

6. Return to the WisToolBox window. When the pop-up appears, click APPLY to proceed.

 

water-pressure-sensor-apply-profile.png

Figure 13: Click APPLY to save the configuration

WisToolBox will return to the main screen and show the import progress.

water-pressure-sensor-applying-profile.png

Figure 14: Applying commands in progress

After the Sensor Profile Import

Once the import is finished, the Probe IO will disconnect and reconnect automatically. After the reconnection, the new setup of the Probe IO with the soil sensor will be visible.

 

water-pressure-sensor-applyed-profile.png

Figure 15: Probe IO new setup

 

On the first refresh, the sensor values might still be showing 0. Use the FETCH DATA button to manually trigger a sensor read.

ℹ️
INFO

The FETCH DATA function only reads and displays the sensor data in the app. It does not transmit the values over LoRa or cellular networks.

 

The third-party 4-20 mA sensor connected to the Probe IO and Sensor Hub is now ready to transmit data.


bernd-giesecke.png

Bernd Giesecke

Bernd is an Electronics Engineer and Product Manager at RAKwireless with 23 years of experience in industrial and automotive hardware and software R&D. He has been supporting the Arduino open-source community since 2014.

 


Changelog

  • Version 1 - How to Connect a Third-Party 4-20 mA Analog Sensor to RAK Sensor Hub
    • Author: Bernd Giesecke
    • Reviewer: Karla Jimenez
    • Date Published: 05/19/2025

Updated