ULM-100 with Arduino, ESP32, Raspberry Pi and Python

How to wire the ULM-100 Ultrasonic Level Sensor for Tanks & Reservoirs to your own microcontroller or computer and read it over RS485 Modbus RTU. The tables are the ones in the datasheet, and both code examples are run against the datasheet example frame before this page is published.

Product page Datasheet (PDF) Datasheet (Markdown) Arduino sketch (.ino) Python script (.py)

ULM-100 Ultrasonic Level Sensor for Tanks & Reservoirs

Connecting the ULM-100

The probe is an RS485 device, so it needs a transceiver between it and your board. On a computer or a Raspberry Pi that is a USB to RS485 adapter. On a microcontroller it is a MAX485-type module on a hardware serial port. Power the probe from a supply within the voltage range in the table and join its ground to the ground of the transceiver.

Python example (Raspberry Pi, Linux, macOS, Windows)

The script needs only pyserial. It builds the Modbus request itself, checks the CRC of the reply and prints one reading every five seconds. On Windows pass the COM port as the argument.

#!/usr/bin/env python3
"""Read the Agrinovo ULM-100 over RS485 Modbus RTU.

Works on a Raspberry Pi or any computer with a USB to RS485 adapter.
Install the serial library once:  pip install pyserial
Run:  python3 ulm_100.py /dev/ttyUSB0
"""
import struct
import sys
import time

import serial

PORT = sys.argv[1] if len(sys.argv) > 1 else "/dev/ttyUSB0"
ADDRESS = 0x01  # the sensor's Modbus address


def crc16(frame: bytes) -> bytes:
    crc = 0xFFFF
    for byte in frame:
        crc ^= byte
        for _ in range(8):
            crc = (crc >> 1) ^ 0xA001 if crc & 1 else crc >> 1
    return struct.pack("<H", crc)


def read_registers(port, address, function, start, count):
    request = struct.pack(">BBHH", address, function, start, count)
    port.reset_input_buffer()
    port.write(request + crc16(request))
    reply = port.read(5 + 2 * count)
    if len(reply) >= 5 and reply[1] == function | 0x80:
        raise IOError(f"sensor returned Modbus error {reply[2]}")
    if len(reply) != 5 + 2 * count or crc16(reply[:-2]) != reply[-2:]:
        raise IOError("no valid reply from the sensor")
    return reply[3:-2]


def sign_and_size(raw):
    """The top bit is the sign, the other 15 bits the size."""
    return -(raw & 0x7FFF) if raw & 0x8000 else raw


def read_probe(port):
    data = read_registers(port, ADDRESS, 0x03, 0x0000, 1)
    return {
        "level": sign_and_size(struct.unpack(">H", data[0:2])[0]),  # cm
    }


if __name__ == "__main__":
    with serial.Serial(PORT, 9600, bytesize=8, parity="N", stopbits=1, timeout=1) as port:
        while True:
            print(read_probe(port))
            time.sleep(5)

Arduino example (Uno, Mega, ESP32, ESP8266, MKR, Pico)

The sketch uses the Agrinovo library: in the Arduino IDE open Sketch > Include Library > Manage Libraries and install "Agrinovo". The library picks the serial port for your board, and the pins are listed at the top of AgrinovoDefaultPort.h. DE and RE of the transceiver go to one output pin.

// Agrinovo ULM-100 ultrasonic level meter
// Prints level or distance every 5 seconds.
//
// Sensor terminals
//   1  supply +, 24 V DC
//   2  supply ground, joined to the board's ground
//   5  RS485 A
//   6  RS485 B
//
// The board talks to the sensor through an RS485 transceiver (MAX485 or
// similar). AgrinovoDefaultPort.h lists the serial pins used on each board.
//
// https://agrinovo.io/products/sensors/sillo/ulm-100-ultrasonic-level-meter/

#include <Agrinovo.h>
#include <AgrinovoDefaultPort.h>

const int DE_PIN = 4;  // transceiver DE and RE, tied together

AgrinovoBus bus(AGRINOVO_PORT, DE_PIN);
AgrinovoULM100 sensor(bus);  // Modbus address 1

