The Shadow on the Moon

Sign In

Forgot username or password? Not enrolled? Sign up now.

Subject: TSoM Account Reinstatement Request

Thanks -- we've forwarded your request to support.

Menu
HomeServicesWorking with TSoMNewsArticlesMission & LeadershipPartners
Contact & Support
Contact UsMantis BT
← Back to Articles
Complications in tank level reading, and the signal analysis behind making sense of it.
July 29, 2026 IoT IIoT Ultrasonic Sensors Embedded Systems Low-Power Design Chemical Industry Signal Processing

Ultrasonic Tank Level Sensing: When Foam, Vapor, and the Unknown Liquid Fight Your Reading

By Damian Bucovsky, President at The Shadow on the Moon

Building reliable, ultra-low-power ultrasonic level sensing for small and medium chemical tanks comes with a problem that's rarely discussed, and often not even recognized until it shows up in the field: getting a trustworthy reading in the first place, on a liquid you often don't fully know, inside a headspace that's actively working against you.

You're not measuring a liquid, you're measuring whatever is on top of it

An ultrasonic sensor doesn't see the liquid. It sees the first surface that reflects sound back to it. On a calm water tank, that's the same thing. On a chemical tank, it very often isn't.

Foam is the obvious offender. Many chemicals foam when agitated by fill events, off-gassing, or temperature-driven convection, and foam is a terrible acoustic reflector — it scatters and absorbs sound rather than bouncing it cleanly. A foam layer can sit anywhere from a fraction of an inch to several inches above the true liquid surface, and it changes thickness over time. A sensor that just reports "distance to first strong echo" will report the foam top as the tank level, and that number will drift independently of the actual liquid volume. Depending on the chemistry, that error can be a minor nuisance or a genuinely dangerous false reading — either masking a near-empty tank or making an actual overfill look like there's still headroom.

Vapor and off-gassing are subtler and, in some ways, worse, because they don't just produce a bad echo — they change the medium the pulse travels through. Ultrasonic level measurement relies on knowing the speed of sound in the headspace gas to convert time-of-flight into distance. That speed of sound depends on gas composition and temperature. A pure air headspace at a known temperature is easy. A headspace with evaporating solvent, off-gassed vapor, or humidity buildup has a different density and composition than the air you calibrated against, and the speed of sound shifts accordingly. You can have a perfectly clean echo and still get a distance reading that's wrong, simply because the pulse traveled through a different acoustic medium than assumed.

The tank itself works against you: a small, enclosed headspace is an echo chamber

There's a complication that sits alongside foam and vapor and compounds both of them: the acoustic environment itself. Small and medium tanks are, acoustically, small enclosed cavities. The pulse the sensor emits doesn't travel in a clean straight line down to the liquid and back — in a tight or irregularly shaped headspace, some of that energy reflects off the tank walls, fittings, agitator shafts, and other internal structures before it ever gets back to the transducer. The result is a return signal that can carry secondary reflections layered on top of the true liquid-surface echo, effectively a mini reverberation field rather than a single clean pulse-echo pair. On a foam-free, vapor-free tank in a lab, this is a minor artifact you can filter out. Combine it with a foam layer that's itself scattering energy in multiple directions, and a vapor gradient that's bending the effective sound path, and you get an echo return that's legitimately hard to interpret as a single distance value. Part of the signal-processing job is separating "this peak is the real liquid surface" from "this peak is a wall reflection or a secondary bounce off the foam," and that separation gets harder, not easier, as tank geometry gets smaller and more cluttered.

Not knowing the chemistry is often by design, not by accident

In a lot of real deployments, you don't get a clean datasheet on the exact liquid, and it's usually not because nobody bothered to ask. Customers frequently treat their specific chemical formulation as protected IP and won't disclose the exact composition, concentration, or additive package, even to a vendor building a sensor for their own tank. During development and early trials, that typically means working with a close, or only quasi-close, stand-in chemical rather than the real thing — something with broadly similar density and acoustic behavior, but not a guarantee of matching foaming tendency, vapor pressure, or off-gassing behavior exactly. Some of the acoustic quirks of the actual liquid simply aren't knowable in the lab; they show up for the first time once the sensor is on the customer's real tank, and the honest expectation has to be that early field trials will surface behavior nobody anticipated, which then gets folded back in as a correction to the algorithm. That's a different situation than a liquid changing from batch to batch — it's less about drift over time and more about the fact that the true reference chemistry may be unknown, or only approximately known, for the life of the deployment. The system has to be robust to that uncertainty from day one, not tuned to a spec sheet that may never fully match reality.

