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.