4

I'm using a classic Water Level Detection Sensor or sometimes called Rain Water Level Sensor together with a RPI 3+ to detect water in a Pot (Link). So I don't need any analog reading but only the information about the presence of water.

I tested this Code:

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)

GPIO.setup(18,GPIO.OUT) # to Power the Sensor with 3.3 Volt
GPIO.setup(23,GPIO.IN) # to get the Sensor Reading
GPIO.output(18,1)
state = GPIO.input(23)

on a small breadboard setup and everything works:

Water: state = 1

No Water: state = 0

Now when I'm trying the same on the bigger setup with approx. 3 meters of cable between the Pi and the Sensor --> I always end up with 0 reading with some random exemptions. I tried the same setup with an arduino and it worked (Sensor powered via 5 Volt).

Is my assumption, that the low (3.3) voltage together with the bigger distance cause the wrong readings on the pi?

Update: Tried the 3.3 Volt Pin instead of Pin 18 and it did not help.

1

Question

GPIO.setup(18,GPIO.OUT) # to Power the Sensor with 3.3 Volt

Tried the 3.3 Volt Pin instead of Pin 18 and it did not help

Answer

I found that the Xinda water level detector uses the very common NPN BJT SS8050. Usually the a BJT is biased for a fixed voltage, say, 5V for Arduino. If you supply power Vcc = 3V3, then the BJT might not work properly, or intermittently marginal. On the other hand, CMOS FET circuit usually works from 3V to 5V. So my conclusion is that

this water level should use 5V power supply 5V.

Some months ago I tested the detector with the following results.

detector results

The output is analog from 0V to 3V, so is good if you want to measure rain water level. But then you need an ADC.

But if your application is not water level detection, but also soil moisture sensing, then there are many more digital and analog devices to choose, but more expensive. The one in the reference using the OP Amp MCP606 as a comparator, gives digital output for easy digital interface.

References

water level sensor spec

more moisture sensors

Raspberry Pi Analog Water Sensors ADC Tutorial - 41,699 views

Raspberry Pi Analog Water Sensor Tutorial - 2016oct11

moisture sensors demonstration and explain about why sensors broke after time

Capacitive Soil Moisture Sensor v1.2

ESP32 WiFi Blue Tooth Battery DHT11 Soil Moisture/Temperature - ¥85

Soil Moisture/Temperature Sensor (Nickel plated, no corrosion problem) - ¥23

1

At least one of the comments on the linked product says they only work with 5V so you may well be correct.

I suggest you power them from 5V and drop the output to a Pi safe 3V3 by using a resistor divider at the receiving GPIO.

  • will try ... since I only want to power the Sensor during the readings I think I'm going to need a Mosfet to toggle the 5 Volts. – Peter S May 12 at 12:26
  • 1
    I didn't pick up that you were powering via the GPIO. They can only supply about 20mA. Perhaps that is part of the problem. I would also check the circuit works from the Pi 5V pin before buying additional circuitry. – joan May 12 at 12:31
  • to my knowledge those sensors need less than 20mA and as I stated the whole setup worked on the breadboard but i can try to connect the sensor to the 3.3 volt pins – Peter S May 12 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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