Water Monitoring

Tank Level Sensor

We have three water tanks in Molly. In each tank is an ultrasonic level sensor, and this sensor measures to the water level. The sensors are connected to the house control panel where the levels can be displayed. This is a simple system that works well, and is standard in all Earthcruisers.

Molly’s control panel display with water level in the main Fresh Water Tank.

However, for long term record keeping of water usage, we also connected the above mentioned water level sensors to our monitoring system. Sure, we could use a pencil and note-book to record water usage, but using a monitoring system is just more fun.

The Sensors

The water tanks are fitted with a BEP Marine Ultrasonic Tank Sender, model number TS1. Below are the specifications for this device:

Operating Depth and Accuracy

0 to 2,000 mm with 2 mm accuracy

Output Signal

0 to 5 volts (dc)

Operating Voltage

Operating voltage: 10-32 Volts dc.

Temperature Range

4 to 65 ºC

While the above specifications seem pretty reasonable, but there is one small problem; just not very accurate, especially when the tank is full. There are four main problems with the sensors that cause inaccurate readings.

  • The main problem s because of how the sensors are fitted in the tanks. As our water tanks are closed, so the only place to mount the sensor is inside the tank. So, when a tank is full, or nearly full, then the sensor is fully submerged. The sensor is unable to tell the difference between a completely full and a nearly full tank. When the sensors on the main fresh water tank indicates a full tank, and we can still add another 25% or 40L. Not much we can do to fix this problem. At low water levels the sensors work much better.
  • At the low water levels there is a similar problem, the sensors also aren’t able to determine the difference between a completely empty tank and one that is nearly empty. On the main fresh water tank, the sensor will show empty while there could be upto 10% or 16L of water remaining.
  • Even between the full and empty levels, the signal can be up-to to 15 liters off the correct reading.
  • Other more minor errors are introduced if the truck is not parked on a level surface.

The sensors are certainly accurate enough to make sure we aren’t going to run out of water, or overflow the gray water tank. And this is the main reason why the sensors are there. Also, it is very easy to read the levels on all three tanks from the control panel.

But, there are things we can do to improve the accuracy by monitoring the fresh water pump.

Fresh Water Pump

The fresh water tanks supply the house via a Whale Watermaster FW0814 pump, which automatically starts when the outlet pressure drops and stops pumping when the pressure returns. Turning on a tap causes the water pressure to be released and turning off the tap allows it to build again. The pump is rated at 8 liters per minute (open flow) and uses a 12 volt power source.

In our setup, the rate at which water flows through the pump is very consistent, measured at 1 liter of water for every 14.5 seconds that the pump is running1. This means the run-time of the pump is a very reasonable measure of water consumption. The water level sensor indicates how much water is available, but the running time of the pump is a much better indication of our fresh water consumption.

It is possible to pump or move water from one tank to another or even recirculate water back to the same tank. In both of these cases, the pump is running but the water is not being consumed. This would confuse the software calculation of water tank levels. But we have added a little extra software to compensate for these type operations and to maintain the accuracy of the water consumption.

Each tank will have the following display values on our dashboard or virtual control panel.

  • Amount of water in Liters, with the graphic showing the water level as an approximate % of total capacity.
  • If the heater is on or not. This is especially important in freezing conditions.
  • Is the water tank in service or not.
  • Is the level been determined from the ultrasonic sensors or from the derived pump running calculation.
node-red dashboard of water levels.
  • Fresh Water Tank 1 is in-service, indicated with a dark blue colour. Current capacity is 130L, which is around 80% of the total capacity of 165L.
  • Fresh Water Tank 2 is empty and not in service, indicated by a light blue colour and 0L.
  • The level in Fresh Water Tank 1 is being calculated by subtracting the consumption from pump running hours from the total capacity. This is indicated by the cogs icon in the tank label. The level is Fresh Water Tank 2 is being obtained from the ultrasonic senor as indicated by the radar icon.
  • The heater for the Gray Water Tank is on, indicated by an orange outer rim. When the heater is off, the outer rim is gray, as it is gray water.

Totals and trends will be available in Grafana.

Recirculation Valve

A recirculation valve is installed on the hot water line to the main sink, and is super useful as it can send any cold water in the hot water line back to the water tank. This allows the hot water line to be primed with hot water without wasting any water down the drain. The recirculation valve is controlled via a push button switch near the sink. The monitoring system is connected to this switch and ignores pump run time of recirculation operations.

Water Operations

If we drain water using the pump, then we indicate this to the monitoring system by not selected any tank as the in-service tank, and it will ignore these pumping operations when calculating water usage.

It is possible to move water from fresh water tank 1 to tank 2 using the fresh water pump, and vice-versa. The software is able to ignore this and not treat it as consumption. But the software is not able to correctly allocated the remaining water correctly in each tank. The water remaining total is still correct.

The good news, we have never pumped water from one tank to another. So, this is unlikely to be a significant issue.

Water Tank Calibration

Before getting into the details of the software, probably should mentioned that we undertook a semi scientific exercise to measure the tank volumes and calibrate the water level sensors. We always wanted to know exactly how much water each tank would hold.

