Monitoring the water level in your rain barrel, water tank, or IBC container can be easy and reliable – if your sensor is placed correctly. The SmartGateways Distance Meter Gateway uses an ultrasonic sensor, which works by bouncing sound waves off the water surface. But incorrect installation or placement can lead to strange readings, jumping values, or no data at all.

In this blog post, we’ll explain:

  • How the sensor works (in simple terms)
  • What conditions must be met for accurate measurements
  • Real-world installation examples (with sketches)
  • The most common issues and how to solve them

This guide is based on the official Smart Gateways Manual with extra tips to help you avoid frustrating mistakes.

1. How the Ultrasonic Sensor Works

The Distance Meter Gateway uses an ultrasonic distance sensor. That sounds complicated, but it just means this little device uses sound to measure distance — like a bat.

What does it do?

The sensor sends a sound wave (you can’t hear it) and waits for the echo. When the sound bounces back (like an echo in a canyon), the sensor knows how far away the surface is — for example, the water level in a tank.

What distances can it measure?

  • Minimum distance: 20 cm (the sound needs space to bounce back properly)
  • Maximum distance: 450 cm

If your water level gets too close to the sensor (under 20 cm), it stops working and show strange values, mostly a distance of 0 cm.

What is the sensor’s “view” or “angle”?

The sound wave spreads out like a cone:

  • The beam angle is 30° wide
  • That means the sound doesn’t just go straight down — it spreads out as it travels
  • The further the distance, the wider the area it sees

Example:
At 100 cm distance, the “view area” is about 53 cm wide.
So the sensor may “see” the sides of your tank or a pipe if it’s in the way.

What can go wrong?

The sensor doesn’t know what it’s measuring — it just hears echoes. If the sound bounces off:

  • a slanted wall
  • a pipe
  • or a floating lid

…it can give the wrong distance.

That’s why it’s important to install the sensor pointing straight down, with clear space under it.

Distance Meter Gateway showing the real-time measurements on the internal webserver

2. Basic Sensor Requirements

Before installing your Ultrasonic sensor, make sure the following conditions are met:

  1. Minimum distance to surface:
    The sensor only works for distances greater than 20 cm. Too close, and it won’t detect the water (The ultrasound waves need some distance to measure).
  2. Maximum distance:
    Reliable readings up to around 450 cm.
  3. Sensor must be mounted straight (90°)
    It must point directly downward to measure the distance accurately.
  4. Clear line of sight to the water:
    The sensor should not “see” any wall edges, pipes, or overflows below it.
  5. No foam, waves, or floating debris:
    These may distort or block the ultrasonic signal.
  6. Keep it dry:
    The sensor head is waterproof, but the rest of the device (the white box) must stay dry and protected.

3. Sensor Placement and Gateway Settings

Correct placement of the ultrasonic sensor is critical for accurate and reliable distance readings. The sensor must have a clear “view” of the water surface, and its mounting height must be set correctly in your system to interpret the values meaningfully.

Below we explain the most common installation methods with examples, and how to set the correct offset.

General Rules for Placement

  • The sensor must point straight down (not angled).
  • There should be no obstacles (like edges, wires, or pipes) within the 30° beam cone.
  • The surface below must reflect sound well (still water is ideal).
  • Do not place the sensor too close to the water — minimum 20 cm is needed.
  • The sensor must always be placed above the maximum water level.
  • Keep the sensor away from walls, corners or tank edges. The sound beam has a 30° cone shape, so any nearby wall or object can cause unwanted reflections or false readings. Leave enough space around the sensor so that the entire sound cone has free space all the way to the water surface.

4. Height Setting

The height is the actual physical height of the tank or pit — from the bottom to the highest possible water level. This value is crucial, as all calculations in the gateway are based on it. These calculations include determining the percentage of water in the tank.

For example, if your tank is 100 cm high and can be completely filled to the top, then you should enter 100 cm as the height. However, be aware: if the sensor is placed exactly 100 cm above the bottom, it typically cannot measure the top 20 cm. This is because ultrasonic sensors have a minimum measurable distance, usually around 20 cm. In this case, the sensor would only detect the water when the level drops below 80 cm — so you wouldn’t know when the tank is completely full.

You can solve this by mounting the sensor higher than the tank itself and using an offset value. How this works is explained in the next section.

Another important note: the measured distance (from the sensor to the water surface) must never exceed the configured height in the gateway. If it does, the gateway will interpret this incorrectly, thinking the water level is far lower than physically possible. This leads to incorrect readings — even negative values — which are unacceptable.

To avoid this, we recommend setting the height slightly higher than the actual tank height. For example, instead of exactly 100 cm, use 105 or 110 cm. This creates a safety margin that prevents issues when the sensor detects slightly more than expected.

