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.

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tank level monitoring
#31
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!
  Reply
#32
Hi, the project is very much alive. However, I have used most of my time (limited as it is with a job and family life) on the yacht server part of it.
The best part is that we acquired a new boat this fall, an Ovni 395 : https://photos.app.goo.gl/2WGKVTG9KXaUZq7N6

Most of the information is found here: https://sites.google.com/site/olewsaa/ya...el-monitor
and the code : https://github.com/olewsaa/Yacht-compute...alK-v2.ino

This code is just a start. I have planned to install a number of these sensors over the winter to monitor the heads holding tank. If you follow the
project page: https://sites.google.com/site/olewsaa/yacht-server i'll post the progress.

An additional problem showed up, how to measure the kerosene day tank level. The electromagnetic ones do not work with organic fluids.
Will see if some ultrasonic might work, I am not to happy with floats etc.  

Ole
  Reply
#33
(11-07-2018, 02: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


Forum Jump:


Users browsing this thread: 1 Guest(s)