0% found this document useful (0 votes)
6 views34 pages

New Project Manager

Automatic irrigation system

Uploaded by

yadavkush2024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views34 pages

New Project Manager

Automatic irrigation system

Uploaded by

yadavkush2024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 34

AUTOMATIC IRRIGATION CONTROL

A Thesis
Submitted by

1. Abhiraj Kumar (21103149903)


2. Anil Kumar (21103149964)
3. Dharmendra kr. (21103149015)
4. Ishan Kumar (21103149993)
5. Kush Kumar (21103149992)
6. Pankaj Kumar (21103149949)

Under the Guidance of


Prof. Ajit Kumar Singh
Assistant Professor, Dept. of Electrical Engineering

To the

DEPARTMENT OF ELECTRICAL ENGINEERING


GOVERNMENT ENGINEERING COLLEGE, GOPALGANJ
August, 2024

GOVERNMENT ENGINEERING COLLEGE GOPALGANJ


DEPARTMENT OF ELECTRICAL ENGINEERING
CERTIFICATE

This is to certify that the Major Project entitled “Automatic Irrigation Control” submitted by Abhiraj Kumar
(21103149903), Anil Kumar (21103149964), Dharmendra Kumar (21103149015), Ishan (21103149993) Kush
Kumar (21103149992) and Pankaj Kumar (21103149949) of 8th semester in partial fulfillment of the
requirement for the award of degree of Bachelor of Technology in Electrical Engineering is a record of a major
project carried out by them under my supervision and guidance.

All help received by him from various sources have been duly acknowledged.
No part of this report has been submitted elsewhere for award of any other degree or diploma.

___________________________ ______________________

Prof. Ajit Kumar Singh Dr. Mosarrat Jahan

(Project Guide) (Head of Department)

Department Of Electrical Engineering Department of Electrical Engineering

___________________________

External Examiner

GOVERNMENT ENGINEERING COLLEGE, GOPALGANJ

DEPARTMENT OF ELECTRICAL ENGINEERING


DECLARATION
We hereby declare that the thesis entitled “Automatic Irrigation Control” submitted to Department of
Electrical Engineering, Government Engineering College, Gopalganj in partial fulfillment of the
requirements for the award of the Bachelor of Technology in Electrical Engineering in a record of
bonafide project work carried by Us, under the guidance of Supervisor Prof. Ajit Kumar Singh,
Assistant Professor, Government Engineering College Gopalganj. The matter presented in this
project has not been submitted by us for the award of any other degree elsewhere.

Abhiraj Kumar (21103149903)

Anil Kumar (21103149964)

Dharmendra Kumar (21103149015)

Ishan Kumar (21103149993)

Kush Kumar (21103149992)

Pankaj Kumar (21103149949)


ACKNOWLEDGEMENT
We would like to express our deep sense of gratitude and sincere thanks to my project supervisor Name
of supervisor, Assistant Professor, Department of Electrical Engineering, Government Engineering
College Gopalganj for being helpful and a great source of inspiration. He has provided me with great
insight and feedback every step of the way and as a result of that I have learned and grown personally
and professionally. His keen interest and constant encouragement gave me the confidence to complete
my work.

We are also grateful Dr. Ram Sagar Singh, Principle, Government Engineering College, Gopalganj,
Dr. Mosarrat Jahan, Assistant Professor and Head of Department Electrical Engineering,
Government Engineering College Gopalganj, for providing the necessary facilities in the department.

We are also grateful to all the faculty members, technical staffs of Electrical Engineering Department,
Government engineering college Gopalganj for all their useful suggestions and encouragements.

We would also like to extend our heartfelt gratitude to our project coordinator Mr. Amit Kumar,
Assistant Professor, Department of Electrical Engineering, Government Engineering College
Gopalganj, classmates and Lab technician who have encouraged me in every possible way to the
completion of the thesis. This dissertation would not have been possible without the help of several
individuals who extended their support in the completion of this study.

Abhiraj Kumar ( 21103149903)

Anil Kumar ( 21103149964)

Dharmendra Kumar ( 21103149015)

Ishan Kumar ( 21103149993)

