TEP , The Engineering Projects , Author Welcome! Syed Zain Nasir Mechatronics Engineer TEP , The ENgineering Projects , TEP Badge TEP , The Engineering Projects , Ratting Background 7.5 7.5/10
TEP , The Engineering Projects , Rating Percentage Background Reputation Score 55 / 100
TEP , The Engineering Projects , Tutorials TEP , The Engineering Projects , Tutorials

Raspberry Pi 4

How To Interface A Soil Moisture Sensor With Raspberry Pi 4, soil moisture sensor with rpi4, rpi4 with soil moisture sensor, raspberry pi 4 soil moisture sensor
TEP , The Engineering Projects , Boxes

Interfacing Soil Moisture Sensor with Raspberry Pi 4

TEP , THe Engineering Projects , Shares 2.5K Views
TEP , The ENgineering Projects , Reaction 40
TEP , The ENgineering Projects , Reaction 700
TEP , The ENgineering Projects , Reaction 60
TEP , The ENgineering Projects , Reaction 25
TEP , The ENgineering Projects , Reaction 60
TEP , The Engineering Projects , Pintrest TEP , The Engineering Projects , Pintrest TEP , The Engineering Projects , Pintrest TEP , The Engineering Projects , Pintrest TEP , The Engineering Projects , Pintrest
Shares: 691
TEP , The Engineering Projects , PCBWAY
How To Interface A Soil Moisture Sensor With Raspberry Pi 4, soil moisture sensor with rpi4, rpi4 with soil moisture sensor, raspberry pi 4 soil moisture sensor

Hello everyone, I hope you all are doing great. Today, we are going to share the second chapter of Section-III in our Raspberry Pi programming course. The previous guide covered how to interface an LDR Sensor with Raspberry Pi 4. This tutorial will cover the basics of hooking up a soil humidity sensor to a Raspberry Pi 4 to get accurate readings. Next, we'll write a Python script to collect the data from the sensors and display it on a Serial monitor.

Are you aware that you can utilize a Raspberry Pi 4 to track the water absorbed by the soil around your houseplants or garden? This helpful guide will show you how to install a soil humidity sensor that will send you a text message when your plant needs watering. A Pi 4, a soil humidity sensor, and a few low-priced components are required. All right, let's get going!

Project Description

Today, we are going to interface Soil Moisture with Raspberry Pi 4. We will design a simple irrigation system, where we will measure the moisture of the soil and depending on its value, will turn ON or OFF the water pump. We will also use a 20x4 LCD to display values/instructions.

  • Here's the video demonstration of this tutorial:


Components Required

  1. Raspberry Pi 4.
  2. Soil humidity sensor.
  3. Breadboard.

Soil Moisture Sensor

One way to assess soil conditions is with a soil moisture sensor. The electromagnetic signal that the sensor emits travels through the soil. The sensor then evaluates the moisture level based on the signal's reception.

How To Interface A Soil Moisture Sensor With Raspberry Pi 4, soil moisture sensor with rpi4, rpi4 with soil moisture sensor, raspberry pi 4 soil moisture sensor

We can use soil moisture sensor has numerous purposes. Saving water is one of them. Adjustments to the watering system can be made based on readings from the sensor that measures the soil's moisture level. This could cut down on both water consumption and waste. Plant health can be enhanced by employing a soil moisture monitor, another perk. We can use this sensor to set off a relay to begin watering the plant if the soil moisture level drops off a given threshold.

Soil Moisture Sensor Working Principle

The two exposed wires on the fork-shaped probe function as a variable resistor whose resistance changes with the soil's moisture level.

How To Interface A Soil Moisture Sensor With Raspberry Pi 4, soil moisture sensor with rpi4, rpi4 with soil moisture sensor, raspberry pi 4 soil moisture sensor

The above figure demonstrates how to use a soil moisture sensor to detect moisture levels. When water is poured into the soil, the voltage of the sensor immediately reduces from 5V to 0V. The module has a potentiometer(blue) that adjusts how sensitively the digital pin changes state from low to high when water is introduced into the soil.

There are typically two components that make up a soil moisture sensor.

The Probe

Two exposed conductors on a fork-shaped probe are put wherever moisture levels need to be determined. As was previously mentioned, its a variable resistor whose resistance changes as a function of soil moisture.