This involved completely filling the water tanks, and then measuring the pump run time and the water level sensor reading with each 4 liters of water discharged. We confirmed that the main freshwater tank holds 165 liters, and that the water level sensor is only accurate between 10% and 75% full. The chart below shows this same information in a graphical form.

To empty the fresh water tank 1, the pump ran for 2425 seconds and we measured 167.25 liters of water.

The sensor reading indicated with the orange line does not follow the water level based on measurement. This chart is for the freshwater tank 1, but similar results can be seen on all three water level sensors.
Software

There is quite a bit of software to make this all happen and we will discuss each of these, including

  • A small python script to increment a timer whenever the pump is running and the recirculation value is not being used. With a new value is sent every second.
  • Javascript code in node-red to use the tank calibraiton data to adjust the raw sensor readings to slightly more accurate water levels.
  • calculate water remaining in the tanks.
Water Consumption using Pump Run Time

using the pump running time to measure Water Consumption has been way more reliable than we ever thought possible. Not sure why; but It just works and never seems to crash. Combined with Grafana, it is now super easy to see how much water we use. Just select a time period, and Grafana and influxDB do all the work to calculate water usage during the period. This could be the last hour, day or even month. Below is a simple panel we have configured in Grafana to show water usage.

Simple Grafana panel to show water usage over the selected time period.

The python script to make this all work runs on the Raspberry Pi computer and updates node-red when the pump has run for 1 second.

from time import sleep
from widgetlords.pi_spi import *

import requests

init()
inputs = Mod8DI()

runSeconds = 0
lastRunSeconds = 0
digitalValue = inputs.read()

url = 'http://192.168.0.76:1880/pumpSeconds'

while True:
    digitalValue = inputs.read()
    if (digitalValue & 0x02) and not (digitalValue & 0x20):
         runSeconds = runSeconds + 0.1
         if runSeconds > (lastRunSeconds + 1):
               lastRunSeconds = runSeconds
               pumpRunObj = {'pumpRun': runSeconds}
               try:
                  x = requests.post(url, data = pumpRunObj)
               except requests.exceptions.RequestException as e:
                  print ("Error Connecting:",e)
    sleep (0.1)

The python script is executed with

$ nohup python3 -u sendPumpHours.py &

To ensure the python script is running at start-up, the above line was added to rc.local with the following

$ sudo nano /etc/rc.local

The influxDB query to calculate water used is

"SELECT cumulative_sum("waterUsageTick") /14.5 FROM "house" WHERE ("source" = 'tankFresh1' OR "source" = 'tankFresh2') AND time >= now() - 30d"
Water Level – Adjusted

The ultrasonic sensors connected to the control panel give a pretty good approximation of the water level, and is certainly where we go if we need to know quickly the tank levels. The same sensor information is available in the monitoring system, but with code we can improve the water level calculation. We used tank calibration data to adjust the raw sensor readings. This was done with a simple node-red javascript function:

Water Remaining Calculation

Even with this adjusted and improved water level calculation, the remaining water still has significant issues as mentioned earlier. So we also added a calculation based on pump hour hours. The remaining water is calculated as, the maximum tank volume less any water used from that tank since it was last filled. With pump run hours in influxDB, this is easier to calculate than initially expected

Unfortunately the calculation is not fully automatic, and there are a few tricks to do to make this work. When we fill a tank, we select that tank on the monitoring system and press a button on the monitoring system indicate that the tank has been filled. This also means we have to completely fill the tank, but we always do this anyway. And when we are using water, we have to manually select which tank we are getting the water from. This second condition is not that bad, as we almost exclusively use tank 1 for water consumption. Only when we go into the desert or for extnended trips without water do we fill the second fresh water tank. So, practically this means, every 10 to 20 days when we fill tank 1, we have to press a button on the node-red dashboard.

There are a few steps to calculate remaining water. First we query influxDB to get the timestamp of when the tank was last filled

SELECT last("fillPumpRunHours") FROM "house" WHERE ("source" = 'tankFresh1')

Then we use that timestamp in another query to influxDB to sum up the usage.

SELECT sum("waterUsageTick") / 14.5 FROM "house" WHERE("source" = 'tankFresh2') AND time >= dateFill.toISOString()

This returns a value equal to the water consumed which is subtracted from the maximum capacity of the tank.

msg.payload = Math.round(165 - parseFloat(msg.payload[0].sum));

Conclusion

The ultrasonic water level sensors provide a good and very quick indication of the water level, although it is good to know that the sensor readings are only valid in a certain range, approximately 10% to 85% of the tank capacity. Using pump run hours is a much more accurate way to measure both water consumption and the amount of water remaining in the tanks.

  1. It actually takes longer than 14.5 seconds to pump 1 liter of water, as the pump cycles on and off while the tap is fully open. The pump is rated to pump 8 liters per minute, but the actual measured flow-rate out of any of the taps is lower, and depends on the resistance (drag and throttles) in the system. For example, water from the drinking filter (with the tap wide open) flows at a rate of 1 liter every 43 seconds, and slower when the tap is only partially open. Water from the pump is absorbed by the accumulator and released when the pump is off, providing a steady flow at the tap. ↩︎