Automatic Plant Watering System using Arduino & Soil Moisture Sensor | LCD display [with CODE]

Tech at Home
25 Aug 202309:53

Summary

TLDRThis Arduino tutorial video builds on a previous lesson about soil moisture sensors by integrating an LCD module and a water pump to create an automatic plant watering system. The required components include an Arduino board, soil moisture sensor, LCD module, relay module, a 9-volt water pump, and jumper wires. The script outlines the connections for each part and provides a code example that activates the pump when soil is dry, displaying status on the LCD. The demonstration shows the system in action, automatically watering the plant when needed.

Takeaways

  • πŸ˜€ The video is an Arduino tutorial focused on creating an automatic plant watering system.
  • πŸ”§ The main components needed are an Arduino board, a soil moisture sensor, an LCD module, a relay module, a water pump, and jumper wires.
  • πŸ“ The LCD module used is a 16x2 I2C model, which simplifies the wiring process.
  • πŸ”Œ Connections involve linking the VCC and ground of all components to the Arduino's 5V and ground, with specific pins for the sensor, LCD, and relay.
  • πŸ’§ The soil moisture sensor's analog output is connected to Arduino's analog pin A0.
  • πŸ–₯ The LCD module's SDA and SCL pins are connected to Arduino's analog A4 and A5 pins, respectively.
  • πŸ”˜ The relay module's signal input is connected to a digital pin on the Arduino, in this case, digital pin 7.
  • 🌑 The water pump's operation is controlled by the relay module, which is activated when the soil is dry based on sensor readings.
  • πŸ“Š The code includes logic to determine soil moisture levels and activate the pump accordingly.
  • πŸ’¬ The LCD displays the soil moisture status and the motor's (pump's) status.
  • πŸ”§ A demonstration is provided showing the system in action, with the pump turning on when the soil is dry and off when it's wet.

Q & A

  • What is the main focus of the video tutorial?

    -The main focus of the video tutorial is to demonstrate how to add an LCD module and a water pump to an existing soil moisture sensor setup to create an automatic plant watering system using an Arduino board.

  • What is the purpose of using an LCD module in this project?

    -The purpose of using an LCD module is to display the moisture content of the soil, providing a visual representation of the sensor readings.

  • What type of water pump is used in the tutorial?

    -A small 9-volt water pump is used in the tutorial for the automatic plant watering system.

  • What is the role of the relay module in this setup?

    -The relay module is used to control the water pump's operation based on the soil moisture levels read by the sensor.

  • Which pins on the Arduino board are used for the LCD module connections?

    -The LCD module's VCC and ground are connected to the Arduino's 5V and ground. The SDA pin is connected to the Arduino's analog A4 pin, and the SCL pin is connected to the Arduino's analog A5 pin.

  • How is the soil moisture sensor connected to the Arduino board?

    -The soil moisture sensor's VCC and ground are connected to the Arduino's 5V and ground, and the analog output pin is connected to the Arduino's analog pin A0.

  • What is the significance of the value 950 in the code?

    -The value 950 is used as a threshold in the code to determine when the soil is dry and needs watering, triggering the relay to activate the water pump.

  • How does the code differentiate between dry, medium, and wet soil conditions?

    -The code uses if-else statements to evaluate the sensor values. If the value is greater than 950, the soil is considered dry. If the value is between a certain range (not specified in the transcript), the soil is medium. If less than 400, it is considered wet.

  • What function is used to control the relay pin in the code?

    -The `digitalWrite` function is used to control the relay pin, which is connected to digital pin 7, to turn the water pump on or off based on the soil moisture levels.

  • How is the status of the soil and the motor displayed on the LCD?

    -The status of the soil (dry, medium, wet) and the motor status (on or off) are displayed on the LCD using the LCD module's commands, with the soil status on the first row and the motor status on the second row.

  • What is the purpose of the demonstration at the end of the tutorial?

    -The purpose of the demonstration is to show the automatic plant watering system in action, illustrating how the system monitors soil moisture and triggers the water pump when the soil is dry.

Outlines

00:00

πŸ’§ Building an Automatic Plant Watering System with Arduino

