I connected my Soil Moisture sensor to my RaspberryPi following this tutorial.
But I have small problem with reading the analog value of humidity. When I put the sensor to the glass of water, the Digital LED on sensor turn ON, but my script still returns 0. This is the script I’m talking about:
delay = 5
spi = spidev.SpiDev()
val = spi.xfer2([1,(8+channel)<<4,0])
data = ((val&3) << 8) + val
if __name__ == "__main__":
val = readChannel(0)
#if (val != 0):
It read good value once. After reading the good value I changed the script to print the value even if it’s 0
What is the problem? Did I damage the sensor by putting it into glass of water?
How far did you submerge it? I have no experience with this device, but I would think that as long as you kept the water below the circuitry (i.e. the dark part at the top) it would probably be OK. If you submerged the whole thing that would probably have killed the sensor.
Try stopping the RPi, unplug it, replug it back in, then restart the RPi and try again. If it still reads 0 I’d say the sensor is dead.
I haven’t reached the dark part. What I read about this sensor one hour ago, it often reads value 0 even if the sensor is submerged in water. I think I have to check this in flower pot.
(a bit off topic)
I would suggest a capacitve soil moisture sensor
It also reports an analog value like yours but it has the big advantage that the electrodes do not corrode.
It’s a budget project for studies, that means every dollar counts
costs around 0,80€ on aliexpress
Oh, you’re right. I googled it and the first result was 6$