Problem with calibration of “Water level sensor” when power is turned on

Hello
I am running a sample program for “Water level sensor” on Arduino, but if the sensor is submerged in water when the power is turned on, it will not measure correctly.

If the sensor is placed outside of water when the power is turned on, and then placed in water, the Hello
I am running a sample program for “Water level sensor” on Arduino, but if the sensor is submerged in water when the power is turned on, it will not measure correctly.

If the sensor is placed outside of water when the power is turned on, and then placed in water, the measurements will be accurate.

example
(a problem occured)
Under water when power is turned on
sample1


water level = 0%
low 8 sections value =
0.0.0.0.0.0.0.251.
high 12 sections value =
251.0.0.0.0.0.0.0.0.0.0.0.


sample2


water level = 0%
low 8 sections value =
0.0.0.0.0.0.0.0.
high 12 sections value =
0.0.0.0.0.0.0.0.0.0.0.0.


(works correctly)
Out of water when powering on, then in water


water level = 45%
low 8 sections value =
252.251.252.252.253.251.252.251. PASS
high 12 sections value =
250.0.0.0.0.0.0.0.0.0.0.0.


Due to the above operation,
・If there is water in it from the beginning
・If the power is turned on and off repeatedly
In these two cases, this sensor will not work properly.

This problem seems to be caused by the initialization of the sensor when the power is turned on. Is there a way to avoid this problem?

By the way, this problem occurs with Arduino, but it also occurs with Raspberry Pi PICO, which was ported with Python.

I find this

Hey! Still face error with Ardunio? Lee me know by replying this message. Thanks

Actually the issue with inaccurate water level measurements when the sensor is submerged at power-up can be addressed by adding a delay in the Arduino or Raspberry Pi PICO code’s setup() function, allowing the sensor to stabilize before reading data.

For instance, a delay of 1 second can be added. Additionally, ensure that the sensor has adequate time to warm up, as some sensors require it. If the problem persists, consider using a pull-up or pull-down resistor on the sensor’s signal pin to maintain a consistent state during initialization, preventing erratic readings. Calibration and filtering techniques can further enhance measurement accuracy in challenging scnarios.

Did you exactly use the same code that is given here?

mrjames thank you for your reply.

I also set a delay of about 10 seconds to allow time for calibration, but it did not solve the problem so far.

And further

I added a delay of 1 minute before and after wire.begin in the Arduino setup function.

void setup() {
delay(60000);
SERIAL.begin(115200);
Wire.begin();
delay(60000);
}

But the problem persisted.

Once I have a resistor, I’ll put a pull-up resistor in SCL SDA of the grove’s I2c.

Yes, I was running the code as is from the source of that web page.

If you put the sensor into water after turning on the power and starting the program, it is working normally.

If you turn on the power while submerged in water from the beginning, measurements will not be accurate.

This is a similar problem reported over two years ago at the URL I cited a while back.

You can make a water level indicator by yourself like this: Water Level Indicator PCB Design Board - Share Project - PCBWay
You can make a prototype and compare the performance with your existing setup.

When the sensor is submerged in water at the time of powering on, it doesn’t provide accurate measurements. If I place the sensor outside of water during power-on and then immerse it in water, the measurements become accurate. I’ve tried adjusting a cup bras the code to introduce a delay during setup.