I am designing a water level sensor using two 2mm graphite rods about 10cm long. I have attached the leads for my schematic to the graphite rods using silver epoxy.
I am using an Arduino Pro Mini pin A0 for the input from sensor. and the following code.
float waterSensorInValue = analogRead(A0);
delay(10);
float waterSensorInValue2 = analogRead(A0);
delay(10);
float waterSensorInValue3 = analogRead(A0);
delay(10);
float waterSensorInValue4 = analogRead(A0);
delay(10);
float waterSensorInValue5 = analogRead(A0);
delay(10);
float waterSensorInValue6 = analogRead(A0);
delay(10);
float waterSensorInValue7 = analogRead(A0);
delay(10);
float waterSensorInValue8 = analogRead(A0);
delay(10);
float waterSensorInValue9 = analogRead(A0);
delay(10);
float waterSensorInValue10 = analogRead(A0);
delay(10);
float waterSensorInValueA = (waterSensorInValue+waterSensorInValue2+waterSensorInValue3+waterSensorInValue4+waterSensorInValue5+waterSensorInValue6+waterSensorInValue7+waterSensorInValue8+waterSensorInValue9+waterSensorInValue10)/10;
Serial.print (waterSensorInValueA);
I take ten successive readings from the sensor pin and then divide by 10.
Does anyone know how to get more precise reading as with a few decimal places?
The problem is that the sensor reading isn't consistent. Last night it was reading 682 when the filler started filling the pool. Two and a half minutes later is read 664 when the level had risen a little. Then 2.5 minutes later it was 657. After that it went up (relatively) for the next hour as it filled. When it shut off the water it was reading 663. Two hours later it read 690 and then 693 two hours after that. Eight hours later it is at 702 with no more water being added. The water temperature hasn't changed.
Can someone explain the reason for the level to drop when water was first added and then rise only to shoot back up after it has finished filling?
One reason could be the water being sensed was directly from the ground water source without being mixed with the pool water which could have more particulates increasing conductivity.
Any help would help.
I am using averaging to mitigate wave action. But still the reading fluxuate as much as three points. I am thinking of putting more time between the reading and putting a 10uf capacitor between the sensor and ground to smooth things out. Any opinion on this.
Thanks for any suggestions.
I am not including the led on my wiring.
This is the MH Water Sensor I based mine on As the water rises up the bars the reading rises. Am I missing something or do I have the wrong type transistor?
average = (average * 9 + analogRead(A0))/10; delay(10);
should do the same job as your first 20 lines of code. \$\endgroup\$