SWAPNILIOT
SWAPNILIOT
Internship report on
DOMAIN:-IOT
Abstract:
This project introduces an innovative automated plant watering system that
utilizes the power of a Raspberry Pi 3, precise soil moisture sensors, and
Proteus software. The main objective is to provide a practical solution to the
prevalent issue of neglecting to water plants regularly, leading to healthier and
thriving vegetation.
The system's core functionality involves detecting soil moisture levels in real-
time using strategically positioned soil moisture sensors. The Raspberry Pi 3,
functioning as the central control unit, continuously monitors the soil moisture
data and makes informed decisions to water the plants based on predefined
thresholds.
By automating the watering process, the project ensures that the plants
receive the optimal amount of water precisely when they need it, preventing
under or overwatering. The virtual simulation on Proteus software enables
thorough testing and validation of the hardware setup, guaranteeing a
seamless and reliable deployment in real-world scenarios.
With the integration of Python programming, Raspberry Pi 3, and Proteus
software, users are presented with an intuitive and user-friendly interface to
interact with the system, offering the flexibility to customize watering
schedules and monitor plant health effortlessly.
In conclusion, this automated plant watering system offers a sustainable and
efficient approach to plant care, promoting eco-conscious practices and
contributing to greener environments. The project's fusion of advanced
technology, practicality, and virtual simulation on Proteus marks a significant
step towards hassle-free and responsible gardening for enthusiasts and
hobbyists alike.
3|Page
TABLE OF CONTENTS
Abstract
Introduction…………………………………………………………………………………………… 5
1.1 Overview
1.2 Importance
1.3 Objectives
Soil Moisture-Based Plant Watering System………………………………………….. 7
2.1 Understanding Sensors
2.2 Hardware Setup (Proteus)
2.3 Working Principle
Existing Methods of Plant Watering……………………………………………………… 15
3.1 Manual Watering
3.2 Timer-Based Systems
3.3 Limitations
Proposed Method and Architecture……………………………………………………… 18
4.1 Automated Watering with Python
4.2 Integration of Sensors (Proteus)
4.3 Raspberry Pi and GPIO Setup (Proteus)
4.4 SPI Communication (Proteus)
Python Code Explanation……………………………………………………………………… 20
5.1 Initialization and LCD Display
5.2 Functions for Data and Commands
5.3 Reading Soil Moisture Levels
5.4 Controlling the Pump and Indicators
Calibration and Sensor Calibration………………………………………………………… 25
4|Page
1.INTRODUCTION
1.1 Objective of project :
The automated plant watering system using Python and soil moisture sensors is
a practical and innovative project that addresses the challenges associated with
manual plant care. Many plant enthusiasts, gardeners, and even commercial
farmers face difficulties in maintaining a consistent and effective watering
schedule for their plants. This project aims to provide a solution to this problem
by automating the process of watering plants based on the real-time moisture
level in the soil.
The heart of the system lies in the integration of soil moisture sensors with a
microcontroller, specifically a Raspberry Pi, which is programmed using
Python. The soil moisture sensors continuously measure the moisture content
of the soil, providing valuable data on whether the plants need water or not.
The Raspberry Pi processes this data and triggers a water pump to supply
water to the plants when the moisture level falls below a predefined threshold.
The system also incorporates an LCD display to provide users with instant
feedback on the soil moisture levels and the status of the watering process.
1.2 Importance of Automated Plant Watering:
Maintaining the right moisture level in the soil is crucial for the healthy growth
of plants. Underwatering can lead to stunted growth, wilting, and eventually,
the death of the plants, while overwatering can cause root rot and other
water-related issues. Manual watering can be a time-consuming and labor-
intensive task, especially for large gardens or agricultural fields. Moreover,
manual watering is prone to human error, as it relies on the memory and
availability of the person responsible for watering the plants.
The automated plant watering system addresses these challenges and offers
several significant advantages. Firstly, it ensures that the plants receive the
appropriate amount of water precisely when they need it, leading to improved
plant health and growth. Secondly, it reduces the burden of manual watering,
freeing up time for gardeners to focus on other important tasks. Thirdly, the
6|Page
In this section, we delve deeper into the concept of soil moisture sensors and
their pivotal role in the plant watering system. Soil moisture sensors are
essential devices designed to measure the water content in the soil accurately.
We provide a comprehensive overview of the various types of soil moisture
sensors commonly used in the industry, including resistive, capacitive, and
time domain reflectometry (TDR) sensors. Each type of sensor operates on a
unique principle, and we explain how these principles influence their
effectiveness in measuring soil moisture.
model to interface with the soil moisture sensors, process the data, and
control the watering system.
Decision-Making Logic:
Within the Python script running on the virtual Raspberry Pi, you can
implement the decision-making logic for automated watering. Based on
the readings from the soil moisture sensors, the script can analyze the
moisture levels and determine when and how much to water the plants.
When the ADC receives the analog voltage of 3 volts from Channel 3, it
internally converts this voltage into a digital value using its built-in
analog-to-digital conversion circuitry.
The ADC divides the analog voltage range (in this case, 0 to 3 volts) into
1024 equally spaced intervals (levels), and each interval is represented
by a unique 10-bit binary value.
This 10-bit binary code is then sent to the Raspberry Pi over the MISO
(Master In Slave Out) pin during the SPI communication.
For example, let's assume that the ADC generates a 10-bit binary code of
1001100110 to represent the analog voltage of 3 volts from Channel 3. This
binary code is what the spi.xfer2() function will read from the ADC and return
to the Raspberry Pi.
18 | P a g e
The Raspberry Pi can then use this 10-bit binary code to calculate the actual
voltage, as explained in the previous responses, using the formula:
where Raw Data is the 10-bit binary code received from the ADC, and Vref is
the reference voltage of the ADC (e.g., 5 volts). In this example, the actual
voltage calculated from the binary code 1001100110 will be approximately
2.98 volts, as previously shown.
3.EXISTING METHOD
3.1 Manual Plant Watering:
Manual plant watering is a traditional and widely practiced method of
providing water to plants. Gardeners and plant caregivers water the plants by
hand using watering cans, hoses, or spray bottles. The decision of when and
how much to water is typically based on the gardener's experience, visual
assessment of the plant's condition, and individual judgment.
Pros of Manual Plant Watering:
Direct Control: One of the main advantages of manual watering is the direct
control it offers to the gardener. They can tailor the watering process to meet
the specific needs of each plant based on factors such as plant type, soil
condition, and weather.
Suitable for Small-Scale Gardening: Manual watering is well-suited for small
home gardens, potted plants, or indoor planters where a more personalized
and hands-on approach is possible.
Low Upfront Cost: This method requires minimal equipment, making it a cost-
effective choice for individuals with small gardens or limited budgets.
Water Waste: Timer-based systems may lead to water wastage if plants do not
need water at specific times, especially if natural rainfall occurs. This can
contribute to inefficient water usage.
across the garden. Each plant may have unique watering needs that are not
adequately addressed.
In this section, we detail the virtual setup of the Raspberry Pi 3 and its GPIO
configuration within Proteus. We explain how the GPIO pins are utilized to
interface with the hardware components, such as the soil moisture sensor,
relay or motor driver module, and water pump.
We discuss the proper initialization of the GPIO pins and the necessary
configurations to ensure seamless communication between the Raspberry Pi
and the hardware components. The accurate representation of the Raspberry
Pi's GPIO setup in Proteus allows us to simulate the system's behavior
accurately, minimizing potential errors during the physical implementation.
soil_channel = 0
spi.open(0,0)
GPIO.setup([RS, EN, D0, D1, D2, D3, D4, D5, D6, D7,BUZ,LED,PUMP], GPIO.OUT)
time.sleep(0.2)
lcd_init()
lcd_command(0x80) # Move cursor to the beginning of the first line
lcd_print("WELCOME...")
lcd_command(0xC0) # Move cursor to the beginning of the second line
lcd_print("EXPOSYS DATA LABS")
lcd_command(0x80) # Move cursor to the beginning of the first line
lcd_print("SOIL MOIST LEVEL:-")
lcd_command(0xC0) # Move cursor to the beginning of the second line
lcd_print(" ")
lcd_command(0x94) # Move cursor to the beginning of the 3RD line
lcd_print("PUMP STATUS:-")
while 1:
soil_level = ReadChannel(soil_channel)
lcd_command(0xC0) # Move cursor to the beginning of the second line
lcd_print(str(soil_level))
lcd_command(0xD4) # Move cursor to the beginning of the fourth line
if(soil_level<400):
GPIO.output(BUZ,True)
GPIO.output(LED,True)
GPIO.output(PUMP,True)
lcd_print("ON")
else:
GPIO.output(BUZ,False)
GPIO.output(LED,False)
GPIO.output(PUMP,False)
lcd_print("OFF")
The LCD is initialized using the lcd_init() function, which sets the required
parameters for the display, such as 8-bit mode, 2-line display, and 5x7 font.
The function lcd_print() is defined to print strings on the LCD, and
lcd_command() and lcd_data() are used to send commands and data to the
LCD, respectively.
5.2 Functions for Sending Commands and Data to LCD:
The functions lcd_command() and lcd_data() are responsible for sending
commands and data to the LCD, respectively. These functions use the GPIO
pins to set the appropriate data bits (D0 to D7) and control signals (RS, EN) to
communicate with the LCD in 8-bit mode.
For example, the lcd_command() function sets the RS (Register Select) pin to
low to indicate command mode, and then it sets the appropriate data bits for
the command. The EN (Enable) pin is then toggled high and low to execute the
command.
5.3 Reading Soil Moisture Levels:
The function ReadChannel(channel) reads the analog voltage from the soil
moisture sensor connected to the MCP3008 ADC. It uses SPI communication to
request the conversion of the analog value and reads the digital result from
the ADC.
The MCP3008 ADC returns a 10-bit digital value representing the analog
voltage, which is then converted to the actual soil moisture level using the
ConvertTemp() function. This function scales the digital value to the
corresponding moisture level based on the sensor's calibration.
5.4 Controlling the Pump and Indicators:
The main part of the code consists of a while loop that continuously reads the
soil moisture level and controls the water pump and indicators accordingly.
Inside the loop, the soil moisture level is read using the ReadChannel()
function. If the moisture level is below a certain threshold (e.g., 400),
indicating that the plants need water, the water pump, buzzer, and LED are
turned on. This is achieved by setting the corresponding GPIO pins to high
using GPIO.output().
The LCD display is updated with the current soil moisture level and the status
of the water pump. The lcd_print() function is used to print the moisture level
27 | P a g e
on the LCD, and the lcd_command() function is used to move the cursor to
different positions on the display.
If the moisture level is above the threshold, indicating that the plants have
sufficient water, the water pump, buzzer, and LED are turned off, and the LCD
is updated to show the pump status as "OFF."
By combining all these elements, the Python code effectively controls the
automated plant watering system. The soil moisture sensors continuously
monitor the moisture levels in the soil, and the Raspberry Pi reads the data
through the MCP3008 ADC. Based on the moisture levels, the system
intelligently controls the water pump and indicators, ensuring that the plants
receive the appropriate amount of water when needed. The LCD display
provides real-time feedback on the soil moisture levels and the watering
process, making plant care more efficient and effective.
To calibrate the soil moisture sensor, you can perform the following steps:
28 | P a g e
a. Prepare different soil moisture levels: Arrange several samples of soil with
different moisture levels, ranging from very dry to saturated. Label each
sample with its respective moisture level (e.g., 0% for very dry, 100% for
saturated).
b. Insert the sensor into the soil: Insert the soil moisture sensor into each soil
sample and allow it to stabilize for a short period.
c. Record analog voltage readings: Using the ReadChannel() function in the
Python code, record the analog voltage readings from the sensor for each soil
sample.
d. Create a calibration curve: Plot the analog voltage readings against the
corresponding moisture levels to create a calibration curve. This curve will help
in mapping analog readings to moisture levels.
The calibration curve will allow you to convert the digital values obtained from
the ADC to actual moisture levels. With this calibration, you can accurately
determine the threshold at which the plants require watering and set the
appropriate moisture levels for activation and deactivation of the water pump.
The threshold value can be adjusted in the Python code. For example, in the
while loop of the code, you can set a condition to check if the soil moisture
level is below a certain value to activate the water pump:
python
Copy code
threshold = 400 # Set the moisture threshold for watering
29 | P a g e
while True:
soil_level = ReadChannel(soil_channel)
if soil_level < threshold:
# Watering condition
# Activate water pump and other indicators
GPIO.output(BUZ, True)
GPIO.output(LED, True)
GPIO.output(PUMP, True)
else:
# No watering needed
# Deactivate water pump and indicators
GPIO.output(BUZ, False)
GPIO.output(LED, False)
GPIO.output(PUMP, False)
By adjusting the threshold value, you can customize the watering behavior of
the system to meet the specific water needs of different plants or soil
conditions. A lower threshold will result in more frequent watering, while a
higher threshold will trigger watering only when the soil becomes drier.
Calibration and adjusting the watering threshold are crucial steps in the
implementation of the automated plant watering system. Proper calibration
ensures accurate readings from the soil moisture sensor, and adjusting the
threshold allows the system to provide the right amount of water at the right
time, promoting healthy plant growth and efficient water usage.
In this critical section, we focus on testing the entire system within the Proteus
simulation environment. We demonstrate how to run the Python script, which
31 | P a g e
emulates the automated watering process based on the soil moisture readings
from the virtual soil moisture sensor.
We analyze the system's responses to different scenarios, such as varying soil
moisture levels and predefined watering thresholds. The simulation enables us
to observe how the system triggers the water pump, waters the plants, and
manages the indicators based on the Python script's logic.
Furthermore, we address potential challenges and test the system's robustness
by simulating extreme conditions, such as very low or very high soil moisture
levels, to ensure its reliability and resilience.
7.3 Ensuring Proper Watering:
help in verifying that the system correctly identifies and responds to soil
moisture variations, providing a visual indication of successful watering.
Overall, this section guides the implementation and testing process within the
Proteus simulation environment, ensuring that the hardware is correctly
assembled, the system functions as intended, and proper watering strategies
are in place to maintain the health and well-being of the plants.
9. FUTURE ENHANCHEMENT:
The soil moisture-based automated plant watering system lays a strong
foundation for further improvements and enhancements. By incorporating
advanced technologies and features, the system can become even more
versatile and user-friendly. Here are some potential future enhancements for
the system:
34 | P a g e
10.CONCLUSION:
10.1 Summary of the Project:
In this concluding section, we provide a concise summary of the soil moisture-
based plant watering system project. We revisit the main objectives set at the
36 | P a g e
beginning of the project, emphasizing how the system aims to address the
common issue of forgetting to water plants regularly. We recap the key
components of the system, including the Raspberry Pi 3, soil moisture sensors,
Python programming, and Proteus software for virtual simulation.
We highlight the significance of automating the watering process to ensure
plants receive the right amount of water at the optimal time, leading to
healthier and thriving vegetation.
10.2 Achievements and Learnings:
Here, we reflect on the achievements and learnings gained throughout the
course of the project. We discuss the successful implementation of the
automated plant watering system and how it effectively meets the desired
objectives. We elaborate on the valuable insights acquired during the
development process, such as understanding the behavior of soil moisture
sensors, working with Python and Raspberry Pi, and utilizing Proteus for virtual
hardware simulation.
We acknowledge any challenges encountered during the project and how they
were overcome, providing a well-rounded view of the project's development
journey.
10.3 Final Thoughts:
In this final section, we offer concluding remarks and insights about the soil
moisture-based plant watering system. We express our appreciation for the
opportunities and knowledge gained during the project's execution. We
highlight the potential impact of the system in promoting sustainable plant
care practices and its contribution to greener and healthier environments.
We discuss the potential future applications and improvements that can be
made to enhance the system's functionality and scalability. Additionally, we
may mention how the project has inspired further exploration of automation
and smart solutions in other domains.
Overall, this section serves as a final reflection on the project, encapsulating its
achievements, lessons learned, and future possibilities. It reinforces the
significance of utilizing advanced technology, such as Python, Raspberry Pi, and
Proteus software, to foster innovative solutions for modern-day challenges.
37 | P a g e
References: