Comments on: Water Tank level display with Arduino https://www.open-electronics.org/water-tank-level-display-with-arduino/ Open source electronic projects Tue, 17 Jul 2018 04:24:27 +0000 hourly 1 https://wordpress.org/?v=6.8.3 By: HSMECHANIC https://www.open-electronics.org/water-tank-level-display-with-arduino/#comment-12736 Tue, 17 Jul 2018 04:24:27 +0000 http://www.open-electronics.org/?p=1466#comment-12736 In reply to HASHIM ASHRAF.

Hello Hashim

use this code, i have some error line 324-325!
“hWatherCm = H_POZZO – microseconds_to_centimeters(duration);” this one

error code is this
C:\Users\HANSEOKHWAN\Documents\Arduino\sketch_jul09a\sketch_jul09a.ino:10:0: warning: “PI” redefined

#define PI 3.1415926535898

^

In file included from sketch\sketch_jul09a.ino.cpp:1:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:47:0: note: this is the location of the previous definition

#define PI 3.1415926535897932384626433832795

^

sketch_jul09a:60: error: stray ‘\342’ in program

newChar[i] = code[n ?? 1];

^

sketch_jul09a:60: error: stray ‘\200’ in program

sketch_jul09a:60: error: stray ‘\223’ in program

sketch_jul09a:324: error: stray ‘\342’ in program

hWatherCm = H_POZZO ?? microseconds_to_centimeters(duration);

^

sketch_jul09a:324: error: stray ‘\200’ in program

sketch_jul09a:324: error: stray ‘\223’ in program

C:\Users\HANSEOKHWAN\Documents\Arduino\sketch_jul09a\sketch_jul09a.ino: In function ‘byte* getChar(int, byte*)’:

sketch_jul09a:60: error: expected ‘]’ before numeric constant

newChar[i] = code[n ?? 1];

^

sketch_jul09a:60: error: expected ‘;’ before numeric constant

C:\Users\HANSEOKHWAN\Documents\Arduino\sketch_jul09a\sketch_jul09a.ino: In function ‘void print_histogram(int)’:

sketch_jul09a:270: error: expected ‘;’ before numeric constant

for (i = 0; i 0)

^

C:\Users\HANSEOKHWAN\Documents\Arduino\sketch_jul09a\sketch_jul09a.ino: In function ‘long int read_height()’:

sketch_jul09a:324: error: expected ‘;’ before ‘microseconds_to_centimeters’

hWatherCm = H_POZZO ?? microseconds_to_centimeters(duration);

^

sketch_jul09a:24: error: expected ‘)’ before numeric constant

#define H_POZZO 146.0 /* cm */

^

C:\Users\HANSEOKHWAN\Documents\Arduino\sketch_jul09a\sketch_jul09a.ino:326:15: note: in expansion of macro ‘H_POZZO’

if (hWatherCm H_POZZO)

^

exit status 1
stray ‘\342’ in program

please help me i want a resolve this problem

thank you and have a nice day

]]>
By: Shijil https://www.open-electronics.org/water-tank-level-display-with-arduino/#comment-12614 Thu, 23 Nov 2017 13:44:00 +0000 http://www.open-electronics.org/?p=1466#comment-12614 Not working, display shows nothing. tried in real and also tried online simulation!

]]>
By: John Schtein https://www.open-electronics.org/water-tank-level-display-with-arduino/#comment-12494 Mon, 12 Jun 2017 14:29:00 +0000 http://www.open-electronics.org/?p=1466#comment-12494 Thank you for the article, I think that Arduino is indeed the future. I work for the company implementing different remote monitoring solutions (for example, http://www.dataonline.com/tank-level-monitoring/), but not Arduino yet.

]]>
By: SuperHouse Automation https://www.open-electronics.org/water-tank-level-display-with-arduino/#comment-12098 Sun, 10 Jul 2016 07:30:30 +0000 http://www.open-electronics.org/?p=1466#comment-12098 […] this are really limited to your imagination! To get started on this project check out the following link. […]

]]>
By: Pratik Singhal https://www.open-electronics.org/water-tank-level-display-with-arduino/#comment-12071 Fri, 24 Jun 2016 11:41:00 +0000 http://www.open-electronics.org/?p=1466#comment-12071 Hi! Very nice project. I have a question. Mostly water tanks are kept on roof and water level needs to be displayed at ground level.
One thing that can be done is connecting sensor wirelessly to Arduino so that sensor can send readings from roof tank to Arduino at ground level.
Can you please suggest any way to accomplish this?
Thank you.

]]>
By: BorisLandoni https://www.open-electronics.org/water-tank-level-display-with-arduino/#comment-11987 Sun, 08 May 2016 08:14:00 +0000 http://www.open-electronics.org/?p=1466#comment-11987 In reply to Jon Biddell.

