Soil Moisture Sensor (Raspberry Pi)

Introduction: Soil Moisture Sensor (Raspberry Pi)

About: the Raspberry Pi is Awesome!

Basic tutorial of how to setup a soil moisture sensor with the Raspberry Pi.

Step 1: Parts

RPI 3 - https://amzn.to/2VA9pQY

4 Amp Power Adapter - https://amzn.to/2CTptWu

16GB micro SD - https://amzn.to/2SFMwd3

120 pcs jumper cable: https://ebay.to/2VAb9cY

Soil Moisture Sensors: https://amzn.to/2DfX5hs

Step 2: Setup

VCC -> 5V

GND -> GND

SIG -> GPIO 21

Step 3: Code

1. Copy script to raspberry pi

2. Run script by typing "python soil.py" and hit enter to run

Attachments

Step 4: Additional Info

Be the First to Share

    Recommendations

    • Rice & Grains Challenge

      Rice & Grains Challenge
    • Puzzles Challenge

      Puzzles Challenge
    • CNC and 3D Printing Contest

      CNC and 3D Printing Contest

    11 Comments

    0
    AphireAexon
    AphireAexon

    6 months ago on Step 4

    Great tutorial - thanks!
    Weirdly when I launch the python script it works the first time, but after it says that moisture was not detected it just keeps reporting not detected each time afterwards regardless of the LED switching on or off.

    The sensor is reporting the correct data but checking the pin input seems to be giving me the same value each time, is this a code problem or a faulty sensor?

    0
    AphireAexon
    AphireAexon

    6 months ago on Step 4

    Great tutorial - thanks!
    Weirdly when I launch the python script it works the first time, but after it says that moisture was not detected it just keeps reporting not detected each time afterwards regardless of the LED switching on or off.

    The sensor is reporting the correct data but checking the pin input seems to be giving me the same value each time, is this a code problem or a faulty sensor?

    0
    udaauday
    udaauday

    Question 1 year ago on Step 3

    How do I get sensor values like 90%,95%??

    0
    MagdalenaJ3
    MagdalenaJ3

    3 years ago

    Hi, Thanks for sharing this - it is really helpful.

    I am trying to set up a system that is rather monitoring how low is the water level in the soil. So how can I modify the code to actually print the output of the GPIO output? I realize this would need to be standardized, but having the actual numbers would be more helpful for me.

    Also - the code that can be downloaded from here has an error - in both cases the output reads "Water detected".

    0
    Anon
    Anon

    Reply 1 year ago

    Same here. How did you overcome this issue? I cant seem to find a solution.

    2
    Hareesh Kanna
    Hareesh Kanna

    3 years ago

    Why cant we use Analog pin instead of digital pin. Is Analog read() possible in raspberry pi??

    0
    TiglathIII
    TiglathIII

    3 years ago

    Hi, Can you explain why it is OK to put the DO pin from a 5V device onto a 3.3V Raspberry Pi?
    Every book I read makes a warning about 5V devices and the Pi. I guess that resistors in the device are making sure that the voltage does not exceed 3.3V but is there a safety resistor we should be using in series with the DO pin perhaps just to be safe?

    0
    Willrocks07
    Willrocks07

    4 years ago

    Hi are used to see instructor ball on a school project slightly modifying it so would play music and LED would change colour depending on the state of the plant this really helped me with my project thank you I will post a instructable on what I did

    0
    HugoS94
    HugoS94

    Question 4 years ago

    Hi, Excellent tutorial. Is it possible to connect multiple sensors to the same Raspberry? If yes, how can I do it? Thanks.

    0
    Willrocks07
    Willrocks07

    Answer 4 years ago

    Yes you can you just have to duplicate the script and change the GPIO numbers

    0
    Ghostrider513
    Ghostrider513

    Question 4 years ago

    Can a flexible probe be made to detect dehydration? This could be a great wearable.