void setup() {
  Serial.begin(115200);
  agrinovoPortBegin(9600);
  bus.begin();
}

void loop() {
  if (sensor.read()) {
    Serial.print("Level or distance: ");
    Serial.print(sensor.level(), 0);
    Serial.println(" cm");
  } else {
    Serial.println(sensor.errorText());
  }
  delay(5000);
}

What the examples read

Both examples send one request, function 0x03, 1 registers from 0x0000, and decode these values:

Value Unit Register Encoding
Level or distance cm 0x0000 16-bit integer, the top bit is the sign

Other Modbus tools

The same request works from any Modbus RTU master: pymodbus, minimalmodbus, Node-RED, LabVIEW, a PLC or a third-party data logger with a Modbus port. Use the serial settings, function code and register addresses above.

Logging without writing code

The Omni Genesis controller reads the ULM-100 and sends the readings to the Agrinovo cloud over the cellular network, where they can be exported or read through the cloud API.

Datasheet reference

Specifications

Measurement

Parameter Specification
Measuring Range 5 m / 10 m / 15 m / 20 m (per probe variant)
Accuracy 0.5% to 1.0% of measured range
Resolution 3 mm or 0.1% of range
Blind Zone 0.3 m (5 m range), 0.4 m (10 m), 0.6 m (15 m), 0.8 m (20 m)
Measurement Modes Level (default) or Distance
Application Liquids (water, wastewater, slurry, non-corrosive media)
Temperature Compensation Automatic, internal sensor

Electrical

Parameter Specification
Power Supply 24 VDC standard, 220 VAC +15% / 50 Hz optional
Analog Output 4-20 mA, 2-wire (250 Ω max load) or 4-wire (510 Ω max load)
Digital Output RS485 Modbus-RTU (or RS232 on request)
Relay Output Optional 2 × SPDT, AC 250 V / 8 A or DC 30 V / 5 A, programmable
Cable Entry M20×1.5

Mechanical and Environmental

Parameter Specification
Display LCD with keypad
Housing Die-cast aluminium (single or dual chamber) or plastic
Protection Grade Display IP66, Probe IP68
Probe Material Standard polymer; PVDF or PTFE optional for corrosive media
Process Connection Thread G1½, G2, M78×2, NPT 1½, NPT 2, or flange DN50 / DN65 / DN80 / DN100
Process Pressure ≤0.3 MPa (3 bar)
Process Temperature (probe) -20°C to +80°C
Operating Temperature (display) -20°C to +60°C

Measurement Modes

The meter supports two output modes, selectable from the front panel or via Modbus.

Level Mode (default)

4-20 mA output is proportional to liquid level (height of material above tank bottom).

Distance Mode

4-20 mA output is proportional to distance from probe face to liquid surface (empty height).

Installation

Position Selection

Install the meter perpendicular to the liquid surface. The space between the probe emitting face and the maximum liquid level must remain greater than the blind zone (see specifications table).

Avoid placement directly above fill streams, agitators, internal pipes, or weld seams. Any object within the beam path near the probe causes a strong false echo and corrupts the reading.

Flat-Top Tank with Connecting Pipe

When a short connecting pipe (nozzle) is used, the pipe length must not exceed 60 mm and the inner diameter must be at least 100 mm. The probe emitting face must protrude at least 3 cm below the underside of the flange.

Direct Flange Mount

The cleanest installation is direct mounting on the flat tank top without any connecting pipe. The probe emitting face sits below the datum plane and the full sensor range is usable above the blind zone.

Open Container Mount

Use an installation bracket and maintain the minimum wall distance for the selected range. Because an open container has no focusing effect, the meter may be installed at the center.

Range Min. Distance to Wall
5 m 0.5 m
10 m 1.0 m
15 m 1.5 m
20 m 2.5 m

Notes

  • Ultrasonic transmission requires a gaseous medium between the probe and the liquid surface. Vacuum vessels are not suitable.
  • When installing by thread, the probe must not be in direct contact with the metal bracket. Use the supplied rubber rings to isolate it.
  • Mount the probe at 1/2 or 2/3 of the tank-top radius on arch-roof tanks to avoid lens-focused false echoes.