HI, this is open source, of course you can modify it to insert new features ;-)

]]>
By: Jon Biddell https://www.open-electronics.org/water-tank-level-display-with-arduino/#comment-11937 Wed, 23 Mar 2016 10:33:00 +0000 http://www.open-electronics.org/?p=1466#comment-11937 I know this is old, but I’m going to get my daughter to build this as a learning experience… Just wondering if it would be possible to incorporate a flow sensor in it as well ??

]]>
By: HASHIM ASHRAF https://www.open-electronics.org/water-tank-level-display-with-arduino/#comment-11936 Wed, 23 Mar 2016 07:37:00 +0000 http://www.open-electronics.org/?p=1466#comment-11936 Thanks Boris Landoni for this awsome -(* – *)-

i figured out some mistakes on your pgm

Its the final one;

#include

#define PING_PIN 13

#define BUZZER_PIN 8

#define SWITCH_INT 0 /* 0 => pin 2 */

#define PI 3.1415926535898

#define SUPERFICE_BASE (R_POZZO * R_POZZO * PI)

#define SIZE_BAR (16 * 5)

#define ALARM_ICON 0 /* code */

#define SOUND_ICON 6 /* code */

#define SOUND_ICON_ON 7 /* code */

#define R_POZZO 0.5 /* raggio pozzo (m) */

#define H_POZZO 146.0 /* cm */

#define SOGLIA_ALLARME_1 100 /* cm */

#define SOGLIA_ALLARME_2 120 /* cm */

#define DELAY_0 60000 /* ms; 1000 * 60 * 1 = 1 min */

#define DELAY_1 600 /* ms */

#define DELAY_2 200 /* ms */

/* initialize the library with the numbers of the interface pins */

LiquidCrystal lcd(12, 11, 5, 4, 3, 6);

int mute = 0;

byte *getChar(int n, byte newChar[]) {

int i;

byte code[5] = {

B10000,

B11000,

B11100,

B11110,

B11111};

for (i = 0; i < 8; i++)

newChar[i] = code[n – 1];

return newChar;

}

void setup() {

int i;

float h;

byte newChar[8];

/* set up the LCD's number of rows and columns: */

lcd.begin(16, 2);

for (i = 1; i < 6; i++)

lcd.createChar(i, getChar(i, newChar));

{

newChar[0] =B00000;

newChar[1] =B00100;

newChar[2] =B01010;

newChar[3] =B01010;

newChar[4] =B11111;

newChar[5] =B00100;

newChar[6] =B00000;

}

lcd.createChar(ALARM_ICON, newChar);

{

newChar[0] =B00011;

newChar[1] =B00101;

newChar[2] =B11001;

newChar[3] =B11001;

newChar[4] =B11001;

newChar[5] =B00101;

newChar[6] =B00011;

}

lcd.createChar(SOUND_ICON, newChar);

{

newChar[0] =B00100;

newChar[1] =B10010;

newChar[2] =B01001;

newChar[3] =B01001;

newChar[4] =B01001;

newChar[5] =B10010;

newChar[6] =B00100;

}

lcd.createChar(SOUND_ICON_ON, newChar);

pinMode(BUZZER_PIN, OUTPUT);

/**

* LOW to trigger the interrupt whenever the pin is low,

* CHANGE to trigger the interrupt whenever the pin changes value

* RISING to trigger when the pin goes from low to high,

* FALLING for when the pin goes from high to low.

*/

attachInterrupt(digitalPinToInterrupt(SWITCH_INT), button, RISING);

/* initialize serial communication */

Serial.begin(9600);

}

