I'm completely new to RPi, and I'd like to make a garden project, at first I would like to measure the soil moisture.

I purchased one of these sensors https://www.amazon.com/Analog-Capacitive-Moisture-Corrosion-Resistant/dp/B07N11R8MD and also an ADS1015 ADC.

I followed the tutorial on this page, so I know my ADC is working properly https://learn.adafruit.com/adafruit-4-channel-adc-breakouts/python-circuitpython , after that I connected my sensor to the setup. VCC of the sensor is connected to the 3V3 of the RPi, GND to RPi GND, AOut to ADC A0.

In this case I don't get the right value since when it's dry i get 0 and when wet also 0 ( when i touch the sensor i get some value not 0).

After that i connected the vcc of the sensor to the 5V of the RPi. In this case I get right values as when dry 30000 when the sensor is in a glass of water it's 16000.

I read something about having to be careful with the 5V Pin, but I don't really understand if it's allowed to use the 5V Pin as a power source for the sensor?

My setup looks like this: https://banasiak.com/blog/wp-content/uploads/2019/09/pepperbot2_bb3.png

My Code:

import board
import busio
import adafruit_ads1x15.ads1015 as ADS
import RPi.GPIO as GPIO
from time import sleep
i2c = busio.I2C(board.SCL, board.SDA)
from adafruit_ads1x15.analog_in import AnalogIn
ads = ADS.ADS1015(i2c)
chan0 = AnalogIn(ads, ADS.P0)
chan1 = AnalogIn(ads, ADS.P1)
while True:

   print('Channel 0 is:',chan0.value, chan0.voltage)
   #print('Channel 1 is:',chan1.value, chan1.voltage)

Later on I would like to expand my project with more Soil moisture Sensor and a Relay controlling a pump. Thanks for any help.

  • @shujaandi, Welcome and nice to meet you. Ah let me see. Your moisture sensor EK1940 and ADC1015 ADC look good. (1) " Gikfun EK1940 - Capacitive moisture sensor V1.2 for 3V3/5V Rpi/Arduino operation) - $12 for two units": amazon.com/Gikfun-Capacitive-Corrosion-Resistant-Detection/dp/…. / to continue, ... – tlfong01 Jul 31 at 11:35
  • The datasheet says that there is an on board 3V3/5V regulator and compatible for 5V Arduino and 3V3 Rpi. So I would recommend you to power the sensor with 3V3. – tlfong01 Jul 31 at 11:36
  • Some time ago I also played with moisture sensors, ADC 1015 and also relay KY019, and weight sensor HX711. You might like read the following forum discussion for more details: "Micro Green Project (moisture sensor, ADC, Relay, Weight Sensor) - rpi.org.forum 2019feb09 raspberrypi.org/forums/viewtopic.php?f=91&t=233311#p1427880. Cheers. – tlfong01 Jul 31 at 11:45
  • 1
    Thank you for the reccomendations @tlfong01, I will definitely check them. My problem with 3V3 is that my sensor shows 0 when it's in water and when it's completely dry, although when I connect with 5V pin it shows correct values. – shujaandi Jul 31 at 13:08
  • 1
    Thanks a lot for your time and advices. Do you think that I should implement a logic level shifter just to avoid that 1% risk? Cheers – shujaandi Jul 31 at 13:41

Your Answer

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

Browse other questions tagged or ask your own question.