Project: Water Tank Gauge using a load cell
Initial post 18Jan16.
This version of a tank gauge uses a load cell to measure the quantity of water in a tank and report that and other information back to a display wirelessly using a local wifi network. Access to the information can be via a web browser or a dedicated client (20 X 4 LCD display in this case). The system is proving reliable and has a a better than 1% accuracy.
Tank gauges are problematic in that the sensor(s) must exist in an environment which has high and low temperatures and almost always with high humidity. Ultrasonic methods have been assessed but are expensive if a sensor of IP64 or 65 or greater rating is considered. Tank size, construction, shape, material properties will affect the nature of the ultrasonic reflections and add another layer of complexity. A series of float switches was also considered and whilst probably the most reliable, provide a discrete accuracy (ie 4 switches will provide ¼, ½, ¾, & full indication only).
For these reasons I decided to use a load cell to measure the water level. Load cells have reduced in price dramatically over the last few years with a 10kg cell around $10. The load cell approach should be robust enough for the environment, provides a continuous reading, has no moving parts and is easily interfaced with a small computing device such as an Arduino (or a nodeMCU wireless/ soc module). A potential issue is that of creep. Since the load cell will be under a constant load, the output of the strain gauges may decrease overtime and therefore producing an inaccuracy.
The principle of operation is to suspend a weight from the load cell into the tank. The weight is a cylindrical shape (i.e. a tube) of uniform density which extends from just above the water level low point to the water level high point at the top of the tank. Assume for the moment that the tube density is equal to that of water. When the tank is empty the tube will weigh several kilograms depending on the size and length of the tube. As the tank fills more and more of the tube will be submersed in the water and the weight of the tube will decrease accordingly. When the tank is full the weight will be zero (assuming the tube density equals that of water). The load cell will measure this weight and calculate the % full value for the tank.
Gauge main components:
The suspended weight is easily constructed using PVC pipe. The length needs to be just greater than the depth of the tank. The pipe is sealed at the bottom by gluing (PVC glue) on an end cap. The pipe is then completely filled with water and another end cap glued on the top. Nylon rope or galvanised wire is attached by using a circular hose clamp. For my application the tank is 2m deep. A 2m length of 75mm PVC pipe filled with water weighs approximately 9kg which is perfect for the 10kg load cell.
To aid assembly I suspended the weight inside another pipe (150mm diameter). This was achieved by assembling a top cap to which the load cell was bolted. A hole drilled in the top cap allowed the nylon rope through attaching the weight. Note also the holes drilled in the 150mm outer PVC pipe to allow the water in and out. Position of the holes is not important except that there should be some near the bottom of the pipe to allow water to enter and exit the outer pipe when the tank level is low. The outer pipe can rest on the bottom of the tank.
Load Cell – 10kg straight bar load cell (TAL220) :
This cell is a Wheatstone bridge configuration. Specifications can be found at TAL220 Datasheet at Sparkfun. The key parameters are: 1mV/V at full scale i.e. 10kg, Excitation voltage 5 – 10V (this design is 5V), IP65 rating
Load cell interface – Amplifier (HX711):
This amplifier is a relatively low gain amplifier which has a serial digital (I2C) output. Specifications can be found at HX711 Datasheet at Sparkfun.
This design uses Channel A and a gain of 128. The amplifier can be mounted with the Arduino/ nodeMCU a cable length away from the load cell.
Computer – NodeMCU:
I have changed this from an Arduino to a NodeMCU which incorporates a wifi interface. The nodeMCU located at the tank will act as a server into my local wifi network. A remote NodeMCU (client) will interrogate the server via wifi, obtain the tank data and display.
The HX711 library will be used to interface to the load cell.
The nodeMCU has more than enough memory storage for small applications such as this. It has sufficient memory to provide a small webpage on command back to the client. This means that any device with an internet browser can request the webpage and display the tank information. Alternatively a dedicated client shown opposite can request and display the tank information. The server in this system stores the tank information at midnight which enables the calculation
of water used each day. I also took the opportunity to connect a tipping bucket rain gauge to a spare pin and record the rainfall.
Wifi Router – each nodeMCU has a unique MAC address. This enables the router to allocate a fixed ip address to the server nodeMCU (located at the tank) when the server is connecting to the wifi network. Clients can then locate the server reliably without having to search for and determine the ip address first.
The TAL220 output is specified at 1mV/V at the rated output. The excitation voltage is 5V so the output will 0 – 5 mV for a loads of 0 – 10kg.
The HX711 with a gain of 128 provides a full-scale differential input voltage of ±20mV. This application uses the +ve part of the range (0 to 20 mV). With the load cell producing 0 to 5mV only ¼ of the +ve input range will be used. The HX711 has a 24 bit ADC so if the FS output is FFFFFF hex then ¼ of the output range will be 3FFFFF hex which should provide adequately accurate readings for a tank level indication. Note that the output of the HX711 is 2’s complement which doesn’t affect the representation of +ve binary numbers. So the output for a load range of 0 – 10 kg will be 000000H to 3FFFFFH.
The code to calculate the % full is quite simple. The empty value is set with the load cell/ HX711 measuring the raw weight of the suspended tube (ie not submersed in water). The full value is set with load cell/ HX711 measuring the weight of the suspended tube completely submersed in water. The % full value is simply calculated once these 2 constants are determined.
% Full = (Ve – V)/(Ve – Vf) * 100
where Ve is empty value, V is measured value, Vf is full value
Update – 8/7/17: I have trialed the load cell sensor and although a little creep is evident it is less than 1%. NodeMCU software (server & client) is complete and tank installation is underway.
Update – 16/7/17: Installation complete and connection to the wifi was straight forward. The server has been running for several days without issue.
Update – 4/8/17: Wifi client operating. The system is stable and can be access by any computer connected to the wifi network or the dedicated client. Accuracy is better than 1% and creep is not evident.