Waterproff UltraSonic

Can u Please provide me the programming logic of waterproof ultrasonic sensor for exact reading of data. M trying to detect the level of water but i could not get the exact data. So can u suggest me the logic for getting the exact data ...............

Could you post what you tried?
And what Arduino you are using and what sensor and its data sheet?

Borish:
Can u Please provide me the programming logic of waterproof ultrasonic sensor for exact reading of data. M trying to detect the level of water but i could not get the exact data. So can u suggest me the logic for getting the exact data ...............

How close to the "exact level" did you get? Is it within the error range for the device?

Paul

i tried the below code:

#define trigger 4
#define echo 5
float tim=0, distance = 0;
int temp = 0;
void setup{
pinMode(trigger,OUTPUT);
pinMode(echo,INPUT);
digitalWrite(trigger,LOW);
delayMicroseconds(2);
digitalWrite(trigger,HIGH);
delayMicroseconds(10);
digitalWrite(trigger,LOW);
delayMicroseconds(2);

tim=pulseIn(echo,HIGH);
distance=tim*340/20000;
Serial.print("Empty Space In ");
Serial.print("Tank is: ");
Serial.print(distance);
Serial.println(“cm”);
delay(2000);

if(distance<10 && temp==0)
{
Serial.println(“WATER TANK FULL”);
delay(2000);
temp = 1;
}
else if(distance<25 && temp==1)
{
Serial.println(“Water Tank Half”);
delay(5000);
}
else if(distance>40)
{

Serial.println(“Low water Tank”);
delay(5000);
temp = 0;
}
}

here in this code i am getting wrong data for sensor. please check it.

Where is your loop()?