How to implement liquid-level measurement using capacitive sensing technology


Whether monitoring water levels in coffee makers or implementing smart refrigerators that can warn when that milk bottle is nearly empty, liquid-level measurement enhances performance and differentiates products from the competition.


  • Capacitive-sensing technology provides a reliable, robust solution for liquid-level measurement while being independent of environmental factors.
  • Mutual-capacitance sensors are independent of parasitic capacitance.
  • Accurate results depend on proper calibration, sensor linearity and nullifying the effect of factors that impact performance, including conductive interference and environmental variation.


When one speaks of capacitive sensing, the first thought that comes to mind is the use of a capacitive-sensing button on different appliances for user interfaces. But is that the only application of capacitive-sensing technology? Not at all. The technology can be used in any application for which input to the system can cause changes in capacitance. There are numerous applications in which capacitive sensing can replace traditional methods, including liquid-level measurement, humidity sensing, metallic object detection, etc. it is both more reliable and more robust while remaining insensitive to changes in environmental conditions.


Liquid-level measurement is an important feature in home appliances such as in a coffee maker to detect the level of water or milk, or in a washing machine to measure the amount of detergent. Liquid level measurement can be of two types:


  • Point-level measurement: In this type of measurement, sensors placed at discrete levels on the tank can be used for tank-full detection, tank-empty detection and discrete liquid levels with lower resolution.
  • Continuous-level measurement: In this approach, as the name implies, the sensor detects liquid level at fine increments.

Each of these types can be implemented in different ways. This article concentrates on continuous-level measurement and some important considerations to ensure accurate performance.


Various methods of liquid-level measurement have been developed, including:


  1. Magnetic float: In this approach, a magnet is mounted on a float that moves as the level of liquid changes in the tank. The float actuates a reed switch to control the system. These solutions provide high repeatability, but due to moving parts, they have shorter life span and reliability.
  2. Ultrasonic sensing: In this method, delay between the ultrasonic signal that is transmitted to the liquid surface and the echoed signal translates to the level of liquid in a given reservoir. The maximum level of liquid this type of system can detect depends on the construction of the transmitter. The measurement can be affected by variations in environmental factors such as temperature, pressure and humidity.
  3. Conductive measurement: These types of devices are based on measuring conductivity with two conductive electrodes. This is a more reliable method than the previous two but it cannot be used for flammable liquids.

Clearly, manufacturers need a more robust, reliable, accurate liquid-level measurement technology that can support a wider range of applications. Capacitive sensing can fill that need. It has no moving parts to fail, works safely with flammable materials and can be rendered insensitive to environmental variations.


The basics of capacitive sensing

Capacitive sensing is one of the most reliable methods available for monitoring liquid levels. It is based on the fundamental fact that liquid, being conductive in nature, causes a change in the capacitance of capacitive sensors.


There are two types of capacitive sensing: self capacitance and mutual capacitance. Self capacitance uses a single pin as the sensor and measures the capacitance between that pin and ground, which is the parasitic capacitance. In this method, the liquid changes the parasitic capacitance of the sensor to a degree that depends upon the volume of liquid present.


Mutual capacitance uses a pair of pins, one as the transmitter (TX) and the other as the receiver (RX). It measures the capacitance between the two, which is the mutual capacitance. In this method, the liquid causes change in the mutual capacitance that varies depending on level. One of the major reasons why the mutual-capacitance method is preferred for liquid-level measurement is because it is independent of sensor parasitic capacitance.


Mutual-capacitance sensing in action

Let’s look at an application of mutual capacitance liquid-level measurement in a coffee maker. The sensor monitors the level of water in the reservoir.


V2N2 liquid picture 1


Figure 1: Mutual capacitance sensor PCB mounted on the side of a coffee maker (yellow rectangle) measures the level of liquid in the water reservoir.


The sensor PCB, which consists of mutual-capacitive sensors, is mounted on the coffee maker overlay; the overlay, in turn, is separated from water reservoir by an air gap (see figure 2). The TX and the RX of the sensors are on the board and the liquid changes the mutual capacitance between them.  

V2N2 liquid picture 2  

Figure 2: Front view of liquid-level measurement system stack up shows the position of sensor relative to the water reservoir.