void loop() {

long hWatherCm;

int litres;

hWatherCm = read_height();

if (check_alarm(hWatherCm) != 0) /* read again wather height */

hWatherCm = read_height();

lcd.clear();

print_histogram(hWatherCm);

lcd.setCursor(0, 1);

lcd.print(hWatherCm);

lcd.print(" cm – ");

// litres = SUPERFICE_BASE * (hWather / 100.0) * 1000

litres = floor(SUPERFICE_BASE * hWatherCm * 10);

lcd.print(litres);

lcd.print(" l ");

lcd.setCursor(14, 1);

lcd.write(SOUND_ICON);

lcd.setCursor(15, 1);

if (!mute)

lcd.write(SOUND_ICON_ON);

else

lcd.write('X');

/*

Serial.print("cm = ");

Serial.println(hWatherCm);

*/

switch (check_alarm(hWatherCm)) {

case 1:

lcd.setCursor(0, 0);

//lcd.write("A,N");

buzz(200);

delay(DELAY_1);

break;

case 2:

lcd.setCursor(0, 0);

// lcd.write("A,N");

buzz(200);

delay(200);

buzz(200);

delay(DELAY_2);

break;

case 0: // no alarm

delay(DELAY_0);

}

}

void print_histogram(int hWatherCm) {

int i;

int bloks;

float histogram;

// hWatherCm : HPOZZO = histogram : SIZE_BAR

histogram = (SIZE_BAR * hWatherCm) / H_POZZO;

histogram = histogram + 0.5;

bloks = (int)histogram / 5;

for (i = 0; i 0)

lcd.write((int)(histogram) % 5);

}

long read_height() {

/**

* establish variables for duration of the ping,

* and the distance result in centimeters:

*/

long duration, hWatherCm;

/**

* The PING))) is triggered by a HIGH pulse of 2 or more microseconds.

* Give a short LOW pulse beforehand to ensure a clean HIGH pulse:

*/

pinMode(PING_PIN, OUTPUT);

digitalWrite(PING_PIN, LOW);

delayMicroseconds(2);

digitalWrite(PING_PIN, HIGH);

delayMicroseconds(5);

digitalWrite(PING_PIN, LOW);

/**

* The same pin is used to read the signal from the PING))): a HIGH

* pulse whose duration is the time (in microseconds) from the sending

* of the ping to the reception of its echo off of an object.

*/

pinMode(PING_PIN, INPUT);

duration = pulseIn(PING_PIN, HIGH);

/* convert the time into a distance */

hWatherCm = H_POZZO – microseconds_to_centimeters(duration);

if (hWatherCm H_POZZO)

return H_POZZO;

return hWatherCm;

}

void buzz(int msec) {

if (!mute)

digitalWrite(BUZZER_PIN, HIGH);

delay(msec);

digitalWrite(BUZZER_PIN, LOW);

}

int check_alarm(int hWatherCm) {

if (hWatherCm > SOGLIA_ALLARME_1) {

if (hWatherCm < SOGLIA_ALLARME_2)

return 1;

else

return 2;

}

return 0;

}

long microseconds_to_centimeters(long microseconds) {

/**

* The speed of sound is 340.29 m/s or 29.4 microseconds per centimeter.

* The ping travels out and back, so to find the distance of the

* object we take half of the distance travelled.

*/

return microseconds / 29.387 / 2;

}

void button() {

mute = !mute;

lcd.setCursor(15, 1);

if(!mute)

lcd.write(SOUND_ICON_ON);

else

lcd.write('X');

}

]]>
By: HASHIM ASHRAF https://www.open-electronics.org/water-tank-level-display-with-arduino/#comment-11935 Wed, 23 Mar 2016 07:35:00 +0000 http://www.open-electronics.org/?p=1466#comment-11935 In reply to shali.

its the working program
Regards Hashim,Ashraf -(* – *)-

#include
#define PING_PIN 13

#define BUZZER_PIN 8

#define SWITCH_INT 0 /* 0 => pin 2 */

#define PI 3.1415926535898

#define SUPERFICE_BASE (R_POZZO * R_POZZO * PI)

#define SIZE_BAR (16 * 5)

#define ALARM_ICON 0 /* code */

#define SOUND_ICON 6 /* code */

#define SOUND_ICON_ON 7 /* code */

#define R_POZZO 0.5 /* raggio pozzo (m) */

#define H_POZZO 146.0 /* cm */

#define SOGLIA_ALLARME_1 100 /* cm */

#define SOGLIA_ALLARME_2 120 /* cm */

#define DELAY_0 60000 /* ms; 1000 * 60 * 1 = 1 min */

#define DELAY_1 600 /* ms */

#define DELAY_2 200 /* ms */

/* initialize the library with the numbers of the interface pins */