How To Interface A Soil Moisture Sensor With Raspberry Pi 4, soil moisture sensor with rpi4, rpi4 with soil moisture sensor, raspberry pi 4 soil moisture sensor

The Module

The sensor also has an electronic module that is interfaced with the microcontroller. The module produces a voltage proportional to the probe's resistance and makes it available through an Analog Output pin. The same signal is then sent to a Digital Output pin on an LM393 High Accuracy Comparator.

How To Interface A Soil Moisture Sensor With Raspberry Pi 4, soil moisture sensor with rpi4, rpi4 with soil moisture sensor, raspberry pi 4 soil moisture sensor

The module features a potentiometer (DO) for the fine-tuning of digital output sensitivity. It can be used to establish a threshold i.e. at which threshold the module will output a LOW signal and a HIGH otherwise.

How To Interface A Soil Moisture Sensor With Raspberry Pi 4, soil moisture sensor with rpi4, rpi4 with soil moisture sensor, raspberry pi 4 soil moisture sensor

In addition to the IC, the module has two LEDs. When the component is activated, the Power LED will light up, and the Condition LED will light up if the moisture level is above the setpoint.

Soil Moisture Sensor Pinout

Four pins are included on the FC-28 soil moisture sensor.

How To Interface A Soil Moisture Sensor With Raspberry Pi 4, soil moisture sensor with rpi4, rpi4 with soil moisture sensor, raspberry pi 4 soil moisture sensor

  • Vcc: Power Pin(+5V).
  • A0: An analog output Pin.
  • D0: Digital output Pin.
  • GND: Ground

Soil Moisture Sensor Applications

Among the various uses of Moisture Sensors, I am sharing a few here:

  • Soil moisture monitoring for efficient watering schedules.
  • Tracking the severity of the drought.
  • Methods for Assessing Irrigation System Performance.
  • Estimating Harvest Success.
  • Compaction of soil detection For environmental reasons, the SMS can be used to do things like: keep an eye on soil moisture levels to make sure water supplies are being used efficiently.
  • Monitoring irrigation systems for leakage.

Soil Moisture Sensor with Raspberry Pi 4

As with most things involving the Raspberry Pi, connecting a soil humidity sensor is child's play. we need to connect the soil moisture sensor with Pi 4 GPIO header. This connection requires three wires.

  • The yellow(data) line will be connected to the Raspberry Pi 4 GPIO Pin4, and the red(power) wire will go to the Raspberry Pi's 5V pin.

We can now start coding our project because all the pieces are in place. Now is the time to begin.

How To Interface A Soil Moisture Sensor With Raspberry Pi 4, soil moisture sensor with rpi4, rpi4 with soil moisture sensor, raspberry pi 4 soil moisture sensor

Here's our hardware setup having soil Moisture Sensor with RPi4:

How To Interface A Soil Moisture Sensor With Raspberry Pi 4, soil moisture sensor with rpi4, rpi4 with soil moisture sensor, raspberry pi 4 soil moisture sensor

Here's the Pin's Mapping:

  • VCC -> 5V

  • GND -> GND

  • DATA-> GPIO4

Python script for Soil Moisture Probe with RPi4

After the sensor has been hooked up, testing it requires the creation of some code. The following code can be copied and pasted into a text editor, then saved as a .py file.

How To Interface A Soil Moisture Sensor With Raspberry Pi 4, soil moisture sensor with rpi4, rpi4 with soil moisture sensor, raspberry pi 4 soil moisture sensor

import RPi.GPIO as GPIO

import time

#GPIO SETUP

channel = 4

GPIO.setmode(GPIO.BCM)

GPIO.setup(channel, GPIO.IN)

def callback(channel):

        if GPIO.input(channel):

                print ("Water Detected!")

        else:

                print ("Water Detected!")

GPIO.add_event_detect(channel, GPIO.BOTH, bouncetime=300)  

GPIO.add_event_callback(channel, callback)  

while True:

        time.sleep(0)

  • The script should be copied into the Python IDLE on the raspberry pi.
  • To execute the script, type "python soil.py" and press Enter.
  • The following command is used to execute the code once it has been saved: "python yourfilename.py"

The below output should be observed if the sensor is operating correctly:

Output