This paragraph introduces an Arduino tutorial focused on creating an automatic plant watering system. The tutorial builds upon a previous video that explained the basic operation of a soil moisture sensor and included basic code for reading moisture values. The project incorporates an LCD module for displaying moisture content and a water pump for automatic watering. The required components include an Arduino board, soil moisture sensor, 16x2 LCD module with an I2C interface, a single-channel relay module, a 9-volt water pump, a power supply, and jumper wires. The paragraph details the connections for each component, starting with the moisture sensor to the Arduino's 5V and GND, and the analog output to pin A0. The LCD module is connected to the same power and ground, with the SDA and SCL pins connected to A4 and A5, respectively. The relay module is also connected to 5V and GND, with its signal input connected to a digital pin (in this case, pin 7). The water pump's negative terminal is connected to the battery's negative terminal, and the positive terminals are connected to the relay module's common and normally open terminals. The paragraph concludes with a reference to a separate tutorial on relay basics and a link to the circuit diagram in the description box.

05:00

πŸ”§ Implementing the Watering System Logic and LCD Display

In this paragraph, the script outlines the coding process for the automatic plant watering system. It begins with a review of the existing code from a previous tutorial, which reads sensor values and evaluates them using if-else statements to determine soil moisture levels. The code is then expanded to include logic for activating a pump when the soil is dry, indicated by a sensor value greater than 950. The script explains the use of a digital pin (pin 7) to control the relay, which in turn controls the water pump. The code also includes logic to handle different soil moisture conditions, ensuring the pump is off when the soil is medium or wet. Additionally, the paragraph describes the integration of an LCD module to display information about the soil's moisture status and the pump's operation. It references previous tutorials for understanding the basics of LCD coding and mentions the use of a 16x2 LCD. The script provides a brief overview of the LCD's setup, including initialization functions and displaying messages on the LCD based on the soil moisture condition. The paragraph concludes with a demonstration of the system in action, showing how the motor starts when the soil is dry and stops once the soil is wet, after adding water to the soil.

Mindmap

Keywords

πŸ’‘Arduino

Arduino is an open-source electronics platform based on easy-to-use hardware and software. It is widely used for building various interactive electronic projects. In the video's context, it serves as the central control unit for the automatic plant watering system, handling the reading of moisture values and activating the water pump when necessary.

πŸ’‘Soil Moisture Sensor

A soil moisture sensor is a device that measures the amount of water present in the soil. It is crucial in the video's project as it provides the data needed to determine the soil's moisture content. The sensor's output is read by the Arduino board to decide whether to activate the water pump.

πŸ’‘LCD Module

An LCD (Liquid Crystal Display) module is an electronic display module used to display information in a readable format. In the video, it is used to show the moisture content and the status of the water pump, providing a visual interface for the automatic watering system.

πŸ’‘i2c Interface

The i2c (inter-integrated circuit) interface is a two-wire serial communication protocol used to connect and control devices. In the script, the i2c module is used for the LCD to simplify the wiring and connection to the Arduino board.

πŸ’‘Relay Module

A relay module is an electrical switch that can be controlled by a low-power signal, used to control high-power devices like the water pump in the video. The Arduino sends a signal to the relay module to turn the water pump on or off based on the soil's moisture level.

πŸ’‘Water Pump

A water pump is a device that moves fluids, typically water, often used in irrigation systems. In the video, a small water pump is integrated into the system to automatically water the plants when the soil moisture level is too low.

πŸ’‘Jumper Wires

Jumper wires are used to create connections between electronic components without soldering. In the context of the video, jumper wires are essential for connecting the various components of the automatic watering system to the Arduino board.

πŸ’‘Analog Pin

An analog pin on an Arduino board can read continuous voltage levels, making it suitable for sensors that provide an analog output. In the video, the analog pin A0 is used to connect the soil moisture sensor, while A4 and A5 are used for the LCD module's SDA and SCL connections.

πŸ’‘Digital Pin

A digital pin on an Arduino board can be set to either a high or low state, used for digital signals. In the video, digital pin 7 is connected to the relay module to control the water pump, illustrating the use of digital pins for controlling devices.

πŸ’‘Circuit