LiquidCrystal lcd(12, 11, 5, 4, 3, 6);

int mute = 0;

byte *getChar(int n, byte newChar[]) {

int i;

byte code[5] = {

B10000,

B11000,

B11100,

B11110,

B11111};

for (i = 0; i < 8; i++)

newChar[i] = code[n – 1];

return newChar;

}

void setup() {

int i;

float h;

byte newChar[8];

/* set up the LCD's number of rows and columns: */

lcd.begin(16, 2);

for (i = 1; i < 6; i++)

lcd.createChar(i, getChar(i, newChar));

{

newChar[0] =B00000;

newChar[1] =B00100;

newChar[2] =B01010;

newChar[3] =B01010;

newChar[4] =B11111;

newChar[5] =B00100;

newChar[6] =B00000;

}

lcd.createChar(ALARM_ICON, newChar);

{

newChar[0] =B00011;

newChar[1] =B00101;

newChar[2] =B11001;

newChar[3] =B11001;

newChar[4] =B11001;

newChar[5] =B00101;

newChar[6] =B00011;

}

lcd.createChar(SOUND_ICON, newChar);

{

newChar[0] =B00100;

newChar[1] =B10010;

newChar[2] =B01001;

newChar[3] =B01001;

newChar[4] =B01001;

newChar[5] =B10010;

newChar[6] =B00100;

}

lcd.createChar(SOUND_ICON_ON, newChar);

pinMode(BUZZER_PIN, OUTPUT);

/**

* LOW to trigger the interrupt whenever the pin is low,

* CHANGE to trigger the interrupt whenever the pin changes value

* RISING to trigger when the pin goes from low to high,

* FALLING for when the pin goes from high to low.

*/

attachInterrupt(digitalPinToInterrupt(SWITCH_INT), button, RISING);

/* initialize serial communication */

Serial.begin(9600);

}

void loop() {

long hWatherCm;

int litres;

hWatherCm = read_height();

if (check_alarm(hWatherCm) != 0) /* read again wather height */

hWatherCm = read_height();

lcd.clear();

print_histogram(hWatherCm);

lcd.setCursor(0, 1);

lcd.print(hWatherCm);

lcd.print(" cm – ");

// litres = SUPERFICE_BASE * (hWather / 100.0) * 1000

litres = floor(SUPERFICE_BASE * hWatherCm * 10);

lcd.print(litres);

lcd.print(" l ");

lcd.setCursor(14, 1);

lcd.write(SOUND_ICON);

lcd.setCursor(15, 1);

if (!mute)

lcd.write(SOUND_ICON_ON);

else

lcd.write('X');

/*

Serial.print("cm = ");

Serial.println(hWatherCm);

*/

switch (check_alarm(hWatherCm)) {

case 1:

lcd.setCursor(0, 0);

//lcd.write("A,N");

buzz(200);

delay(DELAY_1);

break;

case 2:

lcd.setCursor(0, 0);

// lcd.write("A,N");

buzz(200);

delay(200);

buzz(200);

delay(DELAY_2);

break;

case 0: // no alarm

delay(DELAY_0);

}

}

void print_histogram(int hWatherCm) {

int i;

int bloks;

float histogram;

// hWatherCm : HPOZZO = histogram : SIZE_BAR

histogram = (SIZE_BAR * hWatherCm) / H_POZZO;

histogram = histogram + 0.5;

bloks = (int)histogram / 5;

for (i = 0; i 0)

lcd.write((int)(histogram) % 5);

}

long read_height() {

/**

* establish variables for duration of the ping,

* and the distance result in centimeters:

*/

long duration, hWatherCm;

/**

* The PING))) is triggered by a HIGH pulse of 2 or more microseconds.

* Give a short LOW pulse beforehand to ensure a clean HIGH pulse:

*/

pinMode(PING_PIN, OUTPUT);

digitalWrite(PING_PIN, LOW);

delayMicroseconds(2);

digitalWrite(PING_PIN, HIGH);

delayMicroseconds(5);

digitalWrite(PING_PIN, LOW);

/**

* The same pin is used to read the signal from the PING))): a HIGH

* pulse whose duration is the time (in microseconds) from the sending

* of the ping to the reception of its echo off of an object.

*/

pinMode(PING_PIN, INPUT);

duration = pulseIn(PING_PIN, HIGH);

/* convert the time into a distance */

hWatherCm = H_POZZO – microseconds_to_centimeters(duration);

if (hWatherCm H_POZZO)

return H_POZZO;

return hWatherCm;

}

