This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tank level monitoring
#33
(2018-11-07, 07:10 PM)abarrow Wrote: Sure, I'll have to dig up the Arduino sketch I used, but it's extremely simple. Let me see if I can put something together for you.

It may not be super quick as my boat just came out of the water and I need to be at the yard to do work on it!

I found the sketch. Basically, for a sensor, you get a piece of plastic rod the depth of your water tank, and put rings of copper on the very bottom, then at three other places farther up the rod (low, med, full...). Those come back to your Arduino (the bottom contact is ground). As the water level rises, each sensor contact is brought low, which activates the associated LED. Also on your arduino, you attach LEDs to indicate levels. In my case, I used Green, Green, Yellow and Red in a descending row in a little box. 

Code:
*
 Level Sense
This is a water level detector for a tank. It uses a plastic rod with contacts up the length

*/

// set pin numbers:
//Below bottom sensor
const int ledPinRed =  13;
//Above bottom sensor
const int ledPinYellow = 12;
//Above middle sensor
const int ledPinGreen1 =  11;
//Above top sensor
const int ledPinGreen2 =  10;

//Sensors
const int sensorPinLow = 9;
const int sensorPinMed = 8;
const int sensorPinHigh = 7;

int sensorTotalValue = 0;
int sensorValueLow = 0;
int sensorValueHigh = 0;
int sensorValueMed = 0;

void setup() {
 pinMode(ledPinRed, OUTPUT);
 pinMode(ledPinYellow, OUTPUT);
 pinMode(ledPinGreen1, OUTPUT);
 pinMode(ledPinGreen2, OUTPUT);
 pinMode(sensorPinLow, INPUT_PULLUP);
 pinMode(sensorPinMed, INPUT_PULLUP);
 pinMode(sensorPinHigh, INPUT_PULLUP);
 
 Serial.begin(9600);
 Serial.println("Welcome to the level sensor");
}

void loop() {
 //Reset the sensors
//  int sensorValueLow = 0;
//  int sensorValueHigh = 0;
//  int sensorValueMed = 0;
 // read the state of the sensor values:
 
 if (digitalRead(sensorPinLow) == HIGH) {
   sensorValueLow = 1;}
   else {
   sensorValueLow = 0;
 }
 if (digitalRead(sensorPinMed) == HIGH) {
   sensorValueMed = 1;}
   else {
   sensorValueMed = 0;
 }
 if (digitalRead(sensorPinHigh) == HIGH) {
   sensorValueHigh = 1;}
   else {
   sensorValueHigh = 0;
 }
 sensorTotalValue = sensorValueHigh + sensorValueMed + sensorValueLow;
 
 Serial.print("Sensor Value: ");
 Serial.println(sensorTotalValue);
 
 // make sure all the lights are out
  digitalWrite(ledPinRed, HIGH);
  digitalWrite(ledPinYellow, LOW);
  digitalWrite(ledPinGreen1, LOW);
  digitalWrite(ledPinGreen2, LOW);
 
 // then turn on the right lights
 switch(sensorTotalValue) {
   case 3:
     //Absolutely low. Flash the red led
     digitalWrite(ledPinRed, LOW);
     delay(500);
     digitalWrite(ledPinRed, HIGH);
     delay(500);
     break;
   case 2:
   //Yellow Light only
     digitalWrite(ledPinYellow, HIGH);
     break;
   case 1:
   //First green light and yellow
     digitalWrite(ledPinYellow, HIGH);
     digitalWrite(ledPinGreen1, HIGH);
     break;
   case 0:
   //Two green lights and yellow
     digitalWrite(ledPinYellow, HIGH);
     digitalWrite(ledPinGreen1, HIGH);
     digitalWrite(ledPinGreen2, HIGH);
     break;    
 }

}
I'm sure this can be made to interconnect with OP, I just never got around to doing it!
Thank's alot for the information! It will be perfect to monitor my water tank. I do have a arduino uno that I can use and "millions" of small led lights in different colours. I don't need to know exactly the amount of liters, just something that tells me that it's time to fill it up and when then tank is full when I fill it up.
//Patrik
Reply


Messages In This Thread
Tank level monitoring - by olewsaa - 2017-06-25, 05:56 PM
RE: Tank level monitoring - by abarrow - 2017-06-25, 10:33 PM
RE: Tank level monitoring - by olewsaa - 2017-06-26, 01:04 PM
RE: Tank level monitoring - by abarrow - 2017-06-28, 09:46 PM
RE: Tank level monitoring - by Sailoog - 2017-06-28, 07:02 PM
RE: Tank level monitoring - by olewsaa - 2017-06-28, 07:18 PM
RE: Tank level monitoring - by Sailoog - 2017-06-29, 06:18 PM
RE: Tank level monitoring - by abarrow - 2017-07-05, 03:17 PM
RE: Tank level monitoring - by SCarns - 2021-07-21, 05:56 PM
RE: Tank level monitoring - by frpmanu - 2017-07-26, 08:22 AM
RE: Tank level monitoring - by jim321 - 2017-07-26, 12:00 PM
RE: Tank level monitoring - by abarrow - 2017-07-26, 04:06 PM
RE: Tank level monitoring - by jim321 - 2017-07-26, 04:16 PM
RE: Tank level monitoring - by olewsaa - 2017-07-31, 08:02 PM
RE: Tank level monitoring - by abarrow - 2017-07-31, 07:05 AM
RE: Tank level monitoring - by jim321 - 2017-07-31, 11:26 PM
RE: Tank level monitoring - by Sailoog - 2017-08-06, 06:55 PM
RE: Tank level monitoring - by olewsaa - 2017-08-06, 08:14 PM
RE: Tank level monitoring - by olewsaa - 2017-08-13, 08:38 AM
RE: Tank level monitoring - by Sailoog - 2017-08-27, 12:01 PM
RE: Tank level monitoring - by olewsaa - 2017-08-27, 07:46 PM
RE: Tank level monitoring - by Saqqara - 2017-10-14, 06:17 AM
RE: Tank level monitoring - by olewsaa - 2017-10-15, 05:07 PM
RE: Tank level monitoring - by affinite - 2017-10-16, 10:04 AM
RE: Tank level monitoring - by abarrow - 2017-10-17, 06:02 PM
RE: Tank level monitoring - by Pkarl45 - 2018-11-07, 02:49 PM
RE: Tank level monitoring - by olewsaa - 2017-10-16, 04:05 PM
RE: Tank level monitoring - by abarrow - 2017-11-01, 06:24 PM
RE: Tank level monitoring - by JD1 - 2017-11-02, 03:34 AM
RE: Tank level monitoring - by SkipperEarly - 2017-11-02, 01:10 PM
RE: Tank level monitoring - by abarrow - 2017-11-02, 02:39 PM
RE: Tank level monitoring - by abarrow - 2018-11-07, 07:10 PM
RE: Tank level monitoring - by Pkarl45 - 2018-11-08, 12:36 PM
RE: Tank level monitoring - by olewsaa - 2018-11-07, 10:05 PM
RE: Tank level monitoring - by Charles Riley - 2020-10-24, 08:13 PM
RE: Tank level monitoring - by John_Anderson - 2020-10-27, 02:36 AM
RE: Tank level monitoring - by abarrow - 2021-07-21, 06:10 PM
RE: Tank level monitoring - by SCarns - 2022-07-22, 04:33 PM
RE: Tank level monitoring - by sgowardipe - 2022-07-21, 06:30 PM
RE: Tank level monitoring - by RichFind - 2022-09-24, 11:24 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)