# Project water level measurement

Good evening, I’m building a system to measure the water level of a tank through the ultrasonic sensor and achieved using the sensor with the LCD screen but only shows me the distance in cm and fleas, I need is to see the level of expreaso water milliliters and liters truth I have no idea how to do some advice? eh also seen that the ultrasonic sensor varies depending on the temperature and the speed of sound with this reading, it would be possible to construct a temperature sensor apart and this makes me calculated using a speed of sound? I welcome your advice thanks before hand.

by the way my code is as follows:

``````#include <LiquidCrystal.h> //Incluye la libreria de la pantalla LCD
LiquidCrystal lcd(10); //Inicia la biblioteca del numeros de pines del integrado  74HC595

long distancia, distanciaInch;
long tiempo;

void setup()
{
lcd.begin(16, 2); //Establece el numero de caracteres y filas de la pantalla LCD
pinMode(9, OUTPUT); //Configuracion del pin 12 como salida: Trigger = Disparo
pinMode(12, INPUT); //Configuracion del pin 9 como entrada: Echo = Eco

}

void loop()
{
digitalWrite(9,LOW); //Para darle estabilidad al sensor
delayMicroseconds(5);

digitalWrite(9,HIGH); //Enviamos el pulso para activar el sensor
delayMicroseconds(10); //Con una duracion de 10us
tiempo=pulseIn(12, HIGH); //Funcion para medir la longitud del pulso entrante, mide el tiempo transcurrido ida y vuelta
distancia= (0.017*tiempo); //Formula para calcular la distancia
distanciaInch= (0.00665*tiempo);

lcd.setCursor(0,0); //Ubica la primera palabra en la linea 0 columna 0
lcd.print("Distancia ");
lcd.print(distancia);
lcd.print("cm");

lcd.setCursor(0,1);
lcd.print("Distancia ");
lcd.print(distanciaInch);
lcd.print("inch");
delay(1000);

lcd.clear();
delay(10);

}
``````

Welcome to the Fourm.

as a new member, we would ask you to read How To Use This Forum.

# 7 about positing code. how to use this forum is found at the top of every forum.

empty the machine completely. pour in exactly 1 litre of cold water. measure the height of the water.

pour in exactly 1 more litre of cold water measure the height of the water.

repeat with hot water.

you could pour in 1/10 litre and recored the level for each 1/10 litre.

then you would know distance is equal to litres.

Hi, Welcome to the forum.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom.. :)

thank you all for your answers. I do not understand me I mean I am using this sensor to measure the liquid level in a tank but not how to make the measurement is displayed in liters or milliliters, do not want the investigation eh distance and if you can a make but I can not give with her

ultrasonic = distance the sensor can only measure distance.

you must know the volume of the container to calculate quantity

suppose the tank is has a height of 1.08 m and a width of 1.17m as would be the formula to calculate my arduino me the water level ?

Your tank will hold 1160 Liters. How far above the tank will you mount the ultrasonic transducer? You need to have it at least 3 - 4 cm above the top of the tank. Then measure the distance from the transducer to the bottom of the tank. Subtract the transducer reading from that and you will have the height of the liquid. Then it is simply pi * r * r * h * 1000 for liters.
Note: r and h are in meters.
If the above dimensions are the actual tank, pi * r * r * 1000 will be 1075. Just multiply the height of the liquid by that for liters. There will be a slight error due to rounding. (1075 * 1.08 = 1161)
(Have not figured out Pi or superscript symbols on this forum)

Sorry I didn't understand that you said me, why two r?

The formula for the volume of a cylinder is pi * r squared * h. On this forum I do not know how to bring up the square symbol, the small 2 up and to the right of r so I just used r * r instead.

and to test the accuracy. empty the tank and pour in exactly 100 litres measure add 400 more litres, measure add 500 more and measure.

that way you can see how close your measured values are from the actual tank volume.

thank you very much I will be discussing them anything :)