Water Tank Project - UPDATE

First of all, I would like to wish everyone a Great 2024.

Secondly, I would like to thank everyone who helped me with the project I am about to discuss/update. In Aug. '23, I was finally able to install this ultrasonic water level sensor project into one of our domestic water supply tanks.

Fast forwarding - it has been a dismal failure. This was a two-years-in-the-making project, but unfortunately, once installed, nothing seemed work as it did during months of testing in my shop.

Functionality
In brief, the project sketch was designed to:

  1. send water level 'daily texts' @ 0800, 1400 and 2100 hours every day;
  2. send 'low level' texts if the tank water level fell below 8 feet;
  3. send tank level data to Adafruit's IO;
  4. if main/USB power is lost the LiPo powers the board until the main power returns

The well house enclosure has a LCD which shows: water level (ft), temperature ºF, humidity % and LiPo voltage level.

Initially, everything worked as it should. Then gradually, the 'daily texts' were sent sporadically if at all. This was followed by the 'low level' texts being sent erroneously non-stop at all hours of the day and night. I finally had to hide the text file to stop the texts. The Adafruit IO never faltered. These are all ultrasonic sensor issues.

Causes
I can make a lot of guesses, but that is all they would be - guesses. Two 'conditions' that exist in the tank that were absent from my shop environment were humidity and temperature differences. Neither of these are extreme and each are within the operating range of all sensors. This is not the problem.

Board, Sensors and Cable

  • Adafruit HUZZAH32-ESP32 Feather
  • Temperature/Humidity - Am2302. Now discontinued but still functional.
  • Ultrasonic Sensor - DYP-A01-V2.0 A01NYUB Waterproof Ultrasonic Sensor Wiki - DFRobot
  • The 40 ft 18-4 AWG cable was used for testing and final installation. This was done to avoid the obvious.

One odd thing about the ultrasonic sensor is that it continues to report a daily water level of either 14.4 ft or 17.2 ft without fail regardless of what the actual water level is. The water level changes slowly throughout the day and night so why it would just report these values is beyond me. The horn has been wiped down several times to remove condensation, but condensation was minimal and should not cause these misreadings in the first place.

Bottom Line
While I learned a LOT during the development of this project, the knowledge I gained cannot be taken from me. That cannot ever be construed as a a waste of time. However, hindsight indicates that for this 18 ft-height water tank project, using an ultrasonic sensor may not have been the best choice.

I will be switching to a transducer pressure sensor. They should arrive in a day or so and look forward to testing these sensors for this water tank.

Thanks.

1 Like

For debugging purposes, you might also want to make the LCD show the time. Maybe change the first line to something like: 08:00 Wtr 14.61'

While that is a good idea the problem being that the LCD is miles away from my location. In addition, I do not have access to the well house keys.

I have lost confidence in ultrasonic sensors of any type for non-hobbyist projects.

Thanks.

The problem may be in the humidity in the air. Sound travels at different speeds depending on humidity as well as air pressure. MY well sucks and expels a LOT of air when the atmospheric pressure changes. Dry air may go in, but is very humid when it comes out later on.

Good point about the condensation which is why I added the AM2302 sensor in the first place. However, after installation, everything was working so well I disregarded correcting for changes in humidity.

Here are a few shots of how the sensors are attached to the tank cover hatch.

The above is a shot of the sensors attached to the hatch wall. The AM2302 is beneath and to the right of the ultrasonic sensor. Rare earth magnets hold everything in place. These magnets do not disrupt the ultrasonic sensor readings. I tested this very thoroughly,

The above is the interior of the water tank with well inflow to the right. Initially I thought that the surface disruption was the cause of the water level misreadings. I no longer believe that because nothing changes when the well is not pumping water into the tank.

Thanks for your input.

Have you considered a mechanical float system that could be read with an absolute encoder?

Not my first choice. The electronics of open to air sensors eventually corrode.
I have successfully used the si7021 with white Teflon cover in my bathroom.
Covered the whole board in epoxy glue after soldering the wires to it, leaving only the white Teflon cover exposed. Code enables it's internal heater (few mW) between measurements if the RH gets over 80%. Working without issues for several years now.

I assume you also need to heat the tank sensor if it's temp gets below the temp of the water (condensation). If the sensor is faulty, then get it replaced first. Maybe it's just a one-off bad one.

Can't find your original project. Please post a link to it.

Which one. Most of them are analogue and 5volt-only, and interfacing them with the crappy 3.3volt-logic A/D of an ESP32 won't work well.
Leo..

I have used a much cheaper sn-sr04t waterproof ultrasonic sensor outisde for two year sto read river water height without problems
if you take the DYP-A01-V2.0 sensor back to your shop are it readings still faulty ?

transmitting the sensors UART signals over 40ft of cable could be a problem
could you have a local microcontroller to read the sensor and transmit the data over RS232 or RS485?
or even connect to sensor UART output to a RS485 for data transmission

What changes the speed of sound the most is temperature. The rest are second order effects. While it is below freezing out, see the difference from warm indoors. Ping should include temperature as well as humidity, speed of sound formulae and tables are public info.

What temperatures does the tank get?

From the description of it worked and then didn't, I suspect the software falls down. If a log on SD could be added, loads of clues as to why and when could be collected.

Thanks for your post.

The tank does have mechanical floats installed. They control the well pump. The orange-red device in the above image is one of them. The other - as I understand it - is resting on the tank bottom. The difference between the two floats switches the well pump ON & OFF.