A circuit refers to the path of electrical flow from a power source through various components and back to the source. The video describes the connections between the Arduino, soil moisture sensor, LCD module, relay module, and water pump to form a functional circuit for the automatic watering system.

πŸ’‘Code

Code in the context of the video refers to the programming script written for the Arduino board to control the automatic watering system. It includes logic to interpret sensor data and commands to activate or deactivate the water pump and update the LCD display.

Highlights

Introduction to the tutorial on adding an LCD module and a water pump to an Arduino project for an automatic plant watering system.

Explanation of the components needed including an Arduino board, soil moisture sensor, LCD module, relay module, water pump, and jumper wires.

Emphasis on using an I2C module for easier LCD connection.

Description of the connections starting with the Arduino 5V and ground for all components.

Connection details for the soil moisture sensor to the Arduino analog pin A0.

Instructions for connecting the LCD module to the Arduino, including the SDA and SCL pins.

Relay module connection to the Arduino and the significance of the signal input pin.

Water pump connection details, including the connection to the relay module.

Brief mention of a separate tutorial on the basics of relays.

Code review from a previous tutorial and the addition of logic for the water pump activation.

Explanation of the if-else statements used to evaluate soil moisture levels and activate the pump when dry.

Declaration of the relay pin and setting it as an output for pump control.

Demonstration of the pump activation when soil moisture is below a certain threshold.

Logic for keeping the pump off when soil is medium or wet.

Introduction of LCD logic to display soil and motor status.

Details on LCD initialization and status display for different soil conditions.

Demonstration of the system in action, showing the LCD updates and motor activation.

Final remarks on the system's ability to monitor moisture and trigger the motor automatically.

Invitation for viewers to ask questions in the comments and a prompt to visit the provided links for code and circuit details.

Transcripts

play00:01

[Music]

play00:02

foreign

play00:10

[Music]

play00:17

part of the Arduino tutorials

play00:19

in my previous video

play00:21

I have already explained the basic

play00:23

working of the soil moisture sensor and

play00:26

also we have done some basic code to

play00:29

read the moisture values from the soil

play00:34

so in continuation to that video

play00:37

we'll be additionally adding an LCD

play00:40

module to display the moisture content

play00:42

and also

play00:44

a small water pump to make an automatic

play00:47

plant watering system

play00:52

[Music]

play00:54

the components needed for this tutorial

play00:56

are Arduino board

play00:59

soil moisture sensor

play01:04

LCD module

play01:06

I am using this 16 Cross 2 module

play01:09

along with this iTunes interface so if

play01:12

you're planning to buy make sure

play01:14

you have this i2c module

play01:17

which makes your connection easier

play01:20

next we need a single Channel relay

play01:22

module

play01:26

a small water pump

play01:28

here I'll be using this nine volt one

play01:33

a power supply corresponding to your

play01:35

water pump

play01:39

and finally some jumper wires

play01:46

moving on to the connections

play01:48

I'll be taking the Arduino 5 volt and

play01:51

ground

play01:52

on the breadboard

play01:55

since we need it for all the components

play01:59

starting with the moisture sensor

play02:02

the VCC and ground

play02:05

goes to Arduino 5 volt and ground

play02:10

and the analog output pin a0

play02:13

is connected to Arduino

play02:15

analog pin a0

play02:20

on the LCD module

play02:23

the VCC and ground

play02:26

again goes to

play02:27

Arduino 5010 ground

play02:31

the SDA pin

play02:33

is connected to Arduino analog A4 pin

play02:37

and scl

play02:39

connected to Arduino analog pin A5

play02:46

moving to the relay module

play02:48

again the VCC ground

play02:52

is connected to Arduino 5 volt and

play02:53

ground

play02:56

and the signal input pin

play02:59

can be connected to any digital pin

play03:01

here I am using the digital pin 7.

play03:10

and moving to the last component the

play03:12

water pump

play03:15

so the negative terminal

play03:17

of the pump is connected to negative

play03:20

terminal of the battery

play03:23

the left out positive terminals

play03:26

of both

play03:31

will be connected to the relay module

play03:34

so one goes to the common terminal

play03:37

foreign

play03:40

should be connected to normally open