Electrical Connections

Caution: AC power must only be connected to the AC terminals. Connecting AC to signal terminals will destroy the meter. The 485, 232, and 4-20 mA output terminals must not be short-circuited.

Four-Wire Terminal Layout

Four-Wire Wiring Diagram

Terminal Signal Function
1, 2 24 VDC+ / 24 VDC- Power supply
3, 4 mA+ / mA- 4-20 mA current output
5, 6 485A / 485B RS485 Modbus communication
7, 8 RL2 / COM Programmable relay 2
8, 9 COM / RL1 Programmable relay 1

Two-Wire Terminal Layout

Two-Wire Wiring (4-20 mA loop powered)

Terminal Signal Function
1 24 VDC+ Loop supply +
2 24 VDC- Loop supply / 4-20 mA return
3 GND Earth ground

Grounding and Anti-Interference

  • The meter must be grounded independently. Do not share grounding with frequency converters, motor drives, or panel boxes.
  • Signal cables must not share a tray with power cables. Run signal cables in a separate metal conduit, or keep at least 1 m of separation.
  • When the meter is powered alongside a VFD or motor, fit an isolation transformer on the supply side and a signal isolator on the analog output.

RS485 Modbus Communication

Communication Settings

Parameter Value
Protocol Modbus-RTU
Physical Layer RS485, half-duplex
Frame 10 bits (1 start, 8 data, 1 stop, no parity)
Baud Rate 2400 / 4800 / 9600 (default) / 19200
Default Slave Address 0x01
Address Range 0x01 to 0xFE
Byte Order Big-endian (higher byte first)
CRC CRC16 Modbus (low byte first)

Function Codes

  • 0x03 Read holding registers
  • 0x06 Write single register
  • 0x10 Write multiple registers

Register Map

Registers are partitioned into three areas. A single Modbus transaction must stay within one area.

Area Range Access
1 0x0000 to 0x0021 Read only
2 0x0022 to 0x005B Read / write
3 0x005C to 0x006B Read / write

Measurement registers (Area 1, function 0x03)

Address Description Format
0x0000 Instantaneous distance or level UINT16, cm
0x0001 Instantaneous analog output UINT16, raw
0x0002 Internal temperature UINT16

The measurement register returns whichever quantity (distance or level) corresponds to the active measurement mode. The top bit of the high byte is the sign flag: 0 = positive, 1 = negative.

Range and alarm registers (Area 2, function 0x03 / 0x10)

Address Description Unit
0x0022 / 0x0023 Alarm 1 value / Alarm 1 return difference as configured
0x0024 / 0x0025 Alarm 2 value / Alarm 2 return difference as configured
0x0026 / 0x0027 Alarm 3 value / Alarm 3 return difference as configured
0x0028 / 0x0029 Alarm 4 value / Alarm 4 return difference as configured
0x002A Reference zero point as configured
0x002B Range high point (20 mA) as configured
0x002C Range low point (4 mA) as configured
0x002D Current setpoint (wave-loss output) mA × 1000
0x002E Blind zone as configured

Configuration registers (Area 3, function 0x03 / 0x10)

Address High Byte Low Byte
0x005C Alarm 1 mode Alarm 2 mode
0x005D Alarm 3 mode Alarm 4 mode
0x005E Measurement mode Unit option
0x005F Algorithm option Safe-level mode
0x0060 Probe type Response speed
0x0061 Factory reset System reset
0x0062 Baud rate Working mode
0x006B Sensor type character Instrument address (read only)

Encoded Values

Field Values
Measurement mode 0 = Distance, 1 = Level
Unit option 0 = mm, 1 = cm, 2 = m
Alarm mode 0 = Off, 1 = Low-level alarm, 2 = High-level alarm
Safe level (wave loss) 0x00 = Hold last, 0x55 = Output min, 0xAA = Output max, 0xA5 = Output set value
Response speed 0 = Slow, 1 = Medium, 2 = Fast
Baud rate 0 = 2400, 1 = 4800, 2 = 9600, 3 = 19200
Working mode 0 = Auto-report, 1 = Inquiry