5. Offset Setting

The offset is used to correct the measurement when the sensor is not placed exactly at the top edge of the tank. For example, if the tank is 100 cm high but the sensor is mounted 10 cm above the tank, the sensor will measure from 110 cm. In this case, you need to enter an offset of -10 in the gateway’s web interface. This tells the gateway to subtract 10 cm from every measurement, so the level is calculated correctly.

You can also place the sensor 10 cm below the top of the tank. In that case, the sensor only sees water up to 90 cm. To correct this, you set the offset to 10. The gateway will then add 10 cm to the measured value.

Using the offset helps ensure that the water level is always shown accurately, even when the sensor is not installed exactly at the top of the tank.

Need help? Reach out via smartgateways.nl/en/contact for support or additional information.

Distance Meter Gateway Sonar Sensor for Waterlevels Home Assistant Dashboard

6. Sensor Placement Examples

Correct placement of the sensor is critical to ensure accurate and reliable distance measurements. The diagrams below illustrate common installation scenarios, highlighting both recommended and problematic setups.

These examples help you understand:

  • How to avoid false readings caused by obstacles or reflections
  • The importance of aligning the sensor perpendicular to the measured surface
  • How height and surface shape influence measurement quality

Use these diagrams as a guideline when planning your installation to ensure the sensor performs optimally in your specific environment.

Diagram 1

Ultrasonic sensor mounted directly above a 100 cm high, 50 cm wide water tank, beam angle of 28.1 degrees
The sensor is correctly placed but keep
  • Sensor is placed in the center above the tank.
  • Tank size: 100 cm high and 50 cm wide.
  • The sensor cannot measure the top 20 cm when the tank is full.
  • Beam angle is 28.1°, close to the 30° maximum.
  • Sound waves can reflect from the side walls – Reflections are more likely when the tank is nearly empty.
  • This may affect measurement accuracy when the tank is almost empty.

Diagram 2

Ultrasonic sensor mounted off-center above a 100 cm high, 50 cm wide water tank.
  • Sensor is mounted off-center on top of the tank.
  • Tank dimensions: 100 cm high and 50 cm wide.
  • The sensor’s 30° beam hits the left side wall.
  • This causes ultrasonic waves to reflect prematurely.
  • Reflections lead to incorrect or unstable measurements.
  • For best results, place the sensor in the center above the tank.

Diagram 3

Ultrasonic sensor mounted 10 cm above a 100 cm high, 50 cm wide tank, with the beam hitting the tank walls.
  • Sensor is mounted 10 cm above the top of the tank.
  • Tank size is 100 cm high and 50 cm wide.
  • The 30° ultrasonic beam hits the tank walls.
  • Sound waves reflect off the walls, causing false readings.
  • This results in inaccurate or unstable measurements.
  • Place the sensor lower or expect that the level of the tank will not exceed the red markings

Diagram 4

Ultrasonic sensor mounted 10 cm above an 80 cm wide, 100 cm high tank, with the beam not touching the tank walls.
  • Tank height is 100 cm and width is 80 cm.
  • Sensor is mounted 10 cm above the top of the tank.
  • Offset is set to -10 cm in the gateway settings – the gateway subtracts 10 cm from the measurement to correct for the 10 cm higher placed sensor
  • The ultrasonic beam does not hit the tank walls.
  • No reflections occur, resulting in reliable measurements.
  • Offset corrects the distance so the water level is accurately reported.

Diagram 5

Ultrasonic sensor mounted 10 cm below the top of an 80 cm wide, 100 cm high tank, with the beam clear of the walls.
  • Tank height is 100 cm and width is 80 cm.
  • Sensor is mounted 10 cm below the top of the tank.
  • Offset is set to +10 cm in the gateway settings.
  • The ultrasonic beam does not hit the tank walls.
  • No reflections occur, resulting in stable and accurate readings.
  • The offset adds 10 cm to the measurement to show the correct water level.

Diagram 6

Ultrasonic sensor above a 100 cm high, 50 cm wide tank with an obstacle inside causing sound wave reflections.
  • Tank size: 100 cm high, 50 cm wide.
  • An obstacle inside the tank reflects ultrasonic waves.
  • Reflections cause incorrect and unstable measurements.
  • Sensor must have a clear line of sight to the water surface.
  • Obstructions under the sensor are not allowed.
  • Clear view is essential for accurate and reliable readings.

7. Troubleshooting: How to Diagnose and Test Your Sensor

If you’re experiencing unexpected results or want to verify the accuracy of your Distance Meter Gateway, it’s essential to use the live logging function while testing.