play03:42

Terminal

play03:45

so if you want to understand the basics

play03:47

of relay I have already made a separate

play03:49

tutorial you can check out

play03:53

that's it the connections if you face

play03:55

any difficulties follow the circuit link

play03:57

provided in the description box

play04:01

moving to the code

play04:03

here I have already opened the code from

play04:06

my previous tutorial

play04:07

here we have just read the sensor pin

play04:11

and using simple if else statements we

play04:15

have evaluated the values

play04:17

coming from the sensor

play04:19

so if it's greater than this value then

play04:22

there'll be no moisture and soil will be

play04:24

dry

play04:25

and if the values from the sensor is

play04:26

between this range then the soil is the

play04:29

medium condition and for less than 400

play04:32

it is wet

play04:33

so this condition checks remains same

play04:37

additionally we'll try adding the logic

play04:40

to activate the pump

play04:44

so in this three cases we have to just

play04:47

run the pump when soil is dry so I have

play04:50

to add

play04:51

the relay activation here in this first

play04:55

if statement

play04:57

before that we'll declare the pin we

play05:00

have connected the relay using in data

play05:02

type

play05:04

relay pin is connected to digital pin 7

play05:09

and also in the setup

play05:11

will set the pin mode

play05:13

as output

play05:22

so we have to use the digital write

play05:24

function

play05:26

when my sensor data is greater than 950

play05:28

it indicate soil is dry so I am

play05:32

activating the relay which

play05:35

indirectly

play05:37

starts the motor or the pump relay pin

play05:41

will make it high

play05:44

and coming to other conditions so here

play05:47

soil is medium

play05:49

so we have to

play05:52

keep our pump Switched Off

play05:55

same digital right

play05:58

but pump will be off

play06:03

also in the last statement it says soil

play06:06

is wet again we have to switch off the

play06:08

pump

play06:09

so same logic goes here as well

play06:13

that's all the logic for the pump

play06:17

will also add some logic to print some

play06:20

information on the LCD

play06:23

so here I'll not go in depth for the LCD

play06:26

commands

play06:28

you can refer to my previous tutorials

play06:30

to understand basics of LCD coding

play06:34

just

play06:36

including the header file

play06:42

and creating some object for this class

play06:49

also in the setup we have to call some

play06:51

initialization functions

play06:53

so all these Basics I have already

play06:55

explained in my previous tutorials

play06:59

I'm using 16 Cross to LCD

play07:02

so when it comes to this if statement

play07:06

I'll just show

play07:08

the status as soil is dry in the first

play07:12

row of the LCD

play07:16

in the second row of the LCD

play07:18

I'll give you information on the motor

play07:21

status here

play07:23

my motor will be on

play07:25

so I'll give motor on

play07:28

so I'll copy the same

play07:30

lines for other statements

play07:34

here

play07:35

the soil status will be medium

play07:40

and motor will be off

play07:46

and the last statement

play07:50

soil is wet

play07:55

and the motor will be off

play07:58

so that's all the logic

play08:00

for LCD

play08:04

I'll upload this and see how this works

play08:11

initially I have kept the battery

play08:13

disconnected

play08:15

for the water pump

play08:20

and I'll insert the sensor module into

play08:23

the pot

play08:24

in which the soil is already dry

play08:33

since the soil is dry on the LCD showing

play08:36

soil dry and also the motor on

play08:43

as soon as I connect the battery

play08:46

the motor started running

play08:52

[Music]

play08:54

so just for demonstration I'll add some

play08:56

water

play09:02

as soon as there is inner water

play09:05

the status

play09:06

shows soil is wet and also motor is off

play09:24

in this way the system monitors the

play09:27

moisture and whenever needed it triggers

play09:30

the motor automatically

play09:33

so that's all for this video

play09:35

if you have any doubts let me know in

play09:37

the comment section below

play09:39

for code and circuit visit the link in

play09:41

the description box

play09:44

thank you for watching and we'll be back

play09:46

in another interesting tutorial

play09:51

foreign

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
ArduinoLCD ModuleSoil MoistureSensorWater PumpAutomatic SystemDIY ProjectElectronics TutorialPlant CareI2C Interface