This pushes the design away from "calibrate precisely for this chemical" and toward "characterize the echo well enough to know when to trust it, regardless of chemical." Practically, that means the firmware should be evaluating signal quality on every reading, not just extracting a number: echo amplitude, pulse width, presence of multiple return peaks, and how much the estimated level has moved since the last few readings. A clean, tall, single-peak echo consistent with recent trend history is trustworthy. A weak, broad, or multi-peak echo — or one that implies an implausible level jump — is a signal to flag the reading as degraded rather than report it as truth.

Temperature and condensation add a second axis of drift

Outdoor tanks see real diurnal and seasonal temperature swings, and headspace temperature affects speed of sound directly — roughly a fraction of a percent per degree, which sounds small until you're measuring across several feet of headspace and reporting to inch-level precision. Cheap systems that skip temperature compensation entirely will show a level reading that gently breathes up and down with the time of day, which is confusing on a trend chart and can trip false rate-of-change alarms.

Condensation is a related but distinct problem: moisture forming on the transducer face itself, rather than in the headspace gas, can attenuate or distort the outgoing and returning pulse directly at the source. This tends to show up as a gradual, unexplained weakening of echo strength that doesn't track with level or headspace conditions — a fingerprint the firmware can learn to recognize and distinguish from a foam or vapor issue.

What actually helps: installation choices and firmware technique together

No single trick solves this; it's a combination of mechanical and algorithmic choices.

On the installation side, sensor placement matters more than people budget for. Mounting away from fill points reduces direct foam exposure at the sensor face. Where geometry allows, a stilling well or baffle tube around the acoustic path dampens surface turbulence and reduces foam intrusion into the measurement zone, at the cost of some installation complexity. A temperature sensor co-located in the headspace — not just on the tank exterior — gives the firmware the input it needs for real speed-of-sound compensation rather than a fixed assumption.

Another detail that's easy to overlook but worth checking for on every installation is whether the tank has a vent hole, and where it's located. A vent that lets the headspace breathe helps carry off evaporating vapor rather than letting it accumulate and build the acoustic and condensation problems described above, and it reduces the moisture buildup that ends up condensing on the transducer face. When a vent exists, its location relative to the sensor is worth factoring into mounting position; when one doesn't exist or can't be added, that's useful context for how aggressively the firmware should expect to compensate.

On the firmware side, the highest-leverage technique is treating every reading as a candidate rather than a fact: take multiple pulses per reporting interval, score each by echo quality, discard or down-weight the poor ones, and apply temperature compensation before converting time-of-flight to level. Trend-aware filtering — comparing a new reading against a short rolling history — catches the foam-layer creep and the implausible single-sample jump without needing to know anything about the specific chemical involved. And when confidence is genuinely low across multiple pulses, the honest answer is to report degraded confidence rather than a falsely precise number. For unattended, multi-year deployments, a system that occasionally says "I'm not sure" is more valuable, and safer, than one that always gives an answer.

It also matters when the firmware chooses to take that reading. Once a fill, draw-down, or other significant level change is detected, the surface doesn't settle instantly — foam needs time to collapse, and the liquid itself needs time to stop moving. Sampling immediately after a detected change event tends to catch exactly the noisiest, least representative moment for a reading. Building in a deliberate delay, or a short series of repeated readings, after a detected change gives the foam a chance to settle and the surface a chance to still before the firmware commits to a value. For underground tanks specifically, there's a second reason to wait: incoming liquid is often at a different temperature than what's already in the tank, and that thermal mixing takes time to equalize. Letting liquid temperature stabilize before relying on a post-fill reading avoids compounding a settling-surface problem with a still-shifting speed-of-sound problem at the same time.


Acknowledgments: the echo-separation work described above owes a lot to countless hours of testing, analysis, and design alongside Pablo Gomez Martino and Pablo Montalti years ago. Identifying vent conditions in the field, and working out corrections customers could actually live with, owes a great deal to the invaluable effort Jim Jones put into that side of the work.

Email LinkedIn X
Terms of Service - Privacy - Credits
© 2012 - 2026 The Shadow on the Moon, Inc. All Rights Reserved.

We use Google Analytics to understand which pages are useful. It sets cookies only if you agree -- decline and we still count the visit, anonymously and without cookies. See our Privacy Policy.