My project was built on a single premise: to report - via texts - the tank water level 24/7. Nothing more, nothing less. They use a pressure gauge at the tank bottom to determine water level which requires physical presence to both tanks. I was trying to eliminate all of that work.

Thanks!

That is the way to go. My Omega PX309 certified and calibrated, industrial grade pressure sensor has been reliably reporting water tank level for over a decade, and the sensor is 300 meters distant, 50 meters below the tank, in the outlet line. They are expensive, but the quality and reliability makes them well worth the price.

Pricey to be sure.

I have not noted this in this thread but our water association is a non-profit which means they have no $$$. I could go on but there would be no point.

I just reached out to help when I learned the state of NM forced them to either build a fence around each tank or install wifi to protect the tanks. How either secures the water supply is beyond me but as we all know GOVT is much smarter that all of us poor deplorables combined. Obviously, the wifi enabled the text sending for my project.

Back on topic ...

My pressure sensor is this model:

DFRobot has a similar unit which was 4x more expensive without any added benefit. So I will begin testing with the one I chose and see how well it works. The tank height is 18 feet.

Thanks for your post.

Unless you are on their board of directors, don't believe there is no money for something. You just need to make the need known to the board.

Thank you for your post.

Removing the ultrasonic sensor would not be impossible but it would take some work as it is 'hardwired' into the tank structure. And, quite honestly, I do not think it is faulty at all. I will be happy to eat my words, but that is what I think. I am going to take a look at that tomorrow if I can gain access to the well house.

The cable in use has been the same cable since day one. That was done on purpose to a cable issue. This cable worked perfectly in my shop and I expected it to do the same after installation. I believe it has.

The HUZZAH32-ESP32 can be replaced at will. This was a design feature.

Thanks again for your comments and suggestions.

Your comment made me smile.

I could make a movie of all that I have learned about this board. To say that the board is dysfunctional would be an understatement. However, board membership is entirely voluntary. The present cast of characters are really quite innocent. It is the past board that either out of sheer ignorance or genuine stupidity (both?) had absolutely no idea how to run this water association. The current board is paying the price.

I will leave it at that and move on.

Thanks!

I should have added that at one time I was tracking temp and humidity values as seen next.

I can jump start that again.

Data

It may prove helpful.

Here is a shot of the resistance found in a similar - but longer - cable that I used for this project. This cable is 55 feet in length.

The cable in current use is only 40 feet in length.

0.4 Ω is acceptable.

Resistance is irrelevant when sending digital signals over long distance.
Capacitance or characteristic impedance and termination are.
Leo..

1 Like

Hello to all!

I am using the following ultrasonic sensor:

My MCU: Adafruit HUZZAH32 ESP32

In a test sketch I have this sensor working very well. No problems getting this sensor to work in any way.

  #include <DHT.h>
  #include <DHT_U.h>
  #include <Adafruit_SSD1306.h>
  #include <LiquidCrystal_I2C.h>  // NEW 20 JAN 2024 ......

// ===  LCD SETUP ===========
  int lcdColumns = 16; 
  int lcdRows = 2;     
  LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows); 


//======  ULTRASONIC SETUP  ==========================================
  int16_t distance;  
  bool newData = false; 
  uint8_t buffer[4];  
  uint8_t idx = 0;  

  #define mySerial Serial1

void setup() {
  Serial.begin(115200);
  mySerial.begin(9600);
  lcd.init();       
  lcd.backlight();  
  lcd.clear();     
}

void loop() { 
  if (Serial1.available()) {  
    uint8_t c = Serial1.read(); 

    if (idx == 0 && c == 0xFF) {
      buffer[idx++] = c;
    }
    else if ((idx == 1) || (idx == 2)) {
      buffer[idx++] = c;
    }
    else if (idx == 3) {
      uint8_t sum = 0;
      sum = buffer[0] + buffer[1] + buffer[2];
      if (sum == c) {
        distance = ((uint16_t)buffer[1] << 8) | buffer[2];
        newData = true;
      }
      idx = 0;
    }
  }
  if (newData) {
      Serial.print("\nDistance (mm): ");
      Serial.print(distance);
      Serial.println(" mm");
      float feet = distance / 304.8;  // convert mm to ft
      Serial.print("Distance (ft) = ");
      Serial.print(feet);
      Serial.println("  ft");
      lcd.setCursor(0, 0);
      lcd.print("Wtr Lvl ");
      lcd.print(feet);
      lcd.print(" ft");
      newData = false;
    }
}

My question is this: Does anyone know of a way to extract time duration from this sensor?

I have researched the newPing.h library but from all that I have read that library does not work with this particular sensor. I chose this sensor because of its measuring range (with horn) of 750cm.

I would like to get this info because I have another sketch which utilizes this same sensor in a large domestic water tank whose distance accuracy (I believe) could be much improved by implementing temperature and humidity factors such as the follow code snippet would provide:

 // Calculate the Speed of Sound in M/S
    soundsp = 331.4 + (0.606 * temp) + (0.0124 * hum);
    soundcm = soundsp / 10000;       // Convert to cm/ms
    duration = sonar.ping_median(iterations);
  
    // Calculate the distance
    distance = (duration / 2) * soundcm;

Without the ability to extract distance timing this would not be possible.

Thanks in advance to any guidance provided.