0
\$\begingroup\$

I'm trying to use a water sensor in a new design, and I don't understand the example circuit that is given in the datasheet, even though it looks very very simple. I must be missing something. Any help explaining why this example circuit works would be much appreciated.

enter image description here

I don't get how the example circuit shown in the image “Arduino circuit I don't understand” works. The datasheet for the water sensor can be found here.

In the example in question, it says that the Arduino Mega should be in a pull up mode, which I believe should pull the digital input pin up to 5 V. But the sensor is hooked up to 5 V on the other side, so when water is present and it conducts, it seems like the input pin should also go to 5 V. We tested the real device though and found that when there is water the Arduino reads a digital low.

Please explain how this circuit works and why we see a digital low when water is present. To me it looks like the following two conditions would happen:

No water present: Water sensor doesn't conduct. The Arduino input is pulled high to 5 V by the internal pull-up.

Water present: 5V is detected by the Arduino input (a high impedance digital input state) since the water allows the signal to propagate.

What am I missing? Thanks!

\$\endgroup\$
0

2 Answers 2

0
\$\begingroup\$

Your analysis is correct: the datasheet circuit will not work and I doubt they've actually tested it in that configuration. Given the relatively high MΩ impedance of your sensor and the nature of its signal, I recommended using an analog front-end with a voltage divider and Schmitt trigger comparator to give a clean digital signal to your Arduino. Or use a normal (probably rail-to-rail) opamp to buffer the signal into one of your Arduino's analog inputs if you want to measure the level (not just above/below a setpoint) and don't mind cleaning up the signal in software.

\$\endgroup\$
0
\$\begingroup\$

I think you might misinterpreted the information provided by the datasheet. The datasheet suggested two type of configurations for interfacing with Arduino/Rapsberry Pi.

LS-2600 interface with Arduino or RPI

This, when translating into a schematic would looks something like the following:

schematic

simulate this circuit – Schematic created using CircuitLab

So if you write your code to read the sensor using ADC with the following code:

int value = analogRead(LS_2600);
int sensed_voltage = value * 5 / 1023;

It would shows a voltage of 0v when it is not in-contact with water because the LS-2600 has an infinitely high impedance like an open contact, and the pulldown resistor would pull the analog input to ground; and it will shows an voltage of 3.9v when the sensor is in-contact with water based on the assumption that the resistance is 1.4M-ohm. This method will only applicable to Arduino but not Raspberry Pi because Raspberry Pi does not have analog input.

The method two uses Digital Input with internal pull-up and noticed the connection wiring as provided by the datasheet, the red wire is connected directly to the Digital Input pin of Arduino/RPI, and white wire is connected to the GND, together with internal pull-up form the voltage divider.

pinMode(LS_2600, INPUT_PULLUP);
if (digitalRead(LS_2600) // if the reading is HIGH
  // no leakage
else
  // leakage

Assuming the internal pull-up resistance is around 50k-ohm, the voltage presented at the Digital Input pin is around .95V, whether this will be considered as logical LOW would need to further consult the datasheet of the MCU.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.