Kush Kumar (21103149992)

Pankaj Kaumar (21103149949)


ABSTRACT
With the advancement of automation technology, life is getting simpler and easier in all aspects.
In today’s automatic system are being preferred over manual system. Automatic system is a
growing system of everyday object from industrial machine to customer goods thst can
complete tasks while we are busy in other activities.
India's population is reached beyond 1.2 billion and the population rate is increasing day by day
then after 25-30 years there will be serious problem of food, so the development of agriculture
is necessary. Today, the farmers are suffering from the lack of rains and scarcity of water. The
main objective of this paper is to provide an automatic irrigation system thereby saving time,
money & power of the farmer. The traditional farmland irrigation techniques require manual
intervention. With the automated technology of irrigation the human intervention can be
minimized.
Whenever there is a change in temperature and humidity of the surroundings these sensors
senses the change in temperature and humidity and gives an interrupt signal to the micro-
controller.
--
TABLE OF CONTENTS

Chapter Title Page No.

01 ENABLING TECHNOLOGIES
1.1 Introduction 01-04

1.2 Motivation

1.3 Literature Survey

1.4 Irrigation control system function

1.5 Advantage of Automatic irrigation control

02 PROPOSED SYSTEM HARDWARE AND


ARCHITECTURE

2.1 Component List

2.2 Arduino Uno

2.3 DHT11 Temperature and Humidity Sensor 05-14

2.4 Tiny RTC

2.5 Light Emitting Diode

2.6 Resistors

2.7 Relay Module

2.8 Diode

2.9 MOSFET

2.10 DC Motor

3.1 Result
03 3.2 Conclusion 15-16
3.3 Future Scope

Reference 17
Appendix 18-26
LIST OF TABLES

Table 1: Component list of proposed system 05

LIST OF FIGURES

Fig 1: Arduino uno architecture 06

Fig 2: Temperature & Humidity Sensor 08

Fig 3: Real Time Clock (RTC) 10

Fig 4: LED 11

Fig 5: Resistor 11

Fig 6: Relay Module 12

Fig 7: Connection Diagram of Relay with Arduino 12

Fig 8: Diode 13

Fig 9: MOSFET 13

Fig 10: DC Motor 14


CHAPTER 1: ENABLING TECHNOLOGIES

1.2 INTRODUCTION

Agriculture is a critical sector that sustains the livelihoods of millions and ensures food security for populations
worldwide. However, it faces numerous challenges, such as climate change, water scarcity, and the growing
demand for food due to an increasing global population. Efficient water management in agriculture is essential to
address these challenges, as irrigation consumes a significant portion of the world's freshwater resources.
Traditional irrigation methods often lead to water wastage due to over-irrigation, inefficient scheduling, and lack
of monitoring systems. These inefficiencies not only waste a precious resource but can also adversely affect crop
health and yield.

To optimize water usage and improve crop productivity, there is a growing need for intelligent irrigation systems
that can automatically monitor and control water distribution based on real-time data. This need has led to the
development of automatic irrigation control systems, which leverage advancements in sensor technology, data
analytics, and automation.

India is the country of village and agriculture plays an important role for development of country. In our country,
agriculture depends on the monsoons which has insufficient source of water. So the irrigation is used in
agricultural field In Irrigation system, depending upon the soil type, water is provided to plant. In agriculture,
two things are very important, first to get information of about the fertility of soil and second to measure
humidity content in air. Nowadays, for irrigation, different techniques are available which are used to reduce the
dependency of rain. And mostly this technique is driven by electrical power and on/off scheduling. In this
technique, an temperature and humidity sensors are placed near the plant and near the module and gateway
unit handles the sensor information and transmit data to the controller which in turns the control the flow of
water through the pump.

1.2 MOTIVATION

For continuously increasing demand and decrease in supply of food necessities, it’s important to rapid
improvement in production of food technology. Agriculture is only the source to provide this. This is the
important factor in human societies to growing and dynamic demand in food production. Agriculture plays the
important role in the economy and development, like India. Due to lack of water and scarcity of land water result
the decreasing volume of water on earth, the farmer use water.
LITERATURE SURVEY

