Liquid level sensing can be done in several different ways and we have tried several ways too. Sometimes what is required is accurate liquid level measurement without putting anything inside the liquid itself. This is especially preferred in applications such as in the food industry (for level sensing in tanks) and even fuel tank level sensing in automobiles.
We have earlier tried doing this is using a Laser ToF sensor, which is not the optimum way to do this.
What did we do:
We used capacitance to measure the liquid level by sticking two copper tapes on the OUTSIDE wall of the tank to measure the liquid level INSIDE. These two copper tapes measure the capacitance of one of the electrodes with respect to ground.
The TI FDC1004 is an all-in-one chip integrating capacitance measurement and an ADC in one package, calling it a "capacitance to digital converter". The specified applications including proximity detection, gesture recognition and liquid level sensing. ProtoCentral has a breakout board for this chip (ProtoCentral FDC1004 Capacitance Sensor Breakout Board).
The principle behind the use of capacitance for proximity sensing and liquid -level sensing is the same. When two parallel conducting plates are placed at a fixed distance from each other, electric fields are produced. At the edges of these plates, a "fringing" effect is produced. This fringing the key to capacitive sensing applications.
Capacitive sensing for different applications can be done in different ways. In this application, we are using the "parallel fingers" approach to sense the amount of fringe electric field lines being affected by the liquid level. This results in a small change on capacitance which is then measured and calibrated to the liquid level height.
How did we do it?
The actual application was a much larger setup, but for the sake of this article, we demonstrated the same on a small water bottle. We pasted two thin strips of adhesive copper tape (5mm wide) that we purchased from Sparkfun.
We then connected one of the electrodes to system GROUND and the other one to the CIN1 channel of the FDC1004 breakout board. It is best to solder these directly to the electrode itself to avoid any stray capacitance.
The ProtoCentral FDC1004 breakout board connects to an Arduino Uno using the I2C standard interface. This chip is connected to the SCL and SDA pins of the Arduino (for the Arduino Uno, this is A4 and A5). It can be connected to the I2C pins of any controller or platform, but the libraries provided are for Arduino only. If you're using a version of Arduino different from Arduino Uno, please check which pins correspond to the I2C/TWI SDA and SCL lines.
The data is sent through the Arduino's UART over USB to the computer. This data is continuously sent at a rate of 100 SPS and then averaged in the code, this helps in filtering out the noise.
In this example, we have just hard-coded the capacitance to level height conversion into the Arduino code itself, however, calibration can be used to set the same for various heights and liquid types.
We tested the setup using water pumped from another bottle by a peristaltic pump. All the required code is attached in the links below this article.
Any sensing or engineering mechanism always has it's own set of limitations. For this application, this is what we noticed:
- Capacitive sensing is prone to external stray capacitance and sometimes it saturates the ADC. This was however fixed using proper shielding.
- Calibration is key and accurate calibration is very important
- Environmental factors have a huge effect on the capacitance and they have to be shielded from and/or corrected appropriately.
You can let us know your experiences with capacitive sensing in the comments below.