Author Topic: Water tank monitor using ultrasonic range finder and STM8 MCU  (Read 1240 times)

0 Members and 1 Guest are viewing this topic.

Offline rhodgesTopic starter

  • Frequent Contributor
  • **
  • Posts: 331
  • Country: us
  • Available for embedded projects.
    • My public libraries, code samples, and projects for STM8.
Water tank monitor using ultrasonic range finder and STM8 MCU
« on: December 22, 2018, 05:54:16 pm »
BACK STORY (skip if not interested)

About one year ago, I started having water problems. The flow was really low. We have a well, so I was concerned. What is going on? Is our well running out of water? Pump problem?

So I made a device (STM8S103) to monitor and record the pump on/off cycles. Okay, the pump cycles for about two minutes at a time, several times a day. That's seems quite normal. Good. I finally found out that our water filters were PLUGGED UP. We were getting a huge amount of sediment. I ended up replacing the filters about once a week. For months, this was a "stable" situation. Not good, but stable. After about half a year, the sediment problem went away. Good.

Then this summer, I noticed that the pump was cycling on for a very short time (like 10 to 20 seconds) and very often. The pressure tank probably failed. I bought a new tank and waited. The tank is in a concrete chamber in the ground. It was going to be a real pain in the ass to replace the old one and connect the new one. For some time, the water pump would not be usable. One day? Several days? Don't know.

To keep the water flowing, I set up a 1000 liter (265 gallon) International Bulk Container ("tote") as a water tank by the house, with pumps and plumbing, I made that a secondary water source for the house. We tested it for a day, and it worked fine. Then I made it the primary water source so I could work on the pressure tank. It was a pain in the ass. Two days.

It freezes hard here, so an outdoor tank is not a year-round option. It would be nice to have an emergency or secondary tank in the garage. But to refill it would mean going about 200 feet down the driveway and spending a half hour or more watching the water level. It would be nice to refill the tank using valves in the house, and using a monitor to report the current water level.

END BACKSTORY

This project is a water level monitor for a water tank. Mine is 1000 liters (264 gallons) and will provide water to the house for two days of normal use, or longer if we try to conserve. It can easily be modified for other tanks. At the end of the code is a calibration table. Just push the button for ping microseconds and record the numbers every 100 liters. After compiling in the calibration values, the display can show water level in liters, gallons, or percentage of full.

Here is a link to the source code and libraries:
http://www.hodges.org/rh/stm8/tank_mon/tank_mon.tgz.

Here is a link to my project page:
http://www.hodges.org/rh/stm8/tank_mon/index.html

The MPU (stm8s103), display & keypad (tm1638), and ultrasonic range finder (HC-SR04) are about $4 on ebay.
Currently developing STM8 and STM32. Past includes 6809, Z80, 8086, PIC, MIPS, PNX1302, and some 8748 and 6805. Check out my public code on github. https://github.com/unfrozen
 

Offline rhodgesTopic starter

  • Frequent Contributor
  • **
  • Posts: 331
  • Country: us
  • Available for embedded projects.
    • My public libraries, code samples, and projects for STM8.
Re: Water tank monitor using ultrasonic range finder and STM8 MCU
« Reply #1 on: December 22, 2018, 05:59:01 pm »
Here is the 1000 liter water tank in a corner of the garage. I decided to mount the ultrasonic device on top of the tank. I drilled two 5/8 inch holes one inch apart, and then adjusted the holes to hold the sensor firmly. Click on an image for a better view. Very large images are on my personal pages.
« Last Edit: December 22, 2018, 06:04:18 pm by rhodges »
Currently developing STM8 and STM32. Past includes 6809, Z80, 8086, PIC, MIPS, PNX1302, and some 8748 and 6805. Check out my public code on github. https://github.com/unfrozen
 

Offline rhodgesTopic starter

  • Frequent Contributor
  • **
  • Posts: 331
  • Country: us
  • Available for embedded projects.
    • My public libraries, code samples, and projects for STM8.