The sensors board primarily consists of one TX and an array of n receivers (see figure 3). The value of n depends on the height of the tank and the desired resolution. The greater the number of receivers, the higher the measurement resolution.


V2N2 liquid picture 3


Figure 3: Sensor TX and RX pattern in mutual-capacitance sensor which uses multiple receivers to provide continuous liquid-level monitoring.


The controller on the sensor board measures the mutual capacitance. The readings can be processed to measure the liquid level L using the following equation:


                               V2N2 liquid picture 4                           [1]



currentsignal = sum of signals on all RX sensors corresponding to liquid level

emptysignal = sum of signals on all RX sensors when tank is empty

fullsignal = sum of signals on all RX sensors when tank is full

SENSORHEIGHT = height of the tank (sum of height of all RX sensors)


The measurement in the firmware can be done based on the above equation, with additional techniques applied as necessary to meet system-level requirements such as accuracy, linearity, response time and power consumption.


Ensuring accuracy

Now, let us discuss some of the important considerations for implementing liquid-level sensing. They include calibration, linearity, temperature compensation and conductive-object interference.



Calibration is necessary for accurate results. The fullsignal and emptysignal quantities used in Equation 1 must be determined at the factory and stored in EEPROM to be later used for measurements.



Nonlinearities introduce another error source. Equation 1 assumes that the RX sensor delivers a linear response as it moves from the inactive state to active state (i.e., with absence and presence of liquid on the sensor, respectively). The real behavior is different from the ideal behavior, however. Actual data shows that the RX sensor signal settles to the maximum value much later when liquid moves well above the sensor (see figure 4). This results in non-linearity of liquid level measured.


V2N2 liquid picture 5


Figure 4: Signal response of an RX sensor from a Cypress PSoC® 4-based application shows the nonlinear response of a real sensor (red) compared to an ideal sensor (green).


In order to overcome the non-linearity issue, the fullsignal value must be calculated dynamically by considering the current signal of sensors that are active and stored full signal values for sensors that are inactive. 


Temperature Compensation

Temperature affects capacitance. As temperature varies, the capacitance changes, which can potentially lead to errors in liquid-level measurement. It is important to compensate for temperature variations in order to have accurate results.


One of the ways to compensate for temperature variation is by introducing a virtual sensor. The virtual sensor has same characteristic capacitance variation with temperature as that of a real, physical sensor so the effect of temperature on both devices will be equivalent. During runtime, the variation in the signal of the virtual sensor is used to remove the variation in the signal of the real, physical sensors due to temperature.


Conductive object interference

The sensors used for liquid detection and the virtual sensor should be placed away from other conductive objects like human bodies. If a conductive object is close to the sensor, there is every chance of reporting wrong results. The only way to solve this problem is to have proper isolation between the measurement section and other conductive objects such that any conductive object will not add capacitance to the sensor that is used for measuring liquid level.


Whether performing an operation fundamental to the process, such as monitoring water levels in a coffee maker, or delivering a value-added service like warning users when their orange juice carton is nearly empty, liquid-level measurement can vastly improve the product experience for consumers. Capacitive sensing provides a robust, reliable solution.


As we have shown here, the mechanism is straightforward but achieving accurate results can be challenging. Meanwhile, engineers trying to design a washer or coffee maker want to devote their efforts to the performance of the appliance, not to learning the nuances of liquid-level sensors. Fortunately, sensor functionality is built into some microcontrollers, like the PSoC® 4 family of programmable system-on-chip controllers from Cypress. By leveraging this technology, developers can easily introduce capacitive sensing capabilities while focusing their attention on mission-critical functionality like keeping food fresh and cold or brewing an ideal cup of coffee.




Also in this issue:

AS-MCUs bring TFT HMIs to cost-sensitive home appliances

RCCA turns failures into future success

Answers to your data-retention specs and testing questions

Accelerate product development with Bluetooth® low energy modules

PSoC controllers speed design of smart home appliances

Prequalified APIs and software keep white goods safe

Bus Analyzer uncovers root cause of failure in flash-enabled systems

Get More from Core & Code Subscribe

Leave a Reply

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

Other stories in this issue


Bus Analyzer uncovers root cause of failure in flash-enabled systems

Analysis of granular operational data helps developers more easily fix the flaws in their systems