Solar powered smart irrigation system

S Harishankar, RS Kumar, KP Sudharsan… - Advance in Electronic …, 2014 - researchgate.net

… 2. Literature Survey and Background Study According to the survey conducted by the
Bureau of …

1981. Small-scale solar powered irrigation pumping systems: technical and economic
review.

UNDP Project GLO/78/004.Intermediate Technology Power, London, UK …

Research on automatic irrigation control: State of the art and recent


results

R Romero, JL Muriel, I García… - Agricultural water …, 2012 - Elsevier

… We show a literature review of automatic … We present next a review of the contributions that
deal

not only on how to apply a particular irrigation … We have developed


an automatic irrigation controller

based on sap flow measurements (Fernandez et al., 2008a,b,c). The system was

Applied machine vision of plants: a review with implications for field


deployment in automated farming operations
CL McCarthy, NH Hancock, SR Raine - Intelligent Service Robotics, 2010 - Springer

… The literature to date indi- cates that achieving robust machine vision solutions in the field
environment … Jimenez A, Ceres R, Pons J (2000) A survey of computer vision methods for
locating
fruit … Fleck S, Nackaerts K, Muys B, Coppin P, Weiss M, Baret F (2004)

Large area hydrologic modeling and assessment part I: model development


JG Arnold, R Srinivasan, RS Muttiah… - JAWRA Journal of the …, 1998 - Wiley Online
Library

… LITERATURE REVIEW … Watershed modeling is funda- mental to integrated management.


Watershed models abound in the hydrological literature (Singh, 1989) and state-of- the-art
of
watershed modeling is reason- ably advanced … JAWRA Typical Evaporation
Depths Irrigation …
1.4 IRRIGATION CONTROL SYSTEM FUNCTION

 User Interface: User interface allow the user to inter act with the system by
sending information to the controller by presenting information to user about the
system. Its generally a computer or a smartphone
 Controlled Devices: Controlled devices include a wide range of equipment that
this arduino and sensor is capable of. Here in our project it is a motor.
 Programming Computer: Some system controllers allow the user to program
the system with the systems own user interface. Other system require PC to
program. Here we are accessing arduino IDE with the help of a PC.
 Controllers: Relay controllers provide the intelligent control functions in
automatic irrigation control.
 Sensing Devices: Sensing devices can report values, such as temperature and
humidity etc or states.
 I/O Interface Devices: These devices provide the logical communication link
between the controllers and the controlled device systems.
1.5 ADVANTAGES OF AUTOMATIC IRRIGAION CONTROL

Prevents Disease and Weeds


Specialized drip irrigation systems direct water specifically to each plant's root ball, rather than
sprinkling the entire garden like a typical rainstorm. As a result, surrounding weed seeds cannot
germinate, so you'll have less weeding to do. Water at the roots also prevents leaf diseases caused
by standing droplets on the foliage. Because the water does not strike the leaves or flowers, blight
diseases have no chance of proliferating.

Conserves Water and Time


Hand watering with a hose or watering can takes substantial time and early morning and evening
watering rituals take away from family and work. Both drip and sprinkler irrigation systems have
timers that can be preset for daily or weekly watering so you do not need to monitor the
watering because the timer shuts the water off when it has finished. Your water bill should be
lower if the irrigation system is effective.

Preserves Soil Structure and Nutrients


Watering with a wide open garden hose may allow too much water to seep into the soil. As a
result, nutrients leach out with the water runoff, leaving the plants with fewer nutrients available.
The soil may also become compacted when you water with a hose. Plants may show signs of
withering or root disease with suffocating, compacted soil. Using either drip or sprinkler irrigation
produces smaller droplets, helping to preserve nutrients and reducing soil compaction.

Gardening Flexibility
If you have a busy schedule, you'll appreciate being able to work in the garden at the same time as the
plants are being watered. While one garden section is being watered, you can plant and prune in another
area.
CHAPTER 2: PROPOSED SYSTEM HARDWARE AND
ARCHITECTURE

2.1COMPONENT LIST

SL NO NAME OF COMPONENTS QUANTITY