Re: Water tank monitor using ultrasonic range finder and STM8 MCU
« Reply #2 on: December 22, 2018, 06:07:21 pm »
Here is my original calibration setup. I started with an LCD, but when I switched to the tm1638 LED display and keypad, I no longer need the LCD. The second picture shows the MPU, display/keypad, and ultrasonic device connected together. The power supply is most any cell phone charger (micro-USB).
Currently developing STM8 and STM32. Past includes 6809, Z80, 8086, PIC, MIPS, PNX1302, and some 8748 and 6805. Check out my public code on github. https://github.com/unfrozen
 

Offline soldar

  • Super Contributor
  • ***
  • Posts: 3540
  • Country: es
Re: Water tank monitor using ultrasonic range finder and STM8 MCU
« Reply #3 on: December 22, 2018, 08:06:13 pm »
I have a tank just like that in my garage. The pump is the kind that does not need pressure vessel as it detects flow and starts whenever water is running. The system works very well.  I prefer this type of pump to the kind with pressure vessel that cycles on and off because I do not like the pressure cycling that goes with it.

Don't let me discourage you from overengineering a solution but I think it can be much simpler. What's wrong with a float valve which shuts off the water input once the water reaches a certain level?  Or you can find on ebay really cheap and reliable float switches. Even ultrasonic switches.

I would favor a really simple solution like a basic valve to shut off the water supply when the tank is full and backed up with an alarm in case it would overflow.
All my posts are made with 100% recycled electrons and bare traces of grey matter.
 

Offline beanflying

  • Super Contributor
  • ***
  • Posts: 7375
  • Country: au
  • Toys so very many Toys.
Re: Water tank monitor using ultrasonic range finder and STM8 MCU
« Reply #4 on: December 22, 2018, 08:21:42 pm »
Interesting project. Way back in the day I used to play with pumps and controls. A local here has been building a system with 4G boards in his for remote farm tanks.

For Tank filling these were always a better option than a single acting ball valve btw and cut down a lot of the pump cycling.

Coffee, Food, R/C and electronics nerd in no particular order. Also CNC wannabe, 3D printer and Laser Cutter Junkie and just don't mention my TEA addiction....
 

Offline rhodgesTopic starter

  • Frequent Contributor
  • **
  • Posts: 331
  • Country: us
  • Available for embedded projects.
    • My public libraries, code samples, and projects for STM8.
Re: Water tank monitor using ultrasonic range finder and STM8 MCU
« Reply #5 on: December 22, 2018, 08:52:10 pm »
What's wrong with a float valve which shuts off the water input once the water reaches a certain level?  Or you can find on ebay really cheap and reliable float switches. Even ultrasonic switches.
There are four answers.

First, if I need to use it as emergency water, I want to know the water level. How much did we use today? How much is left?

Second, our water has a lot of iron in it. Some is sediment. Some is "clear" iron that is dissolved until it is exposed to oxygen. I would like to find out if I can remove the "clear" iron in the tank before the water goes to the house. Any "red" iron will be caught by the sediment  filters. To do this, we might use the water from the tank during the day, and refill it late at night. The iron could settle during the night, when we are not using the water much.

Third, I want the refilling to be supervised. There is nobody near the garage 99% of the time. If a float valve failed, I might not notice for many, many hours. An alarm for overflow would help. But it would not be very safe to go out at night in the snow and ice, if something failed at midnight.

When refilling, I want to see the progress. If it takes an hour, I would want to take a look every ten minutes or so. One or two float switches would not give me this much information. And what if one of them failed? I do not like that uncertainty.

And now we can look at cost. What would the switches, valves, and alarms cost at the store? Are they what I really want? Can I configure them to my needs? I will have to do the wiring either way, so the wiring is outside this discussion.

If you look at my "shopping list", you will see these parts are very cheap.

Thanks for the feedback!
Currently developing STM8 and STM32. Past includes 6809, Z80, 8086, PIC, MIPS, PNX1302, and some 8748 and 6805. Check out my public code on github. https://github.com/unfrozen
 

Offline soldar

  • Super Contributor
  • ***
  • Posts: 3540
  • Country: es
Re: Water tank monitor using ultrasonic range finder and STM8 MCU
« Reply #6 on: December 27, 2018, 01:02:52 pm »
For remote measurement and monitoring of analog magnitudes I always liked and used the 4 - 20mA current loop standard.  Simple, robust and quite standard so there are plenty of sensors, adapters, etc.
All my posts are made with 100% recycled electrons and bare traces of grey matter.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf