TapHome

Liquid Level Sensor

Modbus RTU
Submitted by
Last updated: 04. 2026

Requires external gateway

TapHome Modbus Gateway — product page

Liquid Level Sensor

A generic Modbus RTU submersible hydrostatic liquid level sensor for monitoring water level in tanks, wells, or retention basins. The sensor communicates over RS-485 half-duplex and reports the measured level via holding register H:4. The TapHome template reads the measurement value with automatic decimal point conversion, supporting meters (m) and centimeters (cm) as display units.

This template is designed for generic Chinese-manufactured pressure/level transmitters that follow the same Modbus register map. The sensor is typically powered by 12-36 V DC and uses a 2-wire RS-485 connection to the TapHome Modbus Gateway.

Hardware connection

The sensor uses an RS-485 half-duplex interface for Modbus RTU communication. Connect the sensor to the TapHome Modbus Gateway:

  • A+ (RS-485 Data+) on the sensor to A+ on TapHome Modbus Gateway
  • B- (RS-485 Data-) on the sensor to B- on TapHome Modbus Gateway
  • GND to a common ground reference

The sensor also requires a separate DC power supply (typically 12-36 V DC, depending on the model). Power wires are separate from the RS-485 data wires.

Ensure a common ground reference between the sensor and the TapHome Modbus Gateway. Without proper grounding, Modbus communication may be unreliable or fail entirely.

Configuration

Default communication parameters

The sensor ships with the following default serial settings:

ParameterDefault
Baud rate9600 bps
Data bits8
ParityNone
Stop bits1
Slave address1

The baud rate can be changed via register H:1 (supported values: 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200). After changing the baud rate, write 0 to register H:15 to save the setting to the user area.

Unit selection

The measurement unit is configured via register H:2. The TapHome template only supports two units:

H:2 valueUnitBehavior
16m (meters)Returns the raw value directly (with decimal point conversion)
17cm (centimeters)Returns the value divided by 100
All othersMPa, KPa, bar, etc.Returns NaN – not supported by the template

If the sensor is configured to a unit other than m (16) or cm (17), the TapHome template will show NaN. Verify the unit setting before importing the template.

Decimal point precision

Register H:3 controls how many decimal places the raw measurement value uses:

H:3 valueFormatDivision factor
0####1
1###.#10
2##.##100
3#.###1000
4.####10000

The TapHome template automatically divides the raw H:4 value by 10^(H:3) to produce the correct reading. For example, if H:3 = 1 (one decimal point) and H:4 = 2500, the displayed value is 250.0.

Import parameters

When importing the template in TapHome, two parameters are required:

ParameterDescriptionExample
Slave IdModbus slave address of the sensor (1-255)1
IP addressIP address of the TapHome Modbus Gateway192.168.1.100

Device capabilities

Water level measurement

The template provides a single read-only sensor device – Water Level – that reads holding register H:4 (Int16). The ReadState script applies dynamic conversion:

  1. Reads the raw integer value from H:4
  2. Divides by 10^(H:3) to apply the decimal point setting
  3. Switches on H:2 (unit): if unit = 16 (m), returns the value directly; if unit = 17 (cm), divides by 100; otherwise returns NaN

The sensor polls every 15 seconds.

Service diagnostics