Step-by-Step Diagnostic Procedure

  1. Point the sensor at a representative surface
    Make sure the sensor is aimed at a flat surface (e.g., water or a solid object) at a realistic distance. This surface should reflect the actual conditions of your final setup.
  2. Set a representative height and offset
    In the configuration, set the “height” (distance from the sensor to the bottom of the tank/pit) and “offset” (correction added to the measured distance) to values that reflect your intended installation.
  3. Monitor live readings
    Connect the USB port of the gateway to your PC or Mac. Install a small terminal program (e.g., PuTTY, CoolTerm, or SerialTools). Full instructions can be found here:
    https://smartgateways.nl/en/view-the-log-of-a-gateway/
  4. Observe real-time measurements
    The log will show two measurements per second, including:
    • The raw distance measured by the sensor
    • The adjusted value after applying the height and offset
    • The calculated percentage full
  5. Validate your setup
    This logging process allows you to:
    • Confirm the sensor is functioning correctly
    • Verify that distance readings are stable
    • Check that your height and offset settings result in an accurate percentage full
  6. Get a feel for how the sensor behaves
    By reviewing the logs, you gain an intuitive understanding of how your sensor performs in different conditions. This helps you fine-tune the installation and decide whether your final setup meets the requirements for reliable operation.

8. Frequently Asked Questions (FAQ)

What is the minimum distance the sonar sensor of the Distance Meter Gateway can measure?
The sensor needs at least about 20 cm distance to the water surface to measure correctly. If the water is closer than this, the sensor may give incorrect or no readings.

What is the maximum distance the sensor can measure?
The maximum reliable measuring distance is around 450 cm. Distances beyond this may lead to inaccurate results.

Why must the sensor be mounted pointing straight down?
The sonar sensor sends sound waves in a cone shape (about 30° wide). If it is tilted, the sound waves can bounce off walls or miss the water surface, causing wrong readings.

Can the sensor be placed near the tank edges?
No, placing the sensor too close to the edges is not recommended. Because of the 30° beam angle, the sound waves can hit the tank walls and reflect, causing false measurements. The sensor should be placed near the center with enough free space around it.

What is the “height” setting and why is it important?
Height is the actual vertical size of your tank from bottom to the highest water level. All level calculations are based on this number. The measured distance must never be greater than the height, or else the system gives invalid results. It’s best to set the height a little higher than the real tank height to avoid errors.

What does “offset” mean and when do I use it?
Offset is used when the sensor is not mounted exactly at the top of the tank.

  • If the sensor is above the tank top (e.g., 10 cm higher), use a negative offset (e.g., -10) to subtract this extra height from measurements.
  • If the sensor is below the tank top (e.g., 10 cm lower), use a positive offset (e.g., +10) to add the missing distance.

This correction ensures the water level is shown accurately.

What causes unstable or incorrect readings?
Common causes include:

  • Sensor placed too close to walls or edges causing reflections
  • Obstacles inside the tank reflecting sound waves
  • Sensor mounted at an angle
  • Sensor too close to the water surface (less than 20 cm)
  • Incorrect height or offset settings in the gateway
  • drop of moisture on the sensor, clean it with a dry wipe

Can obstacles inside the tank affect measurement?
Yes, any object that reflects sound waves inside the tank can cause wrong readings. The sensor must have a clear line of sight to the water surface — this is a strict requirement.

Can obstacles inside the tank affect measurement?
Yes, any object that reflects sound waves inside the tank can cause wrong readings. The sensor must have a clear line of sight to the water surface — this is a strict requirement.

How can I improve the reliability of the measurements?

  • Make sure the sensor is mounted firmly and does not vibrate.
  • Use a stable 5V power supply for the sensor.
  • Place the sensor at a proper height above the water surface (at least 20 cm).
  • Take multiple measurements and use averaging or median filtering to reduce fluctuations.
  • Avoid placing the sensor in tight spaces with many reflections.

What should I do if the sensor does not give any readings?

  • Check if the sensor is properly connected and powered.
  • Ensure the trigger pulse duration is set correctly (minimum 10 µs).
  • Use an oscilloscope to check the signal output.
  • Test the sensor with another object at a known distance to see if it responds.

Where can I get support?
If you need help or have technical questions, you can contact the Smart Gateways team through their contact page. They’re happy to assist.

9. Conclusion

The Distance Meter Gateway offers a reliable and easy-to-use solution for monitoring water levels in tanks, brine containers, IBCs, wells, and more. With accurate ultrasonic sensing, seamless integration into platforms like Home Assistant, and flexible installation options, this sensor enables smarter water management and helps prevent overflows or shortages. Whether you’re tracking the salt level in a water softener or monitoring rainwater usage, the Distance Meter Gateway provides clear insights and dependable performance.

For detailed setup instructions and troubleshooting, refer to the logging guide and the comprehensive Home Assistant integration tutorial.

Leave a Reply

Your email address will not be published. Required fields are marked *