I am trying to measure the liquid level in a reservoir. The liquid can either be water or mineral oil ( no vapours expected as application is at temperatures around 30 Deg C.) Required range is from 30 cm to 200 cm.
Been experimenting with the HCRS04- but somehow not very satisfied withe results. The function used is as below :
// FUNCTION TO READ THE ULTRASONIC SENSOR
void readUltrasonic () {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
measDistance = (duration / 29.15) / 2;
// Calculating the water level
if ( maxDistance > measDistance) {
waterLevel = maxDistance - measDistance;
waterLevelPC = (waterLevel * 100 ) / maxDistance;
}
else {
waterLevel = 0;
}
// Prints the distance on the Serial Monitor
Serial.print("Distance in cm : ");
Serial.println(measDistance);
Serial.println();
Serial.print(" WaterLevel in cm : ");
Serial.println(waterLevel);
Serial.println();
Serial.print(" WaterLevel in % : ");
Serial.println(waterLevelPC);
Serial.println();
}
Anyone has experience with this or any other better sensors exist ? More important is the HCSR04 suitable for liquid level measurement ??
Inconsistent values - even with a fixed level of water the readings are rolling . Like if its 70cm in reality the values swing between 50 to 120. The other problem is lack of resolution - like I need to change the sensing distance by atleast 25cm to see any change.
Actually its a bit difficult to write what I see as there is no pattern to the same. Maybe I have a dud sensor ?
I would suggest an air pressure sensor run a tube to the bottom of the tank the tube needs to have a pressure sensor on the top end (out of the watter) this one looks promising but I am not sure if it would be the best for your application.
MPS20N0040D-D
The tube is attached to the pressure sensor 0-5.9 psi shown above now as the tube with only air inside descends to the bottom of your reservoir (sensor end stays out of the water) at the bottom the air pressure is greater because of the depth of the water. The air tries to escape out the top but the pressure sensor is there and only displaces the water. If the water level drops the tube displaces less water and the pressure decreases. with some calibration you can calculate the depth based on air pressure in the tube.
The MPS20N0040D-D seems to be a novel way with an inverted tube ! Takes out the messiness in having an immersed sensor.
The sealing between the sensing tube and the sensor opening becomes critical as any leak here will undermine the readings. For sure will check this out.