Community
OpenEnergyMonitor

Community

Ultrasonic watertank Level meter


(Doug) #1

Hi,
I am using an Arduino board with in-built ESP8266 for my wifi connected EmonTx shield
https://robotdyn.com/uno-wifi-r3-atmega328p-esp8266-32mb-flash-usb-ttl-ch340g-micro-usb.html

Once I get that project operating, I would like to automate my water tank level reading (We live on rural acreage, relying on rain water). The idea is to feed the data to EmonCMS (private server), then use that data, as well as solar data to control pumps to move water. I want to have all connected by wifi for ease of use.

There are heaps of designs on the web for Arduino shields using ultrasonic transducers to measure water level (so no need to re-invent the wheel!), but there will be work required for the ESP8266 communication. This project will be powered by a small solar panel & Lithium Ion battery (because you do not want to climb a 7.5M water tank tower very often!). The best Ultrasonic sensor to use is the waterproof one available from AliExpress (& others) for a few $. (These are used on cars for parking sensors as an example)

A suggestion to the developers of the ESP8266 code is to allow bi-directional communication. I would also like to use the ESP8266 as a load controller (using a Solid State Relay) to switch on pumps for this project.

Eventually, I would like a fail-safe control system (possibly running on the EmonBase) to check levels while transfer pumping to ensure everything is OK. Living on Rainwater you cannot afford to lose water!

If anyone wants to start this project please keep me informed. I think it is applicable to the Emon project because water is another sustainability issue. Also this project could monitor other data, such as a hopper for an auto-feed boiler (using woodchip for instance).


(Paul Reed) #2

To be clear… are you wanting someone to design the system & write the code for you?


(Doug) #3

No, not someone to write the code. I am not a programmer, but I should be able to adapt other code to perform the task. However, I will need to use some modules from Emon project such as the ESP8266 code. As I said, I am not sure if this is bi-directional atm. It would need to be for this project (& possibly others).
Once the system software goes modular, it should be relatively easy to write & add a program to monitor the tank levels.

Judging by the number of projects reading tank levels (on the web), I think I will get some positive responses. Having the data web-accessible will, I think, tick some boxes. (Nothing worse than being away & having someone ring you to tell you the header tank has run out of water!)
regards, Doug


(Brian Orpin) #4

Just use a Sonoff device. Now has a weatherproof case available.


(Doug) #5

Thanks, but I prefer Wifi devices.

regards, Doug


(Trystan Lea) #6

Hello Doug, the Sonoff devices have an ESP8266 WIFI module inside that you can program with your own firmware and are great pieces of kit.

Here’s an example using the Sonoff S20 smartplug:
https://community.openenergymonitor.org/t/running-emonesp-on-the-sonoff-s20-smart-plug/9096

There’s also a small inline modules e.g:
https://www.ebay.co.uk/itm/Sonoff-ITEAD-Smart-Home-WiFi-Wireless-Switch-Module-Fr-Apple-Android-APP-Control-/332599444186?vti=


(Brian Orpin) #7

It is a WiFi device (as Trystan said). If you want more control over the data, you can flash the device with Tasmota.

If you can wait, order them direct from Itead in China and get the latest revision.


(stephen krywenko) #8

instead of using the wemos R3 you should simplify it and just use the wemos D1 R2 ( no ardiuno)… not sure how long your range finder going to survive in a hot moist environment- you be better off using an analog 16 channel multiplerer and place 16 pad spaced evenly apart in your tank and use a basic moisture sensor code to figure out the water level… or use a water pressure sensor - and say mount it on your drain bunk - fill your tank take a reading drain it to point the sensor does not read any more or your tank is empty - and then do the math to calculate your volume . though not sure if this sensor is accurate enough for you . as ~8 meter of water is ~ 0.08 mpa ( 11 psi)-- and this sensor is 0-1.6 mpa so it give only ~50 steps out of 1024 on a 8bit analog . but look around you might find a a more accurate water pressure sensor then this one – or possibly install 10 bit analog to get a few more steps


(Doug) #9

Thanks for the feedback. The ultrasonic sensors are the sam as is used on auto bumper bars, so should handle the environment. They have a section of lead (1M?) so the box can be a bit isolated.

I have also considered using the stainless float switches. These use a stainless tube, with a stainless float that has a magnet in it. The float can be reversed to be either nc or no. They also have 2 sensors on one stem (about 450mm long). I was thinking of mounting them on a plastic tube, so I have top, bottom, & a few steps in the middle.

One problem with roof water is sometimes it is pure enough to be non-conductive.

I think I will go with the Ultrasonic method, because the code is written already.

regards, Doug


(Bill Thomson) #10

8 bit analog would be a maximum of 256 steps.

10 bits represent 1024 steps.


(Greebo) #11

When I was on tank water, having even 128 (half of 256) steps of “tank level” would have been fantastic :slight_smile:


(stephen krywenko) #12

oops my mistake on bits- but so make that 10bit (normal arduino/esp- analog is 1024) and 12 bit 4096 ( 200 steps as opposed to 50 earlier )

@Dougo
code would be simple for the pressure sensor if you are worried about that you just use the basic analog sensor read and expand it here a quick example based on that water pressure sensor mentioned :

//0.009807 mpa per meter

float top = 7.5; //distance  in meters to top of  tank or water from where sensor is located 
float bottom= 3; //bottom of tank distance from sensor 
float step = 1024; //analog read step
float sensorrange = 1.6; //ie 0 - 1.6 mpa
float indivstep ; //indvidual step
int  maxstep; //max step
int  minstep; //min step
int  valve; 


void setup() {
// calculates the range of your tank based on your variables
invidstep =  (sensorrange/step); //calculates the value of the individual step
maxstep = ((top*0.009807)/indivstep);  //calculates where the  maximum location 
minstep = ((bottom*0.009807)/indivstep); // calculates the minimum steps location

  // initialize serial communication at 9600 bits per second:

  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  //Serial.println(sensorValue);
//figures out what percentage your tank is at 
if (sensorValue <=maxstep && >= minstep){
value = SensorValue - minstep; // brings the  min value down  to zero
int divisor;
divisor = (maxstep-minstep); //  calculates the divisor 
int percentage;
percentage= ((value/divisor)*100); //   and rounds down the value 
Serial.print( "your tank is  ");
Serial.print(percentage);
Serial.println (" %  full");
}
  delay(1000);        // delay for one second in between reads 
}

is you want it to shut off your water by controlling an SSR just add in to void setup

pinMode(7, OUTPUT);

and to the bottom of void loop above the the last }

if( percentage <5){  // 5 is your defined minimum water level
digitalWrite(7, HIGH); // turns off SSR ie no power to your pump
}
else{
digitalWrite(7, LOW); // turns on SSR
}

oh well just an added option for you if you like it untested but should work unless i have typo somewhere - best thing about it you install every thing at ground level no need to climb and if you have issue every thing right there for you easily reachable


(Doug) #13

Thanks (& Merry Christmas all so inclined!)

I am currently waiting on the boards & parts to get my Emon running.

I have found 2 of 9vAC plugpacks for the AC monitoring (Australian: Old Netcomm transformer plugpacks: just hit with a calibrated hammer to open case, then remove rectifier, etc. Luckily had 2 so both will be the same for 2 phase)

The Tank level is for later, but I always debug on the ground before going 7.5M up the stand!.

regards, Doug