Hi
I am new to Arduino and I am using a jsn-sr04t with a Uno to read measurements in cm in a rectangular
water tank using the NewPing sketch. I would like to convert the cm values to litres. I know the volume of the tank and litres per cm, but I cannot find any code to convert to litres. Any help would be appreciated.

Forget the code for now. You say that you know the number of litres per cm so let's suppose that it is 2 litres per centimetre and I told you that the level had risen 3 centimetres. How many litres have been added to the tank ?

andypc:
Hi
Many thanks for your replies. I did not have a problem with the maths, just what the code was to put into the sketch.

Regards Andy

Declare a const variable with a sensible name to the number of litres per cm
Declare a const variable with a sensible name for the distance in cm from the sensor to the bottom of the tank
Read the distance from the sensor to the water in the tank and put the answer in a variable
Do the maths using the data that you have