This document describes an Arduino Nano-based soil moisture sensing system. It uses a soil moisture sensor connected to an Arduino Nano to measure soil moisture levels and control a solenoid valve and irrigation system. The system objectives are to understand Arduino programming for irrigation control, set up an Arduino Nano irrigation system using a soil moisture sensor, write code for the Arduino to control the system based on sensor data, run and test the system, and troubleshoot any issues.
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
40 views
Laboratory Exercise 3
This document describes an Arduino Nano-based soil moisture sensing system. It uses a soil moisture sensor connected to an Arduino Nano to measure soil moisture levels and control a solenoid valve and irrigation system. The system objectives are to understand Arduino programming for irrigation control, set up an Arduino Nano irrigation system using a soil moisture sensor, write code for the Arduino to control the system based on sensor data, run and test the system, and troubleshoot any issues.
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 48
ABEN 4512 - LABORATORY EXERCISE
#3
ARDUINO NANO SOIL
MOISTURE - SENSING SYSTEM GROUP #3: ABAN, NICOLE CABALAR, JOHNNIEL DAR, GABRIEL FRANCISCO FERIA, MARL CHRISTIAN G O N Z A L E S , M A RY J A N E SOLMERIN, CHRISTINE INTRODUCTION Water is essential for life, and plants are no exception. Plants rely on water for their survival just as animals do. Water is necessary for photosynthesis, which is how plants use energy from the sun to create their own food.
The quantity of water that plants need depends on
several factors: • type of plant • climate • soil conditions INTRODUCTION Traditionally, plants are typically watered daily, often several times a day to ensure they receive an adequate supply of moisture. However, this traditional method of watering demands manual intervention, which can be a time-consuming and inefficient process.
There are a number of automated irrigation systems that
can be used to water crops more efficiently. These systems can be programmed to water the crops at specific times and for specific lengths of time. Automated irrigation systems can help to improve water use efficiency, reduce labor costs, and improve crop yields. OBJECTIVES
1. Understand the concept of Arduino programming in terms of
automated irrigation systems;
2. Set up an Arduino Nano-based irrigation system that uses a
soil moisture sensor to control the watering;
3. Write a code for the Arduino Nano to control the irrigation
system based on the soil moisture sensor data;
4. Run and test the Arduino Nano-based irrigation system; &
5. Identify and troubleshoot any potential problems with the
system. MATERIALS & METHODS BREADBOARD
Developing an electronic circuit and
wiring for projects with microcontroller boards like Arduino. ARDUINO UNO BOARD
A low cost, flexible, and easy-to-use
programmable open source microcontroller board that can be integrated into a variety of electronic projects. And it can control relays, LEDs, servos, and motors as an output. CAPACTIVE SOIL MOISTURE SENSOR
Determines the amount of soil moisture
by measuring changes in capacitance to determine the water content of soil. This can be used in an automatic plant watering system or to signal an alert of some type when a plant needs watering. SOLENOID VALVE
Control units which, when electrically
energized or de-energized, either shut off or allow fluid flow. POWER SUPPLY
A power supply adapter that provides
from 7 to 12V(Volts) of DC (Direct Current) is required. Make sure the power adapter complies with your Arduino board specification. JUMPER WIRES
Jump wires are used for making
connections between items on the breadboard and Arduino’s header pins. LCD DISPLAY
An easy-to-use display module, It can
make display easier. Using it can reduce the difficulty of make, so that makers can focus on the core of the work. RELAY BOARD
A relay is an electrically operated switch
that can be turned on or off, letting the current go through or not, and can be controlled with low voltages, like the 5V provided by the Arduino pins. Controlling a relay module with the Arduino is as simple as controlling any other output. USB CABLE FOR ARDUINO NANO
The Cable for Arduino Nano (USB 2.0 A
to USB 2.0 Mini B) 30cm Connects speed-critical devices, such as smartphones and peripherals that require a Mini-B connection to your computer. CIRCUIT CONNECTIONS EXPERIMENTAL PROCEDURE EXPERIMENTAL PROCEDURE The following step-by-step approach was used to design, build, and test an Arduino Nano- based soil moisture-sensing system. A flow chart is used to utterly establish the plan of action regarding the experiment from initial set up to the final output of the system. RESULTS & DISCUSSIONS Arduino programming for automated irrigation involves the utilization of an Arduino microcontroller for the operation and supervision of an irrigation system designed for plants, gardens, or agricultural fields. This method enables the automation of the plant watering process, taking into account multiple factors like soil moisture levels, prevailing weather conditions, and personalized watering timetables. Programming plays a pivotal role in enhancing the efficiency, accuracy, and effectiveness of an irrigation system when working with an Arduino Nano. In the initial stages, coding imparts the intelligence required for automating the watering process. By crafting code for the Arduino Nano microcontroller, users can configure the system to make informed decisions regarding the timing, quantity, and duration of watering for their plants.
Additionally, coding enables the seamless integration of diverse
sensors and data inputs into the irrigation system. Soil moisture sensors, temperature sensors, humidity sensors, and even weather forecasts can all be seamlessly incorporated into the system. Moreover, coding empowers the utilization of conditional statements and decision-making logic within the system, a fundamental aspect of efficient water management. Through coding, you can establish rules and conditions that the system must follow. For instance, you can stipulate that the system should exclusively initiate watering when the soil moisture level drops below a specific threshold. ARDUINO CODE FOR CONTROLLING THE SYSTEM Below is the Arduino Nano code provided to manage an irrigation system by establishing specific thresholds for determining soil moisture levels, whether it is wet or dry. Library & Defining • The Arduino constant code presented here is created for a soil moisture monitoring system. • It makes use of a soil moisture sensor, an I2C-connected Liquid Crystal Display (LCD), and a relay to regulate plant watering according to the soil's moisture content. • The code starts by importing two crucial libraries: "Wire.h" for I2C communication and "LiquidCrystal_I2C.h" for interacting with the LCD screen. It proceeds to create an instance of the LiquidCrystal_I2C library, setting the I2C address of the LCD (0x27) and defining its dimensions as 16 columns and 2 rows. Library & Defining constant • The ‘A0’ is defined as the ‘sensorPin’, indicating the Analog 0 pin to which the soil moisture sensor is connected from the breadboard. Then, the wet and dry threshold are set as constants, representing the criteria for determining soil moisture content. • The ‘sensorValue’ stores the analog reading from the soil moisture sensor. Next is the ‘percentage’, in which it holds the calculated moisture percentage. Then the ‘relayPin’ in which is connected to Digital pin 13 that controls a relay to activate or deactivate the watering system. Setup Function • In the setup function, the initial step is to invoke pinMode(13, OUTPUT). This particular line holds significant importance in the code since it establishes the configuration of digital pin 13 as an output. Within the scope of this project, pin 13 serves a pivotal function as it governs a relay's operation. Relays, functioning as electrically operated switches, are responsible for determining whether the plant is supplied with water. By designating pin 13 as an output, the code guarantees the system's ability to transmit signals to the relay, enabling it to either initiate or halt the watering procedure. Setup Function • Serial communication plays a vital role in the debugging and performance monitoring of an Arduino-based system. Within the setup function, Serial.begin(9600) is utilized to initiate serial communication, operating at a baud rate of 9600. The baud rate specifies the data transmission speed between the Arduino and any connected device. The purpose of initializing serial communication is to enable the code to send real-time messages, alerts, and sensor data to a connected computer. The ability to relay information from the Arduino to an external device is particularly valuable in ensuring that the system operates. Setup Function
• In the setup function, the next set of instructions focuses
on initializing the LCD display. This is done through the lines lcd.init() and lcd.backlight(). This step is crucial for ensuring that the LCD screen is prepared to present information to the user effectively. The lcd.init() function serves to set up the display, making it ready to receive and showcase text and data. Following this, lcd.backlight() is employed to activate the LCD's backlight, ensuring that the displayed information is clearly visible to the user. Setup Function • In addition, lcd.setCursor(0, 0) is used to position the cursor at the top-left corner of the LCD screen. This action specifies where the information will be displayed on the screen. The code is now poised to exhibit data and messages precisely where they are intended to appear. To provide users with immediate clarity regarding the system's purpose, the setup function concludes by presenting an initial message: "Soil Moisture Meter." This message serves as a welcoming introduction, communicating to the user that the system is fully prepared to monitor soil moisture levels and provide relevant feedback. Loop Function • In the loop function, a crucial role is managing the watering process and updating the LCD display based on the "humedad" variable, representing soil moisture. If "humedad" is 450 or higher, indicating sufficient moisture, the LCD displays the moisture percentage, and the watering relay is set to "LOW," signifying no further watering is needed. On the other hand, if "humedad" falls below 450, showing insufficient moisture, the LCD updates with the moisture percentage, and the relay is activated to "HIGH," initiating the necessary watering for plant health and growth. • In the loop function, a significant aspect is ensuring the user remains informed about the soil's moisture condition. This is accomplished through conditional statements that assess the "percentage" variable, representing the calculated moisture level. When the percentage is under 20%, denoting extremely dry soil, the LCD is updated with a straightforward directive, "Water the plant!" In the 20% to 50% range, indicating moderately dry soil, the LCD provides the message "The soil is dry," gently reminding the user to monitor the plant's water needs. When the percentage exceeds 50%, signaling healthy soil with sufficient moisture, the LCD conveys the message "Soil is healthy," affirming that the plant's water requirements are • Finally, towards the end of the loop function, a one-second delay [delay(1000)] is added to ensure system stability and prevent abrupt shifts in data and message. This delay determines how frequently readings and messages are updated, ensuring that the system's replies are ordered and understandable. The loop function's core essence is its never-ending repeating. The loop function restarts after each repetition of reading, calculation, control, and display. This recurrent pattern provides continuous monitoring and updating of the soil's moisture state, supplying critical information to the user and enabling automated watering control. PROBLEMS ENCOUNTERED 1. Confusion in Library to be used:
• The code establishes various constants and variables related
to soil moisture and pin configurations. Yet, there exist inconsistencies in variable naming (e.g., sensorPin and SensorPin), which can lead to confusion and potential errors when referring to these variables. 2. Establishing the thresholds:
• In this code, there is a discrepancy between the comments
and the actual code. The comments mention "wetThreshold" and "dryThreshold," but these variables are not defined or used in the code. This can lead to confusion and might not provide accurate moisture level measurements. A resolution involves assigning appropriate values to these thresholds, enabling the system to recognize wet and dry soil conditions effectively. 3. No coding error but the soil moisture status won’t display on the LCD and Serial monitor: • Despite the absence of apparent coding errors (i.e., the code does not generate error messages), the soil moisture status fails to display correctly on both the LCD and the Serial monitor. This situation typically indicates a logical or functional issue within the code, or a disparity between anticipated and actual outcomes. Possible logic errors in the code may hinder the accurate calculation or display of the soil moisture status. In cases where the code does not format the data correctly before presenting it on the LCD or Serial monitor, the result may not align with the intended presentation. CONCLUSION & RECOMMENDATION CONCLUSION After conducting the laboratory experiment, the following are the established conclusions:
• Understanding Arduino programming is essential for
implementing automated irrigation systems. The concept of Arduino programming enables the development of code that controls the irrigation system based on sensor data. • The setup of an Arduino Nano-based irrigation system utilizing a soil moisture sensor is an effective approach. This system intelligently regulates watering based on the real- time moisture readings from the soil sensor.
• Writing code for the Arduino Nano microcontroller to
interpret and respond to soil moisture sensor data is a critical step. This code enables the irrigation system to make informed decisions about watering, optimizing water usage and promoting efficient irrigation practices. • The running and testing of the Arduino Nano-based irrigation system is crucial to ensuring its functionality and reliability. By monitoring the system's performance, accuracy of soil moisture readings, and validation of irrigation actions, potential issues can be identified and resolved.
• Identifying and troubleshooting potential problems with the
system is an ongoing process. Regular monitoring and evaluation of the irrigation system allow for the detection and resolution of any issues that may arise, ensuring its continuous and optimal operation Therefore, we conclude that the Arduino Nano soil moisture- sensing system has various practical applications in the agricultural industry. It offers an automated solution for irrigation, reducing manual labor and ensuring accurate watering based on specific soil moisture requirements. This technology can be used in large-scale farming operations, greenhouses, and even home gardens. The effectiveness of the Arduino Nano soil moisture-sensing system lies in its ability to optimize water usage by providing water only when necessary. This not only conserves water but also promotes healthier plant growth and minimizes the risk of overwatering or underwatering. RECOMMENDATI ON Upon conducting this laboratory activity exercise, some problems were also encountered by the students. Thus, the following recommendations are suggested based on the work achieved during the activity:
• Refinement of Variable Naming and Comments: Ensure
consistent variable naming conventions to prevent confusion in the code. Comments should accurately reflect the variables and their purposes. RECOMMENDATI ON • Clarification of Threshold Definitions: Define and utilize the "wetThreshold" and "dryThreshold" variables in the code to establish clear parameters for soil moisture levels.
• Expand Testing Scenarios: Encourage students to experiment
with different soil types, plant species, and environmental conditions to assess the system's adaptability and performance under diverse circumstances. RECOMMENDATI ON • Incorporate Additional Sensors: Introduce other environmental sensors (e.g., temperature, humidity) to expand the system's capabilities and enhance its responsiveness to varying conditions.
• Implement Wireless Communication: Explore the integration of
wireless communication modules (e.g., Bluetooth, Wi-Fi) to enable remote monitoring and control of the irrigation system. THANK YOU FOR LISTENING!