How To Interface A Soil Moisture Sensor With Raspberry Pi 4, soil moisture sensor with rpi4, rpi4 with soil moisture sensor, raspberry pi 4 soil moisture sensor

Conclusion

So, there's been a moisture detection! You can change the code to perform any action you like. Once the humidity level is detected, you could activate a motorized or audible alarm, for instance. In the next tutorial, we will Interface a Sharp IR Sensor with RPi4. Stay tuned. Have a good day.

TEP , The Engineering Projects , Tags
How To Interface A Soil Moisture Sensor With Raspberry Pi 4
soil moisture sensor with rpi4
rpi4 with soil moisture sensor
raspberry pi 4 soil moisture sensor
TEP , The Engineering Projects , Comments

Write a Comment

TEP , The Engineering Projects , WordPress TEP , The Engineering Projects , Google TEP , The Engineering Projects , Twitter TEP , The Engineering Projects , Facebook TEP , The Engineering Projects , User
TEP , The Engineering Projects , Robot
TEP , The Engineering Projects , Comments Comments on ‘’ Interfacing Soil Moisture Sensor with Raspberry Pi 4 ‘’ (0)
TEP , The Engineering Projects , About TEP , The Engineering Projects , About Shadow

Top PCB Design Service

PCBA
TEP , The Engineering Projects , JLCPCB
PCB
TEP , The Engineering Projects , JLCPCB
TEP , The Engineering Projects , About TEP , The Engineering Projects , About Shadow

Embedded Tools

ARDINO TEP , The Engineering Projects , JLCPCB
TEP , The Engineering Projects , About TEP , The Engineering Projects , About Shadow

Subscribe Now !!!

Learn Free Pro Tricks

TEP , The Engineering Projects , Mail Receive Quality Tutorials Straight in your Inbox by Submitting your Email ID Below
TEP , The Engineering Projects , Mail TEP , The Engineering Projects , Mail Shadow
TEP , The Engineering Projects , Mail Robot TEP , The Engineering Projects , Mail Robot Shadow TEP , The Engineering Projects , Mail Robot Shadow
TEP , The Engineering Projects , About TEP , The Engineering Projects , About Shadow

Engineering Books

TEP , The Engineering Projects , Arduino Programming Book
SALE $20
Text Book for arduino $20
TEP , The Engineering Projects , Rating Stars (5.0)
TEP , The Engineering Projects , Arduino Programming Book
SALE $20
Text Book for Raspberry Pi $20
TEP , The Engineering Projects , Rating Stars (3.0)
TEP , The Engineering Projects , Arduino Programming Book
SALE $20
Text Book for arduino $20
TEP , The Engineering Projects , Rating Stars (4.7)
TEP , The Engineering Projects , Arduino Programming Book
SALE $20
Text Book for Raspberry Pi $20
TEP , The Engineering Projects , Rating Stars (5.0)
TEP , The Engineering Projects , TEP Robot TEP , The Engineering Projects , TEP Robot Shadow TEP , The Engineering Projects , TEP Robot Shadow
TEP , The Engineering Projects , About TEP , The Engineering Projects , About Shadow

Categories

TEP , The Engineering Projects , Arduino
TEP , The Engineering Projects , Notification 20K
TEP , The Engineering Projects , Tick 900
TEP , The Engineering Projects , Views 900
TEP , The Engineering Projects , Comments 20K
TEP , The Engineering Projects , Arduino
TEP , The Engineering Projects , Notification 20K
TEP , The Engineering Projects , Tick 900
TEP , The Engineering Projects , Views 900
TEP , The Engineering Projects , Comments 20K
TEP , The Engineering Projects , Arduino
TEP , The Engineering Projects , Notification 20K
TEP , The Engineering Projects , Tick 900
TEP , The Engineering Projects , Views 900
TEP , The Engineering Projects , Comments 20K
TEP , The Engineering Projects , Arduino
TEP , The Engineering Projects , Notification 20K
TEP , The Engineering Projects , Tick 900
TEP , The Engineering Projects , Views 900
TEP , The Engineering Projects , Comments 20K
TEP , The Engineering Projects , Arduino
TEP , The Engineering Projects , Notification 20K
TEP , The Engineering Projects , Tick 900
TEP , The Engineering Projects , Views 900
TEP , The Engineering Projects , Comments 20K