Water sensor not switching back to dry state (0)

Hi All,

Currently I'm using a water sensor just to detect water leakage. The sensor returns 1 for dry state and 0 when water is detected. The strange thing is that the sensor works and detects water leakage, but never returns to the dry state (1) after that. The code I'm using;

Serial.print("Reading watersensor value 0 or 1:");
Serial.print(digitalRead(WATER_SENSOR));
Serial.println("DONE");
float WSBio = digitalRead(WATER_SENSOR);

The digitalread keeps returning 0 after water detection. After a reset of the Arduino a value of 1 is returned again.

Any ideas?

Thanks.

Please supply the whole program in code tags (</> icon) and a wiring diagram.

Weedpharma

Wild guess since you've neither shown the whole Arduino sketch nor given a schematic... you need a pullup resistor on the pin.

Ah, many thanks! That should be it, I'm using this sensor (Nieuwe Regen water sensor Waterniveausensor module Detectie diepte voor Arduino|rain water sensor|sensor water levelwater level sensor - AliExpress) and it's directly connected to the digital PIN without a pullup resistor between the VCC and SIG.

I'll give it a try with a resistor in between and post the result.

Thanks again.

alfredb:
I'll give it a try with a resistor in between

Save yourself a bit of hassle and use the built-in one:

pinMode(thePinMumber, INPUT_PULLUP;

Yeah, I was just reading that :slight_smile: Thanks! I'll give it a try on my NodeMCU.