The module exposes four service attributes for monitoring the sensor configuration:

  • Slave Address – current Modbus slave address (H:0)
  • Baud Rate – current communication speed, displayed as the actual baud rate value (e.g. 9600, not the register enum)
  • Unit – currently configured measurement unit (e.g. “m”, “cm”, “MPa”)
  • Decimal Points – current decimal point format (e.g. “###.#”)

A service action Rewrite Slave Address allows changing the sensor’s Modbus address (1-255) directly from TapHome without external tools. The action writes the new address and automatically saves it to the sensor’s user area.

Additional capabilities

The sensor also exposes registers for range zero point (H:5) and full scale point (H:6) calibration references, a zero-bit offset register (H:12) for fine-tuning the measurement output, a 4-byte IEEE 754 floating point measurement output (H:22-23), and serial parity configuration (H:37). A factory reset command (H:16) can restore all parameters to factory defaults. These can be added in a future template update.

If higher precision is needed, the floating point measurement at registers H:22-23 provides the same reading in IEEE 754 format (big-endian ABCD byte order) without the integer rounding of H:4.

Troubleshooting

Sensor returns NaN
  1. Check register H:2 (Unit) – the template only supports unit 16 (m) and 17 (cm). All other units will return NaN
  2. Use the Unit service attribute in TapHome to verify the current setting
  3. If the unit is incorrect, use a Modbus tool to write the correct value to H:2, then write 0 to H:15 to save
No communication
  1. Verify RS-485 wiring: A+ to A+, B- to B-, and common GND
  2. Check that the baud rate matches between the sensor and TapHome (default: 9600, N, 8, 1)
  3. Confirm the correct Slave ID was entered during template import
  4. Verify the IP address points to the correct TapHome Modbus Gateway
  5. If wires are swapped (A+/B-), reverse them – some sensors label pins differently
Incorrect readings
  1. Verify the decimal point setting (H:3) matches the sensor’s factory configuration
  2. Check the unit setting (H:2) – cm mode (17) divides by an additional factor of 100
  3. For submersible sensors, ensure the probe is fully submerged and the cable is not kinked

Available devices

Liquid Level Sensor Module
Service Attributes
Slave Address
Baud Rate
Unit
Decimal Points
Service Actions
Rewrite Slave Address

Liquid level sensor - retenčná nádrž

Service Attributes
Slave Address
modbusr(H, 0, int16);
Baud Rate
SWITCH(modbusr(H, 1, int16),
	0, 1200,
	1, 2400,
	2, 4800,
	3, 9600,
	4, 19200,
	5, 38400,
	6, 57600,
	7, 115200,
      NaN
);
Unit
switch(modbusr(H, 2, int16),
	0, "MPa",
	1, "KPa",
	2, "Pa",
	3, "bar",
	4, "mbar",
	5, "Kgcm2",
	6, "PSI",
	7, "mH2O",
	8, "mmH2O",
	9, "inH2O",
	10, "H2O",
	11, "mHg",
	12, "mmHg",
	13, "inHg",
	14, "atm",
	15, "Torr",
	16, "m",
	17, "cm",
	18, "mm",
	19, "Kg",
	20, "°C",
	21, "PH",
	22, "°F",
	NaN
);
Decimal points
SWITCH(modbusr(H, 3, int16),
	0, "####",
	1, "###.#",
	2, "##.##",
	3, "#.###",	
	4, "#.###",
	NaN
);
Service Actions
Rewrite the Slave Address
Parameters: Slave Address (1–255 SlaveAddr)
modbusw(SH, 0, int16, SlaveAddr);
modbusw(SH, 15, int16, 0);  # Save to user area
Water Level Variable Read-only

Liquid level measurement in meters or centimeters — reads the hydrostatic pressure sensor output with configurable decimal precision

Register: H:4 Int16 Unit: dynamic numeric

Water Level

Read
VAR val := MODBUSR(H, 4, Int16)/power(10, modbusr(H, 3, int16));

switch(modbusr(H, 2, int16),
	16, val,
	17, val / 100, 
	NaN
);
Connection: Modbus RTU • 9600 baud• 8N1 • Slave ID: $[SlaveId]
Possible improvements (6)
  • H:5 Range Zero Point — Int16, transmitter range zero point — factory calibration reference
  • H:6 Range Full Point — Int16, transmitter range full scale point — factory calibration reference
  • H:12 Zero Bit Offset — Int16 (R/W via 0x06), zero-bit offset value — pressure output = calibration + offset. Factory default 0
  • H:22 Floating Point Measurement — 4-byte float (IEEE 754, big-endian ABCD), 2 registers starting at 0x0016 — same measurement as H:4 but in float format
  • H:37 Serial Check Bit — Int16 (R/W via 0x06); enum: 0=None, 1=Odd, 2=Even — serial parity configuration
  • H:16 Restore Factory Parameters — Write 1 to 0x0010 to restore factory defaults — resets address, baud rate, and calibration. Requires re-searching for transmitter

Sources

  • Modbus RTU communication protocol documentation for pressure and level transmitter