void buzz(int msec) {

if (!mute)

digitalWrite(BUZZER_PIN, HIGH);

delay(msec);

digitalWrite(BUZZER_PIN, LOW);

}

int check_alarm(int hWatherCm) {

if (hWatherCm > SOGLIA_ALLARME_1) {

if (hWatherCm < SOGLIA_ALLARME_2)

return 1;

else

return 2;

}

return 0;

}

long microseconds_to_centimeters(long microseconds) {

/**

* The speed of sound is 340.29 m/s or 29.4 microseconds per centimeter.

* The ping travels out and back, so to find the distance of the

* object we take half of the distance travelled.

*/

return microseconds / 29.387 / 2;

}

void button() {

mute = !mute;

lcd.setCursor(15, 1);

if(!mute)

lcd.write(SOUND_ICON_ON);

else

lcd.write('X');

}

]]>
By: joe conery https://www.open-electronics.org/water-tank-level-display-with-arduino/#comment-11934 Mon, 21 Mar 2016 18:01:00 +0000 http://www.open-electronics.org/?p=1466#comment-11934 I made something along these lines awhile back for the sump of my saltwater aquarium. Eventually evaporation/humidity/salt splashing… interfered with it’s ability to function.
The beam is not that focused, so you need to put it fairly close to the water surface so that it doesn’t read the top edges of your container where it becomes susceptible to this.

]]>
By: Kami Reddy Thejesh https://www.open-electronics.org/water-tank-level-display-with-arduino/#comment-11819 Tue, 02 Feb 2016 15:03:00 +0000 http://www.open-electronics.org/?p=1466#comment-11819 Hi, I too doing on the Same type of Project .
But need to read the Data Measured on the Tank And So As to control the Flow, Using a Flow Meter .
My Project needs to be Continued From the Point of Reading the data .
Any one Please Suggest, How to read the values .

]]>
By: Anthony https://www.open-electronics.org/water-tank-level-display-with-arduino/#comment-11622 Mon, 21 Sep 2015 04:48:00 +0000 http://www.open-electronics.org/?p=1466#comment-11622 when I copy and paste I have this compiling errors:

Arduino: 1.7.6 (Windows 10), Board: “Arduino Uno”

LCD_Tank_Level_Meter.ino: In function ‘void setup()’:

LCD_Tank_Level_Meter.ino:58:11: error: assigning to an array from an initializer list

LCD_Tank_Level_Meter.ino:70:11: error: assigning to an array from an initializer list

LCD_Tank_Level_Meter.ino:82:11: error: assigning to an array from an initializer list

LCD_Tank_Level_Meter.ino: In function ‘void loop()’:

LCD_Tank_Level_Meter.ino:146:25: error: call of overloaded ‘write(int)’ is ambiguous

LCD_Tank_Level_Meter.ino:146:25: note: candidates are:

In file included from LCD_Tank_Level_Meter.ino:7:0:

D:ArduinolibrariesLiquidCrystalsrc/LiquidCrystal.h:83:18: note: virtual size_t LiquidCrystal::write(uint8_t)

virtual size_t write(uint8_t);

^

In file included from D:ArduinolibrariesLiquidCrystalsrc/LiquidCrystal.h:5:0,

from LCD_Tank_Level_Meter.ino:7:

D:Arduinohardwarearduinoavrcoresarduino/Print.h:49:12: note: size_t Print::write(const char*)

size_t write(const char *str) {

^

LCD_Tank_Level_Meter.ino:154:25: error: call of overloaded ‘write(int)’ is ambiguous

LCD_Tank_Level_Meter.ino:154:25: note: candidates are:

In file included from LCD_Tank_Level_Meter.ino:7:0:

D:ArduinolibrariesLiquidCrystalsrc/LiquidCrystal.h:83:18: note: virtual size_t LiquidCrystal::write(uint8_t)

virtual size_t write(uint8_t);

^

In file included from D:ArduinolibrariesLiquidCrystalsrc/LiquidCrystal.h:5:0,

from LCD_Tank_Level_Meter.ino:7:

D:Arduinohardwarearduinoavrcoresarduino/Print.h:49:12: note: size_t Print::write(const char*)

size_t write(const char *str) {

^

Error compiling.

]]>