1 Arduino UNO 1

2 Real Time Clock 1

3 DHT11 Temperature and Humidity Sensor 1

4 Electric DC Motor 1

5 Relay Module 1

6 1 k Resistor 1

7 Power Supply cord for Arduino 1

8 MOSFET 1

9 Female Headers 10

10 Male Headers 10

11 Diode 1

12 Jumper wire 20

Table 1: Component list of proposed system


2.2ARDUINO

Arduino is an open source physical computing platform based on simple input/output


board and a development environment that implements the Processing language
(www.processing.org). Arduino can be used to develop standalone interactive objects or can
be connected to software on your computer. The boards can be assembled by hand or
purchased preassembled; the open source IDE(Integrated Development Environment) can be
downloaded for free from www.arduino.cc

2.2.1Introduction to Arduino Boards:

Arduino is an architecture that combines Atmel microcontroller family with standard


hardware into a board with inbuilt boot loader for plug and play embedded programming.
Arduino Software comes with an IDE that helps writing, debugging and burning program
into Arduino. The IDE also comes with a Serial Communication window through which can
easily get the serial data from the board.

Fig 1: ARDUINO UNO ARCHITECTURE

2.2.2Pin Description of Arduino Uno:

The Uno is a microcontroller board based on the ATmega328P. It has 14


digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a
16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset
button. Each of the 14 digital pins can be used as an input or output, using pin Mode
(), digital Write (), and digital Read () functions. They operate at 5 volts. Each pin can
provide or receive 20 mA as recommended operating condition and has an internal
pull-up resistor (disconnected by default) of 20-50k ohm. A maximum of 40mA is the
value that must not be exceeded on any I/O pin to avoid permanent damage to the
microcontroller. In addition, some pins have specialized
functions:
Serial: 0(RX) and 1(TX). Used to receive (RX) and Transmit (TX) TTL serial
data.
External Interrupts: 2 and 3. These pins can be configured to trigger an
interrupt on a low value, a rising or falling edge, or a change in value.
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analog Write()
function.
SPI: 10(SS), 11(MOSI), 12(MISO), 13(SCK). These pins
support SPI communication using the SPI library.
LED: 13. There is a built-in LED driven by digital pin 13.
TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using
the wire library.
The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of
resolution. By default they measure from ground to 5 volts, through is it possible to
change the upper end of their range using the AREF pin and the analog Reference ()
function.
There are a couple of other pins on the board:

AREF Reference voltage for the analog inputs. Used with analog Reference.
Reset. Bring this line LOW to reset the microcontroller. Typically used to add a
reset button to shields which block the one on the board.
2.3DHT11 TEMPERATURE AND HUMIDITY SENSOR

DHT11 digital temperature and humidity sensor is a composite Sensor contains a


calibrated digital signal output of the temperature and humidity. Application of a dedicated
digital modules collection technology and the temperature and humidity sensing technology,
to ensure that the product has high reliability and excellent long-term stability. The sensor
includes a resistive sense of wet components and an NTC temperature measurement devices,
and connected with a high-performance 8-bit microcontroller.

They consist of a humidity sensing component, a NTC temperature sensor (or


thermistor) and an IC on the back side of the sensor. For measuring humidity they use the
humidity sensing component which has two electrodes with moisture holding substrate
between them. So as the humidity changes, the conductivity of the substrate changes or the
resistance between these electrodes changes. This change in resistance is measured and
processed by the IC which makes it ready to be read by a microcontroller.

On the other hand, for measuring temperature these sensors use a NTC temperature
sensor or a thermistor. A thermistor is actually a variable resistor that changes its resistance
with change of the temperature. These sensors are made by sintering of semi conductive
materials such as ceramics or polymers in order to provide larger changes in the resistance
with just small changes in temperature. The term “NTC” means “Negative Temperature
Coefficient”, which means that the resistance decreases with increase of the temperature.

Fig 2: Temperature & Humidity Sensor.


Features of DHT11

 It measures both air temperature and moisture.

 Relative humidity expressed as a percentage.

 HS1100 is used for sensing humidity.

 The output in terms of frequency range 5khz to 10khz.