Reading the Measured Value

Example: read measurement from address 0x01

Request:  01 03 00 00 00 01 84 0A
Response: 01 03 02 00 10 B9 88
Field Bytes Value
Raw register 0x00 0x10 16
Sign bit 0 Positive
Unit cm 16 cm
Result 0.16 m

Example: negative reading (-0.16 m)

Response: 01 03 02 80 10 D8 48

The high byte 0x80 has its top bit set (sign = negative); the magnitude is 0x0010 = 16 cm.

Exception Codes

Code Meaning
0x01 Illegal function code
0x02 Illegal data address
0x03 Illegal data value
0x04 CRC16 check error
0x05 Receive correctly
0x06 Receive error
0x07 Parameter error

Configuration Reference

Range Setup

Parameter Description Default
Bottom Distance Reference zero point. Distance from probe face to tank bottom in level mode. Maximum range
Range Low (4 mA) Measurement value mapped to 4 mA output. 0
Range High (20 mA) Measurement value mapped to 20 mA output. Maximum range
Display Unit m / cm / mm m

Response and Damping

Setting Effect
Slow High noise immunity, slowest tracking
Medium Balanced (factory default)
Fast Lowest latency, lower noise immunity

Wave-Loss Behaviour

When echo is lost (turbulent surface, foam, beam blockage), the output follows the safe-level setting:

  • Hold (default): retains the last valid value, current output unchanged
  • Min: forces 4 mA
  • Max: forces 20 mA
  • Set value: forces a user-defined current between 3.6 mA and 22 mA

Relay Alarm Configuration (per relay)

Parameter Range
Mode Off / Low alarm / High alarm
Trigger value meters
Return difference (hysteresis) meters

A single relay can control a complete pump cycle. To drain a tank between 1 m (stop) and 5 m (start): High-level alarm mode, value = 5.00 m, return difference = 4.00 m.

Parameter Lock

Default unlock password is 25. The user may change the password at any time.

Application Notes

Signal Attenuation Budget

Real-world conditions reduce echo strength. Choose a meter range with margin equal to the sum of expected attenuations:

Condition Attenuation
Light surface ripple 5 to 10 dB
Heavy surface fluctuation, agitator running 10 to 20 dB
Light dust 5 dB
Heavy dust 5 to 20 dB
Light vapour / mist 5 to 10 dB
Heavy vapour / steam 10 to 20 dB
Probe vs medium temperature difference ≤40°C 5 to 10 dB
Probe vs medium temperature difference ≤80°C 10 to 20 dB

For each 10 dB of attenuation, multiply the required range by 1×; for combined attenuation totalling 15 to 40 dB, choose a meter at least 3× the actual maximum measured distance.

Drainage Wells and Common Wells

Narrow wellheads require a measuring casing or connecting pipe. Adding a pipe enlarges the blind zone by 50 to 100%. For a 0.5 m native blind zone, expect 1.0 m once the casing is fitted.

Casing inner diameter must be ≥150 mm for measuring ranges up to 4 m. The inner wall must be smooth (PVC or PE works) and free of internal joints.

Fault Handling

Symptom Likely Cause Action
Meter does not power on Power supply not connected Inspect supply wiring
Display blank Wiring loose between LCD and main board, or LCD damaged Re-seat the wiring; return for service if persistent
Output frozen, trumpet icon static Measured surface beyond range, heavy disturbance, dust, foam, or probe out of plumb Select a larger range, allow medium to settle, re-aim probe perpendicular to surface, raise probe height, check for blockage in blind zone
Erratic readings Strong nearby electromagnetic source (VFD, motor) Verify grounding, add isolation transformer and signal isolator, separate signal and power cables

Revision History

Rev Date Changes
1.0 June 2026 Initial release
1.1 August 2026 Layout revision
1.2 October 2026 New layout; corrected Modbus example CRC values

Contact

Agrinovo, https://agrinovo.io/products, [email protected], +972 54 688 8148 (direct / WhatsApp). Specifications subject to change without notice.

Questions about wiring or the protocol?

Tell us which board or logger you are using and what you need to measure.