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:");
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.
Please supply the whole program in code tags (</> icon) and a wiring diagram.
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.
I'll give it a try with a resistor in between
Save yourself a bit of hassle and use the built-in one:
Yeah, I was just reading that Thanks! I'll give it a try on my NodeMCU.