2.4REAL TIME CLOCK (RTC)

Real time clocks (RTC), as the name recommends are clock modules. The DS1307 real
time clock (RTC) IC is an 8 pin device using an I2C interface. The DS1307 is a low-power
clock/calendar with 56 bytes of battery backup SRAM. The clock/calendar provides seconds,
minutes, hours, day, date, month and year qualified data. The end date of each month is
automatically adjusted, especially for months with less than 31 days.

They are available as integrated circuits (ICs) and supervise timing like a clock and also
operate date like a calendar. The main advantage of RTC is that they have an arrangement of
battery backup which keeps the clock/calendar running even if there is power failure. An
exceptionally little current is required for keeping the RTC animated. We can find these
RTCs in many applications like embedded systems and computer mother boards, etc.
Fig 3: Real Time Clock (RTC

Working of DS1307:

In the simple circuit the two inputs X1 and X2 are connected to a 32.768 kHz crystal
oscillator as the source for the chip. VBAT is connected to positive culture of a 3V battery
chip. Vcc power to the I2C interface is 5V and can be given using microcontrollers. If the
power supply Vcc is not granted read and writes are inhibited.
2.5 LIGHT EMITTING DIODE (LED)

A light-emitting diode (LED) is a two-lead semiconductor light source. It is a p- n


junction diode that emits light when activated. When a suitable voltage is applied to the leads,
electrons are able to recombine with electron holes within the device, releasing energy in the
form of photons. This effect is called electroluminescence, and the colour of light
(corresponding to the energy of the photon) is determined by the energy band gap of the
semiconductor. LEDs are typically small (less than 1 mm2) and integrated optical
components may be used to shape the radiation pattern.

2.6 RESISTORS

A resistor is a passive two-terminal electrical component that implements electrical


resistance as a circuit element. In electronic circuits, resistors are used to reduce current flow,
adjust signal levels, to divide voltages, bias active elements, and terminate transmission lines,
among other uses. High-power resistors that can dissipate many watts of electrical power as
heat may be used as part of motor controls, in power distribution systems, or as test loads for
generators. Fixed resistors have resistances that only change slightly with temperature, time
or operating voltage. Variable resistors can be used to adjust circuit elements (such as a
volume control or a lamp dimmer), or as sensing devices for heat, light, humidity, force, or
chemical activity.

Fig 5: Resistor
2.7RELAY MODULE

Relay is an electromagnetic device which is used to isolate two circuits electrically


and connect them magnetically. They are very useful devices and allow one circuit to switch
another one while they are completely separate. They are often used to interface an electronic
circuit (working at a low voltage) to an electrical circuit which works at very high voltage.
For example, a relay can make a 5V DC battery circuit to switch a 230V AC mains circuit.
Thus a small sensor circuit can drive, say, a fan or an electric bulb.

Fig 6: Relay Module Fig 7: Connection Diagram of Relay

with Arduino

A relay switch can be divided into two parts: input and output. The output section has
a coil which generates magnetic field when a small voltage from an electronic circuit is
applied to it. This voltage is called the operating voltage. Commonly used relays are available
in different configuration of operating voltages like 6V, 9V, 12V, 24V etc. the output section
consists of contactors which connect or disconnect mechanically. In a basic relay there are
three contactors: normally open (NO), normally closed (NC) and common (COM). At no
point state, the COM is connected to NC. When the operating voltage is applied the relay coil
gets energized and the COM changes contact to NO.
2.8DIODE (IN4148)

In electronics, a diode is a two-terminal electronic component that conducts primarily in one direction
(asymmetric conductance), it has low (ideally zero) resistance to the flow of current in one direction,
and high (ideally infinite) resistance in the other. A semiconductor diode is a crystalline piece of
semiconductor material with a p-n junction connected to two electrical terminals

Fig 8: Diode

2.9MOSFET

The 2TN7000 MOSFET is an N-channel, enhancement-mode MOSFETs used for low-power


switching applications, with different lead arrangements and current ratings.
The 2N7000 is a widely available and popular part, often recommended as useful and
common components to have around for hobbyist use.

Fig 9: MOSFET
2.10DC MOTOR

A DC motor is any of a class of rotary electrical machines that converts direct current
electrical energy into mechanical energy. The most common types rely on the forces
produced by magnetic fields. Nearly all types of DC motors have some internal mechanism,
either electromechanical or electronic, to periodically change the direction of current flow in
part of the motor.

DC motors were the first type widely used, since they could be powered from existing
direct-current lighting power distribution systems. A DC motor's speed can be controlled
over a wide range, using either a variable supply voltage or by changing the strength of
current in its field windings. Small DC motors are used in tools, toys, and appliances.

Fig 10: DC Motor


CHAPTER 3
3.1 RESULT
As result we observe that waterpump runs automatically when there is need of water in the farming land or
garden due to the low value of humidity then the set value.

By this automation of the waterpump we can do other productive work and can save time, money and also
water. This system makes our farming easy and convenient. Where not need of human interference for the
irrigation. It has programmed microcontroller based Ardiuno to gather the information from different devices like
temperature sensor , real time clock and control the operation of pump. At the end we save too much of our time
and money as well as water. Also our plants in the farm will get the required amount of water for their growth.
3.2 CONCLUSION
The automatic irrigation control using arduino uno has been experimentally proven to work
satisfactorily and we could successfully set the timer and managed to control the motor over
time.This process not only records values of temperature and humidity it also controls the motor
accordingly.Analyzing the weather condition motor will automatically maintain water supply
making it possible to maintain greenery without human intervention.

3.3 FUTURE SCOPE


Using this system as framework,the system can be expanded to include various other options
which could include mobile application control of motor and wi fi controlled monitoring. These
will expand the working capability and efficiency of this prototype.It can be implemented not in
agriculture but in gardens in any places using the sprinkler concept.It has a vast scope when it
is mixed with IOT .Automation will get a new dimension through this.
REFERENCE
References / Bibliography 1. Attar, S., & Sudhakar, K. N. Real-Time
Monitoring Of Agricultural Activities Using Wireless Sensor Network

1. .Awasthi, A., & Reddy, S. R. N. (2013). Monitoring for Precision Agriculture using
Wireless Sensor Network-A review. GJCST-E: Network, Web & Security, 13(7).
2.Bhadane, G., Sharma, S., & Nerkar, V. B. (2013). Early Pest Identification in Agricultural
Crops using Image Processing Techniques. International Journal of Electrical, Electronics
and Computer Engineering, 2(2), 77-82.
3. Galande, M. S., & Agrawal, D. G. (2013). Embedded Controlled Drip Irrigation System.
International Journal of Emerging Trends & Technology in Computer.
4.Google and other internet sources.
APPENDIX
#include <Wire.h> // Wire library, used by RTC library

#include "RTClib.h" // RTC library

#include "DHT.h" // DHT temperature/humidity sensor library

// Analog pin usage

const int RTC_5V_PIN = A3; const

int RTC_GND_PIN = A2;

// Digital pin usage

const int DHT_PIN = 2; // temperature/humidity sensor

const int NUMBEROFTIMES = 2;

int onOffTimes[NUMBEROFTIMES];

const int ONTIME = 0;

const int OFFTIME = 1;

#define DHTTYPE DHT11

DHT dht(DHT_PIN, DHTTYPE); // Create a DHT object

RTC_DS1307 rtc; // Create an RTC object

DateTime dateTimeNow; // to store results from the RTC

// to store humidity result from the DHT11 sensor

float humidityNow;

void setup(){

// Power and ground to RTC

pinMode(RTC_5V_PIN, OUTPUT);

pinMode(RTC_GND_PIN, OUTPUT);
digitalWrite(RTC_5V_PIN, HIGH);

digitalWrite(RTC_GND_PIN, LOW);

// Initialize the wire library

#ifdef AVR

Wire.begin(); #else

// Shield I2C pins connect to alt I2C bus on Arduino Due Wire1.begin();

#endif

rtc.begin(); // Initialize the RTC object

dht.begin(); // Initialize the DHT object

Serial.begin(9600); // Initialize the Serial object

// Set the water valve pin numbers into the array

// and set those pins all to outputs

pinMode(8, OUTPUT);

};

void loop() {

// Remind user briefly of possible commands

Serial.print("Type 'P' to print settings or ");

getTimeTempHumidity();

// Check for request from the user checkUserInteraction();

// Check to see whether it's time to turn any valve ON or OFF checkTimeControlValves();

// No need to do this too frequently

delay(5000)

}
void getTimeTempHumidity() {

// Get and print the current time

dateTimeNow = rtc.now();

if (! rtc.isrunning()) { Serial.println("RTC

is NOT running!");

rtc.adjust(DateTime( DATE , TIME ));

return;

Serial.print(dateTimeNow.hour(), DEC); Serial.print(':');

Serial.print(dateTimeNow.minute(), DEC); Serial.print(':');

Serial.print(dateTimeNow.second(), DEC); humidityNow =

dht.readHumidity

// Read temperature as Celsius float

t = dht.readTemperature();

// Read temperature as Fahrenheit float f

= dht.readTemperature(true).

if (isnan(humidityNow) || isnan(t) || isnan(f)) {

Serial.println("Failed to read from DHT sensor!");

return; // if the DHT is not running don't continue;

Serial.print(" Humidity ");


Serial.print(humidityNow);

Serial.print("% ");

Serial.print("Temp ");

Serial.print(t); Serial.print("C

"); Serial.print(f);

Serial.print("F");

Serial.println();

} // end of getTimeTempHumidity:

void checkUserInteraction() {

// Check for user interaction while

(Serial.available() > 0) { char temp

= Serial.read();
if ( temp == 'P') {

printSettings();

Serial.flush(); break;

// If first character is 'S' then the rest will be a setting else

if ( temp == 'S') {

expectValveSetting();

else

printMenu();

Serial.flush();

break;

void expectValveSetting() {

char onOff = Serial.read();

int desiredHour = Serial.parseInt(); if

(Serial.read() != ':') {

Serial.println("no : found"); // Sanity check

Serial.flush();

return;
}

int desiredMinutes = Serial.parseInt(); int

desiredMinutesSinceMidnight

= (desiredHour*60 + desiredMinutes); if (

onOff == 'N') { // it's an ON time

onOffTimes[ONTIME]

= desiredMinutesSinceMidnight;

else if ( onOff == 'F') { // it's an OFF time

onOffTimes[OFFTIME]

= desiredMinutesSinceMidnight;

else { // user didn't use N or F

Serial.print("You must use upper case N or F ");

Serial.println("to indicate ON time or OFF time");

Serial.flush();

return;

printSettings();

}
void checkTimeControlValves() {

int nowMinutesSinceMidnight =

(dateTimeNow.hour() * 60) + dateTimeNow.minute();

// Now check the array for each valve Serial.print("Valve

");

Serial.print(" is now ");

if ( ( nowMinutesSinceMidnight >= onOffTimes[ONTIME])

&&

( nowMinutesSinceMidnight <

onOffTimes[OFFTIME]) ) {

// Before we turn a valve on make sure it's not raining if (

humidityNow > 80 ) {

// It's raining; turn the valve OFF

Serial.print(" OFF ");

digitalWrite(8, LOW);

else {

// No rain and it's time to turn the valve ON

Serial.print(" ON ");

digitalWrite(8, HIGH);

} // end of checking for rain


}

else {

Serial.print(" OFF ");


digitalWrite(8, LOW);

Serial.println();

// end of looping over each valve

Serial.println();

void printMenu() {

Serial.println(

"Please enter P to print the current settings");

void printSettings(){ Serial.println();

{ Serial.print("Valve ");

Serial.print(" will turn ON at ");

Serial.print((onOffTimes[ONTIME])/60); Serial.print(":");

Serial.print((onOffTimes[ONTIME])%(60)); Serial.print("

and will turn OFF at ");

Serial.print((onOffTimes[OFFTIME])/60); // hours

Serial.print(":"); Serial.print((onOffTimes[OFFTIME])
%(60)); // minutes Serial.println();

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy