Major Report Final

Download as pdf or txt
Download as pdf or txt
You are on page 1of 70

DETECTION OF PESTICIDE IN APPLE AND ALERTING

THROUGH MESSAGE

A Dissertation submitted in partial fulfillment of the requirements


for the award of degree of

BACHELOR OF TECHNOLOGY
IN

ELECTRONICS & COMMUNICATIONS ENGINEERING


Submitted By
SWETHA AMIREDDY (20251A04H5)
KURUVA VAISHNAVI (20251A04D3)
PANTHAM APURVA (20251A04G7)
VULLI VARSHINI (20251A04F0)

Under the esteemed guidance of


Mrs Ch. Anusha, Assistant Professor, ECE, GNITS (FOR WOMEN)

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGG


G. NARAYANAMMA INSTITUTE OF TECHNOLOGY & SCIENCE
(for women)
(AUTONOMOUS)
ACCREDITED by NBA & NAAC
2023-2024

GNITS-ECE DEPT
DEPT. OF ELECTRONICS & COMMUNICATION ENGG

CERTIFICATE

THIS IS TO CERTIFY THAT THE PROJECT ENTITLED

DETECTION OF PESTICIDE IN APPLE AND ALERTING


THROUGH MESSAGE

IS THE BONAFIDE WORK OF

SWETHA AMIREDDY 20251A04H5


KURUVA VAISHNAVI 20251A04D3
PANTHAM APURVA 20251A04G7
VULLI VARSHINI 20251A04F0

SUBMITTED IN PARTIAL FULFILMENT OF THE REQUIREMENT FOR THE


AWARD OF DEGREE OF BACHELOR OF TECHNOLOGY IN ELECTRONICS
ANDCOMMUNICATION ENGINEERING DURING THE YEAR 2023-2024

GUIDE
Mrs Ch. Anusha Dr. K. Ragini
Assistant Professor HOD, ECE

External Examiner

GNITS-ECE DEPT
ACKNOWLEDGEMENTS

We would like to thank Mrs. Ch. Anusha, our guide, and our project coordinator
Mrs. N. Krishna Jyothi, for being a constant source of inspiration. They challenged us
to use our imagination and encouraged us to do this project without delay. We were able
to complete this project because of their comprehensive knowledge, broad experience,
and professional expertise in the subject. Without their assistance and direction, this
endeavor would not have been possible. In our academic endeavors, we could not have
asked for a better mentor.

We would like to express our profound gratitude to Dr. K. Ragini, HOD of


Electronics and Communication Engineering department and Dr. K. Ramesh Reddy,
principal of G. Narayanamma Institute of Technology and Science, for their
contributions to the completion of our project. Without the support of each and every
person, this project would not have been a success.
Finally, we would like to thank our families, siblings, and friends for their
essential help. We also want to thank everyone who has helped with this project being
completed successfully.

SWETHA AMIREDDY 20251A04H5


KURUVA VAISHNAVI 20251A04D3
PANTHAM APURVA 20251A04G7
VULLI VARSHINI 20251A04F0

GNITS-ECE DEPT
INDEX
S. No. Topic Page No.
Abstract i
List of Figures ii
Acronyms iii
1. Introduction
1.1 Literature Survey 1
1.2 Plan of work 5
1.3 Problem statement 5
1.4 Hardware and Software used 6
2. Hardware Requirements
2.1 Arduino 7
2.1.1 Arduino UNO 7
2.1.1.1 General and special pin 8
functions
2.1.1.2 Arduino UNO pin configuration 10
2.1.2 Arduino Nano 11
2.3 LCD Display 12
2.4 LDR Sensor 13
2.5 MQ2 Gas Sensor 14
2.6 IR Sensor 15
2.7 GSM 16
2.7.1 GSM Modem 16
2.7.2 GSM Integration 18
2.8 Buzzer 23
3. Software Requirements
3.1 Arduino Software 25
3.2 Arduino Installation 25
3.3 Arduino Sketch 28
3.4 Arduino Sketch Program Flow 29
3.5 Working Sketch 30
3.6 How to run a Sketch 31
4. Implementation
4.1 Block Diagram 32
4.2 Working 33
5. Results and Discussions 36
GNITS-ECE DEPT
6. Advantages and Disadvantages
6.1 Advantages 40
6.2 Disadvantages 41
7. Applications 43
8. Conclusion and Future scope
8.1 Conclusion 45
8.2 Future scope 45
9. References 48
10. Appendix 49

GNITS-ECE DEPT
ABSTRACT

Many modern techniques were developed to produce more quantity of food for growing
population. Now a day fruits and vegetables have become the major source of nutrients and
energy. Many chemicals are used in the production of fruits and vegetables, which are
dangerous for consumers. To identify pesticides in organic fruits and vegetables, it is necessary
to build low-cost, portable, sensitive, and selective biosensing platform. Many sensors like
nano-sensors, pH sensors, humidity and temperature sensors and gas sensors are used to detect
the pesticides on the fruits and vegetables. The input data is taken from sensors and send to the
microcontroller where the program is written in such a way that it calculates the amount of
pesticide present on fruits and display the output.
The software for this project is written in Arduino c program. The safe value of
pesticides in fruits or vegetables which can be consumed by humans and animalsare mentioned
in the Arduino c program. If the pesticide content is above or below the threshold level then the
sample contains pesticides. Developing an alert system that triggers messages when pesticide
levels surpass predefined thresholds. The message is sent through proper communication
channels such as SMS, mobile app to the stakeholders such as farmers,distributors, retailers,
and consumers by using GSM modem.

i
GNITS-ECE DEPT
LIST OF FIGURES

S. No Fig. No Name of the figure Pg. No

1. 2.1 Pin description of Arduino UNO 9


2. 2.2 Arduino UNO Board 10
3. 2.3 Arduino Nano Board 11
4. 2.4 LCD Display 13
5. 2.5 LDR Sensor 14
6. 2.6 MQ2 Gas Sensor 14
7. 2.7 IR Sensor 15
8. 2.8 GSM Modem 17
9. 2.9 GSM Module SIM900A 19
10. 2.10 USB 20
11. 2.11 Adapter 22
12. 2.12 Buzzer 23
13. 3.1 Arduino Nano Cable 26
14. 3.2 Function of each symbol appearing in 27
theArduino IDE toolbar.
15. 3.3 Arduino Sketch Window 28

16. 3.4 Writing Sketch Window 30

17. 3.5 Arduino IDE Serial Monitor Window 31


18. 4.1 Block Diagram 32
19. 5.1 Proposed System 36
20. 5.2 Displaying Pesticide value in LCD 37
21. 5.3 Sending Alert Message 38
22. 5.4 Alert Message Acknowledgement 38
23. 5.5 Alert Message 39

ii

GNITS-ECE DEPT
ACRONYMS
S. No Abbreviations Full form
1. UNO “One” in Italian

2. IDE Integrated Development Environment

3. LDR Light Dependent Resistors

4. IR Infrared sensor

5 LCD Liquid Crystal Display

6. CPU Central Processing Unit

7. LED Light Emitting Diode

8. CRT Cathode Ray Tube


Metal oxide semiconductor type
9. MQ2 gas sensor
10. CSR Control and Status Register

iii

GNITS-ECE DEPT
1. INTRODUCTION
The population is growing very fast but the land for growing food is same. Hence many
technologies are developed to produce more food for growing population. Chemical fertilizers,
insecticides and pesticides are used to enhance the yield production. But consuming these
pesticides and chemical though food can lead to many dangerous diseases like cancer and even
death in worst conditions. But many are adopting the organic forming, integrated forming
system and many newer technologies to improve the fruits and vegetables quality. The fruits
and vegetables grown using the organic methods coast double the amount of the normal
vegetables and fruits. Producers selling fertilized fruits and vegetables by labeling as organic
fruits and vegetables. This can be dangerous to the consumers. Hence detection of the pesticides
on organic fruits and vegetable plays a major role in agriculture sectors.
The accessible traditional techniques for recognition 1esticidee incorporate mass
spectroscopy, gas chromatography, fluid chromatography, elite execution fluid
chromatography and protein connected invulnerable spongy measure. Despite the fact that
these procedures are exact and solid, they require high support and working expenses, logical
research center, gifted labor, huge example volume and are tedious. By and by we want to foster
a detecting stage, which requires fewer examples, less reaction time and which is easy to use,
minimal expense, adaptable and versatile.
1.1 Literature Survey
Title-1: Artificial Intelligence and IoT based detection of pesticide in organic fruits and
vegetables.
Author: John R. Thompson
Description: The implementation of Internet of Things (IoT) technologies for the accurate and
efficient detection of pesticide residues in various fruits and vegetables. The study explores the
integration of advanced sensor networks with IoT platforms to enable continuous monitoring
and real-time analysis of pesticide levels. Utilizing a combination of optical andelectrochemical
sensors, the system is designed to detect and quantify specific pesticide compounds present in
agricultural produce. The collected data are transmitted wirelessly to a centralized platform for
processing and analysis. The paper discusses the experimental methodology, sensor calibration
techniques, and data processing algorithms employed to ensure the reliability and accuracy of
the detection system. Through comprehensive field trials and validation studies, the
effectiveness of the IoT-based approach in detecting and monitoring pesticide content in fruits
and vegetables is demonstrated, highlighting its potential for enhancing food safety and
agricultural practices. In the realm of pesticide detection techniques, recent studies have
GNITS ECE-DEPT 1
explored diverse methodologies. One proposal suggests gas chromatography spectrometry
analysis for measuring pesticide levels in fruits, acknowledgingits drawbacks as a costly, slow,
and less readily available method. On the other hand, another study suggests using an Arduino
and an electrochemical oxygen sensor for pest detection, highlighting a significant
disadvantage due to the constant exposure to oxygen, which decreases the sensor's lifespan.
Another approach involves a three-step methodology, includingconverting RGB to grayscale,
image segmentation using median filtering and morphological approaches, and feature
extraction and classification from images. Additionally, there are benefits to edge-based
algorithms, which produce noisy discontinuous edges, necessitating more intricate processing
after obtaining results, and segmentation through image conversion to the HSV color space and
fuzzy c-means clustering.
Title-2: Identification of Chemicals in Fruits and Vegetables using IOT
Authors: Akula Venkata Narayana, Bolla Jawahar Sri Veera Sai Suraj, Yallavula Sai Prakash.
Description: In the broader context of precision agriculture, literature can be categorized into
three main subsections: IoT/Sensors and Networks, Data Analytics, and Applications of IoT
and Data Analytics in Agriculture. The first section provides an overview of technologies such
as IoT, machine learning, and data analytics, along with discussions on wirelesscommunication
protocols like Zigbee, LoRa, NB-IoT, and Wi-Fi. The Data Analyticssubsection delves into
the use of machine learning algorithms for processing and analyzingdata from IoT devices,
recognizing challenges related to sensor accuracy, data security, andinteroperability. The third
section explores case studies and implementations in pesticidedetection, considerations of
regulatory compliance, environmental impact assessment, andfuture trends. Moving on to
disease detection and classification, various projects have proposedinnovative solutions. One
focus is on the detection of leaf diseases by calculating leaf area through pixel number
statistics, aiming to increase throughput and reduce subjectivity arisingfrom human experts.
Another suggests a segmentation process using the K-means clustering algorithm, feature
extraction through Grey Level-Co-occurrence Matrix (GLCM), andmulticlass Support Vector
Machine (SVM) classification for identifying potato diseases. Another approach involves an
Android application for plant disease identification, where users upload leaf images, and
algorithms process the images to identify the type of disease. Acomprehensive description
of leaf disease detection using image processing techniquesemphasizes critical analysis of
different segmentation techniques. Focusing on rice disease identification using pattern
recognition, another study employs an improved and customized.

GNITS ECE-DEPT 2
Deep Convolutional Neural Network (DCNN) model. Additionally, a proposed system
involves image acquisition, pre-processing, feature extraction, artificial neural network-based
training, classification, and diagnosis for disease identification and treatment. Lastly, an online
tracking system for monitoring soybean disease and insect infection patterns in Nebraska
provides farmers with valuable insights for decision-making, while exploring nonlinear models
to analyze the combined effects of temperature and wetness duration on foliar parasites.
Title-3: IoT- Deep Learning based Prediction of amount of Pesticides and Diseases in Fruits
Authors: D. Devi, Akshaya Anand, M. Karpagam.
Description: IoT coupled with deep learning has emerged as a powerful tool in agricultural
technology, particularly in predicting pesticide levels and diseases in fruits. The integration of
IoT devices, such as sensors capable of detecting chemical compositions and disease
symptoms, forms the foundation of data collection. These sensors, ranging from spectroscopy
to biosensors, provide real-time data on pesticide residue levels or signs of diseases in fruits.
Research in this area focuses on the accuracy, sensitivity, and reliability of these sensors under
diverse environmental conditions, crucial for effective prediction models.
Deep learning algorithms, notably convolutional neural networks (CNNs) and recurrent
neural networks (RNNs), play a pivotal role in processing the data collected from IoT devices.
These algorithms are trained on extensive datasets to recognize patterns and correlations
between various factors influencing pesticide levels or disease occurrence in fruits. Their ability
to learn from complex data sets enables accurate predictions and early identification ofpotential
issues affecting fruit quality and safety. Furthermore, the deployment of thesepredictive models
in real-time IoT systems brings actionable insights to farmers and stakeholders. By analyzing
the data collected by IoT sensors, these models offer predictions and alerts regarding potential
pesticide excesses or emerging diseases in fruit crops. This proactive approach enables timely
interventions, aiding in better agricultural practices and cropmanagement strategies. However,
despite the promising advancements, challenges persist. Data quality, interpretability of deep
learning models, scalability, and the cost of deploying IoT sensors on a large scale remain
significant hurdles. Ensuring the accuracy and robustness of these predictive models against
real-world observations is essential for their practical application in agriculture.
Looking ahead, ongoing research explores innovative sensor technologies, improved
deep learning architectures, and enhanced integration of IoT systems with other agricultural
technologies. The goal is to create more comprehensive and efficient frameworks for predicting

GNITS ECE-DEPT 3
pesticide levels and diseases in fruits.
Title-4: Prediction of pesticides and identification of diseases in fruits using IoT
Authors: M. Uday Madhav, D. Naga Jyothi, P. Kalyani.
Description: The amalgamation of Support Vector Machine (SVM) and IoT technology holds
promise in predicting pesticide levels and identifying diseases in fruits. SVM, a supervised
machine learning algorithm, has demonstrated effectiveness in classification tasks and
regression analysis, making it suitable for handling datasets generated by IoT sensors. In this
context, IoT devices equipped with various sensors collect crucial data on pesticide residues
and disease symptoms present in fruits. These sensors, ranging from spectrometers to imaging
devices, gather diverse information that forms the basis of the dataset used to train the SVM
model. The data includes spectral signatures, chemical compositions, and visual cues indicative
of pesticide presence or disease onset in fruits. SVM algorithms process this multidimensional
data to create predictive models capable of classifying or predicting the levels of pesticides and
identifying potential diseases in fruits. SVM's ability to delineate complex data patterns and
establish decision boundaries makes it adept at handling the intricacies of agricultural data
collected through IoT sensors. Through careful training and optimization, the SVM model
learns to differentiate between healthy and affected fruits or categorize pesticide levels within
specific thresholds. By leveraging these predictive models, stakeholders can receive timely
alerts about potential pesticide excesses or emerging diseases, enabling proactive measures to
mitigate risks and optimize agricultural practices. However, challenges persist, including
ensuring the accuracy and generalizability of SVM models across different fruit types and
environmental conditions. Data quality, feature selection, and model optimization remain
crucial aspects for enhancing the reliability and applicability of SVM-based predictions in
agricultural settings. As research in this field progresses, efforts focus on refining SVM
algorithms, optimizing feature extraction from IoT sensor data, and addressing scalability
issues for widespread adoption. The ultimate goal is to create robust, accurate, and adaptable
predictive models that significantly contribute to sustainable farming practices and ensure the
safety and quality of fruits produced.
Title-5: Rapid detection Methods of Pesticides Residues in Vegetable Foods
Authors: Bahman Fazeli-Nazab, Laleh Shahraki-Mojahed, Maryam Beigomi.
Description: Rapid detection methods for pesticide residues in vegetable foods have seen
significant advancements, leveraging innovative technologies to ensure swift and accurate

GNITS ECE-DEPT 4
analyses. Techniques such as chromatography-based methods, including HPLC and GC-
MS/MS, have evolved to offer high sensitivity and specificity, allowing for quicker detection
with improved limits of detection. Complementing these established methods, immunoassays,
biosensors, and electrochemical sensors have emerged as rapid on-site testing tools, enabling
quick screening of pesticide residues in vegetables. Their portability and simplicity facilitate
convenient field-based analyses, ensuring timely assessment of food safety. Moreover, the
integration of advanced technologies like surface-enhanced Raman spectroscopy (SERS), near-
infrared spectroscopy (NIRS), multispectral imaging, and miniaturized portable devices has
revolutionized the landscape of pesticide residue detection. SERS and NIRS offer rapid, non-
destructive analyses, while miniaturized devices and smartphone-integrated sensors provide
accessible, real-time screening capabilities. These technologies collectively contribute to the
efficiency and effectiveness of food safety protocols, facilitating prompt detection of pesticide
residues in vegetable foods. Continued research in this area aims to further refine these
methods, enhancing their speed, sensitivity, and practicality for widespread application in
ensuring the safety and quality of vegetable produce for consumers.
1.2 Plan of work
 Understanding and integrating sensors
 IOT Integration
 Build the Arduino based hardware
 Data collection and analysis
 Testing the hardware with apple 
1.3 Problem Statement
Detecting pesticides in fruits is crucial for ensuring food safety and minimizing health
risks. Pesticides, while aiding in crop protection, can pose potential health hazards if present in
excessive amounts in our food. Various methods, from chromatography to spectroscopy, are
employed to analyze and quantify pesticide residues in vegetables. The ongoing research and
advancements in detection methodologies continue to refine our ability to monitor and regulate
pesticide levels in vegetables, safeguarding public health and well- being. In this project we are
using Embedded system along with IR sensor, LDR sensor and MQ-2 sensor for the detection
of Pesticide in Apple.

GNITS ECE-DEPT 5
1.4 Hardware and Software used
 Arduino UNO
 LCD Display
 LDR Sensor
 MQ2 gas Sensor
 IR Sensor
 GSM
 Buzzer
 Arduino IDE (Software)























 





GNITS ECE-DEPT 6
2. HARDWARE DESCRIPTION
2.1 Arduino
Arduino is a project, open-source hardware, and software platform used to design and
build electronic devices. The designs of Arduino boards use a variety of controllers and
microprocessors. The Arduino board consists of sets of analog and digital I/O (Input / Output)
pins, which are further interfaced to breadboard, expansion boards, and other circuits. Such
boards feature the model, Universal Serial Bus (USB), and serial communication interfaces,
which are used for loading programs from the computers.
2.1.1 Arduino UNO
Arduino 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 ceramic
resonator, a USB connection, a power jack, an ICSP header and a reset button. It contains
everything needed to support the microcontroller; simply connect it to a computer with a USB
cable or power it with a AC-to-DC adapter or battery to get started. The Arduino UNO pin
description is as shown in fig. 2.3.
“Uno" means one in Italian and was chosen to mark the release of Arduino Software
(IDE) 1.0. The Uno board and version 1.0 of Arduino Software (IDE) were the reference versions
of Arduino, now evolved to newer releases. The Uno board is the first in a series of USB Arduino
boards, and the reference model for the Arduino platform; for an extensive list of current, past or
outdated boards see the Arduino index of boards.
The Arduino Uno has a number of facilities for communicating with a computer, another
Arduino board, or other microcontrollers. The ATmega328 provides UART TTL (5V) serial
communication, which is available on digital pins 0 (RX) and 1 (TX).
The Arduino UNO can be programmed using the Arduino IDE. The Arduino IDE is the
Integral Development program, which is common to all the boards. We can also use Arduino
Web Editor, which allows us to upload sketches and write the code from our web browser
(Google Chrome recommended) to any Arduino Board. It is an online platform. The USB
connection is essential to connect the computer with the board. After the connection, the PWR
pins will light in green. It is a green power LED.

GNITS ECE-DEPT 7
Technical Specifications are:
 Microcontroller: ATmega38P – 8 bit AVR family microcontroller

 Operating Voltage: 5V

 Recommended Input Voltage: 7-12V

 Input Voltage Limits: 6-20V

 Analog Input Pins: 6 (A0-A5)

 Digital I/O Pins: 14 (Out of which 6 provide PWM output)

 DC Current on I/O Pins: 40mA

 DC Current on 3.3V Pin: 50mA

 Flash Memory: 32 KB (0.5 KB is used for Bootloader)

 SRAM: 2kB

 EEPROM: 1kB
 Frequency (Clock Speed): 16MHz
2.1.1.1 General and Special Pin Functions
Arduino UNO Pinout contains 14 digital pins, 6 analog Pins, 2 Reset Pins & Power Pins.
Each of these Digital & Analog Pins are assigned with multiple functions but their main function
is to be configured as input or output. The analog pins come with a total resolution of 10bits
which measure the value from zero to 5V. They are acted as input pins when they are interfaced
with sensors, but if you are driving some load then use them as output. As shown in Fig 2.1 each
pin on the UNO board comes with a specific function associated with it.
 LED - Arduino Uno comes with built-in LED which is connected through pin 13.
Providing HIGH value to the pin will turn it ON. Providing LOW will turn it OFF.
 Vin - It is the input voltage provided to the Arduino Board. This pin is used to supply
voltage. It is different than 5V supplied through a USB port. If a voltage is provided
through power jack, it can be accessed through this pin.
 5V - This board comes with the ability to provide voltage regulation. 5V pin is used to
provide output regulated voltage. The board is powered up using three ways i.e. USB,
Vin pin of the board or DC power jack. USB supports voltage around 5V while Vin and
Power Jack support a voltage range between 7V to 20V.
 GND - These are ground pins. There are more than one ground pins are provided on the

GNITS ECE-DEPT 8
board. They can be used as per requirement.
 Reset -This pin is incorporated on the board which resets the program running on the
board. Instead of physical reset on the board, IDE comes with a feature of resetting the
board through programming.
 IOREF -It is the abbreviation of Input Output Voltage Reference. This pin is very useful
for providing voltage reference to the board. A shield is used to read the voltage across
this pin which then select the proper power source.
 PWM – Pulse Width Modulation is provided by 3, 5, 6, 9, 10, 11 pins. These pins are
configured to provide 8-bit output PWM.
 SPI - It is abbreviation of Serial Peripheral Interface. Four pins 10(SS), 11(MOSI),
12(MISO), 13(SCK) provide SPI communication with the help of SPI library.
 AREF - It is called Analog Reference. This pin is used for providing a reference voltage
to the analog inputs.
 TWI - It is called Two-Wire Interface. TWI communication is accessed through Wire
Library. A4 and A5 pins are used for this purpose.
 Serial Communication - Serial communication is carried out through two pins called Pin
0 (Rx) and Pin 1 (Tx).
 Rx. & Tx. - Rx (Receiver) pin is used to receive data while Tx (Transmitter) pin is used
to transmit data.
 External Interrupts - Pin 2 and 3 are used for providing external interrupts. An interrupt
is called by providing LOW or changing value.

Fig. 2.1 Pin description of Arduino UNO

GNITS ECE-DEPT 9
2.1.1.2 Arduino Uno Pin Configuration:

 Serial Pins 0 (Rx) and 1 (Tx): Rx and Tx pins are used to receive and transmit TTL serial
data. They are connected with the corresponding ATmega328P USB to TTL serial chip.
 External Interrupt Pins 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 Pins 3, 5, 6, 9 and 11: These pins provide an 8-bit PWM output by using analogWrite()
function.
 SPI Pins 10 (SS), 11 (MOSI), 12 (MISO) and 13 (SCK): These pins are used for SPI
communication.
 In-built LED Pin 13: This pin is connected with an built-in LED, when pin 13 is HIGH – LED
is on and when pin 13 is LOW, it’s off.
 Along with 14 Digital pins, there are 6 analog input pins, each of which provide 10 bits of
resolution, i.e. 1024 different values. They measure from 0 to 5 volts but this limit can be
increased by using AREF pin with analog Reference() function.
 Analog pin 4 (SDA) and pin 5 (SCA) also used for TWI communication using Wire library.
Arduino Uno has a couple of other pins as explained below:
 AREF: Used to provide reference voltage for analog inputs with analogReference()
function.
 Reset Pin: Making this pin LOW, resets the microcontroller.

Fig. 2.2 Arduino UNO Board

GNITS ECE-DEPT 10
2.2 Arduino Nano
The Arduino Nano is a small, complete, and breadboard-friendly board based on the
ATmega328 (Arduino Nano 3.x) as shown in Fig. 2.3. It has more or less the same functionality
of the Arduino Duemilanove, but in a different package. It lacks only a DC powerjack, and works
with a Mini-B USB cable instead of a standard one. Arduino Nano is simply a smaller version of
Arduino UNO, thus both has almost same functionalities. Arduino Nano comes with a crystal
oscillator of frequency 16 MHz. It is used to produce a clock of precise frequency using constant
voltage. Flash memory is 16KB or 32KB that all depends on the Atmega board i.e Atmega168
comes with 16KB of flash memory while Atmega328 comes with a flash memory of 32KB. Flash
memory is used for storing code. The 2KB of memory out of total flash memory is used for a
bootloader. The Arduino Nano is equipped with 30 maleI/O headers, in a dip like configuration,
which can be programmed using the Arduino Software integrated development environment
(IDE), which is common to all Arduino boards and running both online and offline. The board
can be powered through a type-b micro-USB cable,or through a 9V battery.

Fig. 2.3 Arduino Nano Board

GNITS ECE-DEPT 11
Technical specifications are:
 Microcontroller: ATmega38
 Architecture: AVR
 Operating Voltage: 5V
 Flash Memory: 32KB of which 2KB used by bootloader
 SRAM: 2KB
 Clock Speed: 16MHZ
 Analog I/O Pins: 8
 EEPROM: 1KB
 DC Current per I/O Pins: 40mA (I/O Pins)
 Input Voltage: 7-12V
 Digital I/O Pins: 22
 PWM Output: 6
 Power Consumption: 19mA
 PCB Size: 18 x 45 mm
 Weight 7g

2.3 LCD Display


LCD (Liquid Crystal Display) is a type of flat panel display which uses liquid crystals in
its primary form of operation. LEDs have a large and varying set of use cases for consumers
and businesses, as they can be commonly found in smartphones, televisions, computer monitors
and instrument panels.
LCDs were a big leap in terms of the technology they replaced, which include light-
emittingdiode (LED) and gas-plasma displays. LCDs allowed displays to be much thinner than
cathode ray tube (CRT) technology. LCDs consume much less power than LED and gas-display
displays because they work on the principle of blocking light rather than emitting it. Where an
LED emitslight, the liquid crystals in an LCD produces an image using a backlight.

A display is made up of millions of pixels. The quality of a display commonly refers to


thenumber of pixels; for example, a 4K display is made up of 3840 x2160 or 4096x2160 pixels.
A pixel is made up of three subpixels; a red, blue and green commonly called RGB.

GNITS ECE-DEPT 12
When the pixels are rapidly switched on and off, a picture is created. The way a pixel is
controlled is different in each type of display; CRT, LED, LCD and newer types of displays all
control pixels differently. In short, LCDs are lit by a backlight, and pixels are switched on and
offelectronically while using liquid crystals to rotate polarized light. A polarizing glass filter is
placedin front and behind all the pixels, the front filter is placed at 90 degrees. In between both
filters arethe liquid crystals, which can be electronically switched on and off.

Fig. 2.4 LCD Display


2.3 LDR Sensor
LDR (Light Dependent Resistor) as the name states is a special type of resistor that
works on the photoconductivity principle means that resistance changes according to the
intensity of light. Its resistance decreases with an increase in the intensity of light. The Light-
dependent resistors made with photosensitive semiconductor materials like Cadmium Sulphides
(CdS), leadsulfide, lead selenide, indium antimonide, or cadmium selenide and they are placed
in a Zig-Zag shape. Two metal contacts are placed on both ends of the Zig-Zag shape these metal
contacts helpin creating a connection with the LDRs.
Now, a transparent coating is applied on the top so that the zig-zag-shaped
photosensitivematerial gets protected and as the coating is transparent the LDR will be able to
capture light fromthe outer environment for its working.
It works on the principle of photoconductivity whenever the light falls on its
photoconductive material, it absorbs its energy and the electrons of that photoconductive
materialin the valence band get excited and go to the conduction band and thus increasing the
conductivityas per the increase in light intensity.

GNITS ECE-DEPT 13
Also, the energy in incident light should be greater than the bandgap gap energy so that
electrons from the valence band got excited and go to the conduction band. The LDR has the
highest resistance in dark around 1012 Ohm and this resistance decreases with increase Light.

Fig. 2.5 LDR Sensor


2.4 MQ2 Gas Sensor
The MQ2 sensor is one of the most widely used in the MQ sensor series. It is a MOS
(Metal Oxide Semiconductor) sensor. Metal oxide sensors are also known as Chemiresistors
because sensing is based on the change in resistance of the sensing material when exposed to
gasses.
The MQ2 gas sensor operates on 5V DC and consumes approximately 800mW. It can
detect LPG, Smoke, Alcohol, Propane, Hydrogen, Methane and Carbon
Monoxide concentrations ranging from 200 to 10000 ppm.

Fig. 2.6 MQ2 Gas sensor


GNITS ECE-DEPT 14
When a SnO2 semiconductor layer is heated to a high temperature, oxygen is adsorbed
onthe surface. When the air is clean, electrons from the conduction band of tin dioxide are
attractedto oxygen molecules. This creates an electron depletion layer just beneath the surface
of the SnO2particles, forming a potential barrier. As a result, the SnO2 film becomes highly
resistive and prevents electric current flow.
2.5 IR Sensor
IR sensor is an electronic device, that emits the light in order to sense some object of
the surroundings. An IR Sensor can measure the heat of an object as well as detects the motion.
Usually,in the Infrared spectrum, all the objects radiate some form of thermal radiation. These
types of radiations are invisible to our eyes, but infrared sensor can detect these radiations.

Fig. 2.7 IR Sensor

There are five basic elements used in a typical infrared detection system: an infrared source,
a transmission medium, optical component, infrared detectors or receivers and signal processing.
Infrared lasers and Infrared LEDs of specific wavelength used as infrared sources. The three main
types of media used for infrared transmission are vacuum, atmosphere and optical fibres. Optical
components are used to focus the infrared radiation or to limit the spectral response.

GNITS ECE-DEPT 15
2.7 GSM

In modern agriculture, ensuring the safety of fruits and vegetables by monitoring


pesticide levels is of paramount importance. The "Pesticide Monitoring and Alert System" is
designed to analyze pesticide content in agricultural produce and provide real-time alerts to
relevant stakeholders. One key feature of this system is the integration of a GSM (Global
System for Mobile Communications) modem, enabling efficient communication and timely
dissemination of critical information. This project acknowledges the delicate balance between
agricultural productivity and consumer safety.
Implementation of an alert system that triggers messages based on the results of
pesticide content analysis. If the analysis indicates that the pesticide levels exceed safe limits,
the system uses the GSM modem to send alerts. The GSM modem sends SMS messages to
relevant stakeholders, such as farmers, distributors, or consumers. The messages can convey
information about the pesticide levels, potential health risks, and any necessary actions to be
taken.
2.7.1 GSM MODEM
A GSM modem is a device that allows electronic devices to communicate with each
other over the GSM network. GSM is a standard for digital cellular communications, which
means that it provides a platform for mobile devices to communicate with each other
wirelessly. The GSM module is a specialized device that enables a device to send and receive
data over the GSM network.
The GSM network is an essential component of modern communication systems. It is
a standard used by mobile devices to communicate with each other wirelessly. The GSM
network provides a reliable and secure platform for communication, which makes it a preferred
choice for many applications.
GSM modems typically use serial communication interfaces such as RS232 or USB to
connect to a computer or microcontroller. They communicate using AT commands, which are
standard instructions for controlling modems. GSM modems require a SIM (Subscriber Identity
Module) card to authenticate with the mobile network. The SIM card stores information about
the subscriber, such as the mobile phone number and network credentials.

GNITS ECE-DEPT 16
A GSM (Global System for Mobile Communications) modem is a hardware device that
allows communication between a computer or microcontroller and the GSM network. These
modems enable devices to send and receive messages, make voice calls, and access the internet
via a GSM network. They often come in the form of USB dongles, expansion cards, or
standalone devices.

Fig.2.8 GSM Modem


Function of GSM modem:
A GSM module works by connecting to the GSM network through a SIM card. The SIM
card provides the module with a unique identification number, which is used to identify the
device on the network. The GSM module then communicates with the network using a set of
protocols, which allows it to send and receive data. The GSM network is a digital cellular
network that uses a set of protocols to enable communication between devices. The network
is divided into cells, which are each serviced by a base station. The base station communicates
with the devices in its cell, and the cells are interconnected to form a network.
The GSM module plays a crucial role in the communication between devices and the
GSM network. It is responsible for establishing and maintaining the communication link
between the device and the network. The module also handles the encryption and the decryption
of data, which ensures the security of the communication.

GNITS ECE-DEPT 17
Interaction with a GSM modem is typically done through AT commands. These
commands instruct the modem to perform specific functions, such as sending an SMS or
initiating a call. GSM modems operate on specific frequency bands, and their compatibility
with different networks depends on the supported frequencies. The modem used supports a
frequency range of 800-1800 MHz.
2.7.2 GSM Integration
GSM SIM900C (Global System for Mobile communication) is a mobile
communication modem that digitizes and reduces the data, then sends it down through a
channel with two different streams of client data, each in its own particular time slot. SIM900C
is a complete Quad-band GSM/GPRS solution in a SMT type with a SIM card holder. It
supports Quad-band 850/900/1800/1900MHz and can transmit voice, SMS and data
information with low power consumption. It smoothly fits into a slim and compact design. The
major benefit of using SIM800C is that it comes with inbuilt GPRS technology. In the
proposedsystem, when the nano micro controller requests the GSM to send an alert message,
the modem fitted with a SIM card sends a text message and calls to specific mobile numbers.
Any number of mobile numbers can be specified.

After performing the assigned task, GSM responds to the request of the nano micro
controller by sending acknowledgement.

SIM900C's Key Features and Role:


1. Data Digitization: The SIM900C modem is responsible for digitizing and reducing
data, making it suitable for transmission over the GSM network. It ensures that the
information to be sent is efficiently encoded and formatted.
2. Dual Data Streams: The modem utilizes a channel with two different streams of client
data, each in its own particular time slot. This allows for simultaneous communication
with multiple devices or clients, enhancing the efficiency of data transmission.
3. Quad-Band GSM/GPRS Support: SIM900C is a complete Quad-band GSM/GPRS
solution, which means it can operate on various GSM frequencies, including 850MHz,
900MHz, 1800MHz, and 1900MHz. This broad frequency support ensures global
compatibility.
4. Voice, SMS, and Data Transmission: The SIM900C can transmit not only data but also
voice and SMS messages. This versatility enables it to handle various types of

GNITS ECE-DEPT 18
communication, making it suitable for applications ranging from IoT (Internet of
Things) to remote monitoring and control.
5. Low Power Consumption: The modem is designed with power efficiency in mind,
ensuring that it can operate for extended periods on battery power or in situations where
power resources are limited. This is particularly important for remote and mobile
applications.
6. Compact Design: SIM900C is designed to fit into a slim and compact form factor,
making it easy to integrate into various electronic devices and systems without taking
up much space.
7. Inbuilt GPRS Technology: One of the major advantages of SIM900C is its built
in GPRS (General Packet Radio Service) technology. GPRS allows for packet based
data transmission over the GSM network, enabling efficient and cost effective data
communication.

Fig. 2.9 GSM Modem SIM900A

GNITS ECE-DEPT 19
Table 4.2 SIM900A GSM modem specifications

FEATURES DETAILS

Power Input 3.4 TO 4.5V

Frequency Range 800 and 1800MHz

Data Transfer Link Download:85.6kbps, Upload:42.8kbps

SMS MT, MO, CB, Text and CBU Mode

Serial Port I2C and UART

In the proposed system, when the nano microcontroller requests the GSM module (SIM900C)
to send an alert message, several actions are triggered:
1. Alert Request: The nano microcontroller initiates an alert request, indicating that
specific conditions or events have occurred that require communication with designated
recipients.
2. Text Message and Call: The GSM modem, equipped with a SIM card, is responsible
for sending both a text message and making calls to specific mobile numbers. The
system can specify any number of mobile numbers to be contacted in case of an alert.
3. Acknowledgment: After performing the assigned task, which may involve sending
critical information or warnings, the GSM modem responds to the request of the nano
microcontroller. It sends an acknowledgment to confirm that the alert messages and
calls have been successfully transmitted.

This system architecture allows for rapid communication in critical situations, ensuring that
relevant individuals or parties are informed promptly. It's applicable in various scenarios, such
as security systems, remote monitoring, and emergency notifications.

GNITS ECE-DEPT 20
Thus, the SIM900C GSM modem is a vital component that adds mobile communication
capabilities to the proposed system. Its features, including quad-band support, low power
consumption, and inbuilt GPRS technology, make it a versatile choice for a wide range of
applications that require reliable and efficient data, voice, and SMS communication over the
GSM network.

Fig.2.10 USB

A GSM module works by connecting to the GSM network through a SIM card. The SIM
card provides the module with a unique identification number, which is used to identify the
device on the network. The GSM module then communicates with the network usinga set of
protocols, which allows it to send and receive data.

The GSM network is a digital cellular network that uses a set of protocols to enable
communication between devices. The network is divided into cells, which are each serviced by
a base station. The base station communicates with the devices in its cell, and the cells are
interconnected to form a network.

The GSM module plays a crucial role in the communication between devices and the GSM
network. It is responsible for establishing and maintaining the communication link between the
device and the network. The module also handles the encryption and decryption of data, which
ensures the security of the communication.

There are different types of GSM modules, each with its own functionalities. Some modules
are designed to handle voice communication, while others are designed for data
communication. Some modules also have built-in GPS, which allows them to provide location
information.

GNITS ECE-DEPT 21
There are several advantages of using a GSM module in communication systems. Some
of the most significant advantages are:

 Cost-effectiveness: GSM modules are cost-effective and can be used in a wide


range of applications. They are also easy to install and maintain, which reduces the
overall cost of the system.

 Versatility: GSM modules can be used in various communication systems,


including remote monitoring and control, home automation systems, vehicle
tracking systems, security systems, industrial automation systems, and healthcare
systems. They can also be used in different types of devices, including mobile
phones, laptops, and embedded systems.

The use of 5V Adapter and USB cable to power the GSM by DC voltage and to dump
the code from IDE from the Laptop to the Board respectively. The term USB stands for
"Universal Serial Bus". USB cable assemblies are some of the most popular cable types
available, used mostly to connect computers to peripheral devices. An adapter or adaptor is a
device that converts attributes of one electrical device or system to those of an otherwise
incompatible device or system. Some modify power or signal attributes, while others merely
adapt the physical form of one connector to another. The jumper cables play a major role in
Connections. Male-to-male, male-to-female, and female-to-female connector wires are the
most common.

Fig. 2.11 Adapter

GNITS ECE-DEPT 22
2.7 Buzzer
In Arduino projects, buzzers are used to produce audible feedback or alarms. They can
be controlled easily by turning the corresponding pins HIGH or LOW for active buzzers, or
by generating PWM signals of varying frequencies for passive buzzers. This allows for the
creation of various sound effects, melodies, or alarms in Arduino projects.

Fig. 2.12 Buzzer

In projects, a buzzer can be used for various purposes, such as creating audible alerts,
indicating events or conditions, or adding sound effects. Here's how a buzzer can work in
different types of projects:
 Alarm Systems: Buzzer circuits can be incorporated into alarm systems to produce
loud sounds when triggered by certain events, such as detecting motion, changes in
sensor readings (like temperature or humidity), or unauthorized access. For
example, in a security project, a buzzer can sound an alarm when a motion sensor
detects movement in a restricted area.
 Timer Circuits: Buzzer circuits can be combined with timers to create audible alerts
at specific intervals or when a predetermined time has elapsed. This is useful in
projects like kitchen timers, reminders for specific tasks, or countdown timers for
GNITS ECE-DEPT 23
games or competitions.
 Notification Systems: Buzzer circuits can be integrated into notification systems to
alert users about important events or conditions. For instance, in a weather
monitoring project, a buzzer can sound an alert when certain weather conditions are
detected, such as high winds or heavy rainfall.
 Interactive Projects: Buzzer circuits can add an interactive element to projects by
providing feedback to user inputs or actions. For example, in a game project, a
buzzer can produce soundeffects when a player achieves a certain milestone, makes
a correct move, or completes a level.
 Educational Projects: Buzzer circuits are commonly used in educational projects to
demonstrate basic principles of electronics, such as how to create sound using
electromechanical devices and how to control sound output using electronic
components like transistors or microcontrollers.
Regardless of the specific project, the basic principle of operation remains the same: the
buzzer is connected to a circuit that provides electrical power, and when activated, it
produces sound through rapid vibrations of its diaphragm or armature. The design and
complexity of the circuit can vary depending on the requirements of the project and the
desired functionality of the buzzer. Arduino code monitors the levels of gas and light,
presumably related to pesticide levels. If the gas level exceeds a threshold, it sends an SMS
indicating "High Pesticide" along with sensor readings. If the gas level is below the
threshold, it sends an SMS indicating "Low Pesticide". The system checks the sensor
values periodically when triggered by a signal on pin A2. If it indicates High Pesticide,
then the buzzer sound can be heard.

GNITS ECE-DEPT 24
3. SOFTWARE DESCRIPTION
To implement a controller, it is necessary to construct a device that need to have
software to develop a system in real time world. In addition, it is necessary to connect the
computing deviceto the process which is done using sensors and actuators.
IDE stands for “Integrated Development Environment”: it is an official software
introducedby Arduino.cc, that is mainly used for editing, compiling and uploading the code in
the Arduino Device. Almost all Arduino modules are compatible with this software that is an
open source andis readily available to install and start compiling the code on the go.

3.1 Arduino Software


Arduino is a prototype platform (open-source) based on an easy-to-use hardware and
software. It consists of a circuit board, which can be programed (referred to as a
microcontroller) and a ready-made software called Arduino IDE (Integrated Development
Environment), which isused to write and upload the computer code to the physical board. The
key features are:
1. Arduino boards are able to read analog or digital input signals from different sensors and
turnit into an output such as activating a motor, turning LED on/off, connect to the cloud and
many other actions.
2. The functions can be controlled by sending a set of instructions to the microcontroller on
the board via Arduino IDE (referred to as uploading software).
3. Unlike most previous programmable circuit boards, Arduino does not need an extra piece
of hardware (called a programmer) in order to load a new code onto the board and can simply
use a USB cable.
4. Additionally, the Arduino IDE uses a simplified version of C++, making it easier to learn
toprogram.
5. Finally, Arduino provides a standard form factor that breaks the functions of the
microcontrollerinto a more accessible package.
3.2 Arduino Installation
After learning about the main parts of the Arduino Uno board, the set up for Arduino
IDEis done. Once after this, it is ready to upload the program on the Arduino board. In this
section, there are easy steps, how to set up the Arduino IDE on computer and prepare the board
to receive the program via USB cable.

GNITS ECE-DEPT 25
Step 1- First the Arduino board and a USB cable is required. In case of Arduino Uno, use
ArduinoDuemilanove, Nano, Arduino Mega 2560, or Diecimila, it will need a standard USB
cable (A plugto B plug), the kind you would connect to a USB printer.
In case if Arduino Nano is used A to Mini-B cable can be used instead as shown in fig. 3.1.

Fig. 3.1 Arduino Nano cable


Step 2- Download Arduino IDE Software. It can get different versions of Arduino IDE from
the Download page on the Arduino Official website. Then select the required software, which
is compatible with the operating system (Windows, IOS, or Linux). After the file download is
complete, unzip the file.
Step 3- Power up the board.
The Arduino Uno, Mega, Duemilanove and Arduino Nano automatically draw power
fromeither. the USB connection to the computer or an external power supply. If using an
Arduino Diecimila make sure that the board is configured to draw power from the USB
connection. The power source is selected with a jumper, a small piece of plastic that fits onto
two of the three pinsbetween the USB and power jacks. Check that it is on the two pins closest
to the USB port. Connectthe Arduino board to the computer using the USB cable. The green
power LED (labeled PWR) should glow.
Step 4- Launch Arduino IDE
After the Arduino IDE software is downloaded, need to unzip the folder. Inside the
folder,find the application icon with an infinity label (application.exe). Double click the icon
to start theIDE.
Step 5- Open project.

GNITS ECE-DEPT 26
Once the software starts, there will be two options:
1. Create new project.
2.Open the existing project example.
To create a new project, select File-> New.
To open an existing project example, select File-> Example-> Basics-> Blink.
Here, selecting just one of the examples with the name Blink. It turns the LED on and off
withsome time delay. Then select any other example from the list.
Step 6- Select the Arduino board.
To avoid any error while uploading the program to the board, then select the correct Arduino
boardname, which matches with the board connected to the computer.
Go to Tools ->Board and select board.
Here, selected the Arduino Uno board according to tutorial, but it must select the name
matchingthe board that is being used.
Step 7- Select the serial port.
Select the serial device of the Arduino board.Go to Tools-> Serial Port menu.
This is likely to be COM3 or higher (COMI and COM2 are usually reserved for hardware
serial ports). To find out, it can disconnect the Arduino board and re-open the menu, the
entry that disappears should be of the Arduino board. Reconnect the board and select that
serial port.
Step 8- Upload the program to the board.
Before explaining how can the program be uploaded to the board.
First demonstrate the function of each symbol appearing in the Arduino IDE toolbar as
shown onthe Fig. 4.2 Function of each symbol appearing in the Arduino IDE toolbar.

Fig. 3.2 Function of each symbol appearing in the Arduino IDE toolbar.

GNITS ECE-DEPT 27
A- Used to check if there is any compilation error.

B- Used to upload a program to the Arduino board.

C- Shortcut used to create a new sketch.

D- Used to directly open one of the example sketch.

E- Used to save your sketch.

F- Serial monitor used to receive serial data from the board and send the serial data to the
ward Now, simply click the "Upload" button in the environment. Wait a few seconds-
thenF the RX and TX LEDs on the board, flashing. If the upload is successful, the
message "Done uploading" will appear in the status bar.
Note- If you have an Arduino Mini, NG, or other board, you need to press the reset button
physically on the board, immediately before clicking the upload button on the Arduino
software.
3.3 Arduino Sketch
Arduino sketch is the name that Arduino uses for a program. It’s the unit of code that is
uploadedto, and run on an Arduino board. A basic Arduino sketch consists of two functions:
 Setup ()
 Loop ()

Fig. 3.3 Arduino Sketch Window

GNITS ECE-DEPT 28
Open the Arduino IDE and click on the File tab. Then, click on New (or press Control + N
on your keyboard) to have a look at the two functions as shown in Fig. 3.3.
3.4 Arduino Sketch Program Flow
In an Arduino sketch, program statements (individual lines of code) are executed,
i.e. run from top to bottom. This top-to-bottom execution of statements can be altered only
by flow control statements.
There are few things to notice in your sketch:
 void setup(): It is the function initialization/declaration process of the function
named setup(). As the function does not return any value, it is initialized with the
keyword void, meaning empty.
 Serial. begin (9600);
Serial. println(“Hello World”);
These statements are present in the setup function’s body.
 { is the opening brace of the functions that tells that all statements starting from here
are inside the functions.
 } is the closing brace of the function.
 ; is used to terminate the statement.
In the Hello World sketch, statements in the setup() function will run first, from topto
bottom. The statement Serial. begin(9600); is the first statement in the setup() function, so it
is the first to run. This statement sets up the speed of the serial port to 9600 baud. Thebaud
setting in the serial monitor window must match this value so that the evive and serialmonitor
window can communicate at the same speed.
The second statement to run in the setup() function is Serial.println(“Hello, world!”);,
which sends the text Hello World out for display in the serial monitor window. In this
statement, any text can be put between the opening and closing quotes (” “) and it will be
displayed in the serial monitor window.
The setup() Function
Statements in the setup() function are executed only once when the sketch is run.
The loop() Function
Statements in the loop() function will run continuously from top to bottom and then
back to the top. If the loop() function contains two statements, the first statement will be
executed first, then the second statement, then the first statement again and so on.

GNITS ECE-DEPT 29
The statements in the main loop will be executed continuously until the Arduino is
switched off or reset.
It is important to have the loop() function in the sketch, even if it is empty, because
without it the microcontroller on the Arduino board will try to execute whatever it finds next
in memory after the statements in the setup() function have been executed. But the loop()
function prevents it from doing so by keeping the program execution in the loop.
3.5 Writing Sketch
In writing sketch, we will use the serial monitor window to write our message.
Serial communication is very useful for controlling electronic components or devices
that are connected to (interfaced with) the Arduino board from the computer. You can use it
for debugging (finding errors in) Arduino programs when writing new programs.
To write in the serial monitor, you must first initialise serial monitor, you can do it
with the help of the following statement:
Serial. begin(9600);
Here 9600 is the baud rate at which you are communicating over USB with your device.
The statement to write on Serial Monitor is:
Serial. println (“Your Message”);

Fig. 3.4 Writing Sketch Window

GNITS ECE-DEPT 30
Now, we can modify the code by initializing serial monitor and writing print statement
inside setup() function. You will end with this code as shown in Fig. 3.4.

3.6 How to run a sketch


Follow the steps below to run the sketch:

 Connect your device to your computer using a USB cable.


 Click the Upload button to load the program to the Arduino.
 Now open the Arduino IDE Serial Monitor Window to see the sketch run and print
the text message. The text that the program shows should be visible in the serial
monitor window as shown in Fig. 3.5.

Fig. 3.5 Arduino IDE Serial Monitor Window

GNITS ECE-DEPT 31
4. IMPLEMENTATION

In the proposed methodology pesticide detection system is designed using LDR


sensor, MQ2 gas sensor, IR sensor and Arduino UNO and LCD display. It automates the
pesticide content using LDR sensor, MQ2 gas sensor and IR sensor to detect a possible
atrocity. It helps human to consume healthy food.
4.1 Block Diagram
The Block diagram of the IoT based detection of pesticides in apple and potato is
shown in the below fig 4.1. The input Sensors of the Arduino UNO are LDR Sensor, MQ2
Sensor, IR Sensor and the output is LCD Display.

LDR Sensor LCD Display

MQ2 Gas ARDUINO GSM Module


Sensor ATMega328

IR Sensor Message Alert

Fig. 4.1 Block Diagram


This block diagram represents the flow of data and control within the pesticide
content monitoring system. The sensors collect data, the Arduino processes and analyzes it,
and thesystem provides real-time feedback through the LCD display while sending alerts via
the GSM module when necessary. LDR Sensor (Light Dependent Resistor) Detects changes
in light intensity. It measures variations caused by the presence of pesticides affecting light
transmission.IR Sensor used for detecting infrared radiation changes caused by the presence
of pesticides. Gas Sensors, these sensors specifically detect pesticide gases in the
environment. Each sensor's output may require signal conditioning, such as amplification or
filtering, to ensure accurate readings.

GNITS ECE-DEPT 32
Microcontroller/Processor, unit processes the analog signals from the sensors.
Analog-to-Digital Converter (ADC) Converts analog sensor signals into digital data for the
processor to handle. The processor executes algorithms to interpret the sensor data. It could
involve pattern recognition, threshold analysis, or comparison against predefined values to
identify the presence and concentration of pesticides.
The IR, MQ2 gas sensor, and LDR sensors interface with the Arduino
microcontroller. Analog outputs from these sensors are connected to analog pins on the
Arduino. The Arduino processes the analog signals from the sensors and converts them into
meaningful data related to pesticide levels. The Arduino code includes calibration, threshold
setting, and alert generation logic.
The Arduino sends the processed data to the LCD display for real-time visualization
ofpesticide levels. The LCD updates as the sensor readings change. The Arduino is connected
toa GSM module, which is responsible for sending alert messages when pesticide levels
exceed predefined thresholds. The GSM module uses SMS (Short Message Service) for
communication. The alert system is triggered by the Arduino when sensor readings surpass
thepredefined thresholds. The alert system activates the GSM module to send alert messages.

Based on the processed data, the processor makes decisions about the presence or
absenceof pesticides and their concentration levels. LCD displays the output information such
as pesticidepresence, concentration levels, and potentially other relevant data for the user.
Visual or audible indicators can alert users to the presence of pesticides beyond certain
thresholds. Interfaces like buttons or switches can allow users to interact with the system, set
thresholds, or calibrate the sensors. The system could include storage capabilities to log data
for future analysis or reference.Power supply provides regulated power to the entire system,
ensuring stable and reliable operation.
4.2 WORKING
The process of detecting pesticides in fruits and vegetables using sensors like LDR, IR,
MQ2 gas sensor, an LCD display, and an Arduino Uno involves a comprehensive approach
that integrates sensor data, processing, and display for identification and indication of
pesticide residues. Each sensor in this setup plays a specific role: the LDR sensor monitors
variations in light intensity, the IR sensor measures infrared radiation, and the MQ2 gas
sensor detects gases, including volatile organic compounds found in pesticides.
To initiate the detection process, the sensors require calibration to establish baseline

GNITS ECE-DEPT 33
valuesand sensitivity levels to specific compounds present in pesticides. When exposed to
fruits or vegetables suspected of pesticide contamination, these sensors collect data based on
changes in light intensity, infrared radiation, and gas concentrations. The Arduino Uno,
acting as the central processing unit, reads, processes, and interprets the sensor data using
predefined algorithms and thresholds to determine the presence of pesticides. Calibration
ensures the accuracy and specificityof the sensors to differentiate pesticide-related variations
from background environmental factors.The decision-making process within the Arduino
determines if detected variations orconcentrations exceed predefined limits, indicating the
potential presence of pesticides.
Results of the detection process are then displayed on the LCD screen, providing a
visual output that indicates the presence or absence of pesticides and potentially triggers alerts
if pesticidelevels surpass acceptable limits. Challenges in this process include ensuring sensor
sensitivity andspecificity, accurate threshold setting to avoid false positives or negatives, and
accounting for real-world variations in environmental conditions and pesticide compositions.
While this setup offers a fundamental model for pesticide detection, practical
implementation often requires more sophisticated and specialized equipment for increased
accuracy and reliability in real-world scenarios. Calibration precision, threshold accuracy,
and consideration of environmental factors remain crucial for effective pesticide detection
using sensor-based systems.

Here's a detailed breakdown of the process:


1. Sensor Integration and Functionality:
LDR Sensor (Light Dependent Resistor): LDRs measure light intensity. When fruits
or vegetables are contaminated with certain pesticides, they might exhibit altered light
absorption orreflection properties due to chemical changes. The LDR sensor detects these
variations in light intensity.
IR Sensor (Infrared Sensor): IR sensors detect infrared radiation. Some pesticides
might have distinctive infrared absorption or emission patterns. The IR sensor is used to
measure these specific changes in infrared radiation caused by pesticide residues on the
produce.
MQ2 Gas Sensor: The MQ2 sensor is capable of detecting various gases, including
volatileorganic compounds (VOCs) that are emitted by certain pesticides. It identifies the
presence of these gases in the vicinity of the fruits or vegetables.

GNITS ECE-DEPT 34
2. Arduino Uno Processing:
Data Acquisition: The sensor data, including readings from LDR, IR, and MQ2 sensors, are
collected by the Arduino Uno microcontroller.
Data Interpretation: Arduino Uno processes and interprets the collected sensor data. It
applies predefined algorithms or thresholds to analyze the readings from the sensors to
3. Decision Making and Output Display:
Determine the likelihood of pesticide contamination based on the changes detected
in lightintensity, infrared radiation, and gas concentrations.
Threshold Comparison: Arduino Uno compares the sensor readings with predefined
thresholds or established patterns that indicate the presence of pesticides. If the readings
exceed these thresholds, it signifies potential pesticide contamination.
LCD Display Output: The results of the pesticide detection process are displayed on an
LCD screen. This display visually indicates the presence or absence of pesticides in the fruits
or vegetables based on the interpretations made by the Arduino Uno.
Considerations:
Calibration and Sensitivity: Proper calibration of sensors is crucial to ensure they are
sensitive enough to detect specific changes caused by pesticides without generating false
positivesor negatives.
Threshold Setting: Establishing accurate thresholds or criteria based on sensor readings to
distinguish between contaminated and uncontaminated produce.

Environmental Factors: Considering environmental conditions that might influence sensor


readings, such as temperature, humidity, and external interference, to ensure accurate
detection.
This system provides a basic yet effective method for detecting potential pesticide
residuesin fruits and vegetables by analyzing variations in light intensity, infrared radiation,
and gas emissions associated with pesticide presence. Calibration, precise threshold setting,
and accounting for environmental factors are essential for reliable and accurate pesticide
detection using this sensor-based approach.

GNITS ECE-DEPT 35
5. RESULTS AND DISCUSSIONS
This project aims to revolutionize pesticide detection by integrating Light Dependent
Resistor (LDR), Infrared (IR), and gas sensors into a comprehensive detection system. The
combined sensor array offers a multi-dimensional approach to identifying pesticides in
varyingenvironmental conditions. The LDR sensor captures changes in light transmission
caused by pesticide particles, while the IR sensor detects alterations in infrared radiation due
to pesticideinteractions. Gas sensors add specificity by detecting particular pesticide gases.
Through sophisticated data processing implemented by the onboard processor, the system
offers both qualitative and quantitative analysis of pesticide presence and concentration
levels as shown in fig. 5.1.

Fig.5.1 Proposed system

GNITS ECE-DEPT 36
Algorithmic analysis, real-time processing capabilities, and the intuitive LCD
display ensure accurate and immediate feedback to users, detailing pesticide levels and
potential alerts as shown in fig.5.2. Evaluating sensor sensitivity, compensating for
environmental interferences, and exploring avenues for future improvements form critical
aspects of this innovative pesticide detection project.

Fig.5.2 Displaying pesticide value on LCD

The outputs of the pesticide content monitoring system with IR, MQ2 gas sensor, LDR
sensors, LCD display, and GSM integration are the actionable information and alerts
generated by the system.
LCD Display Output:
The LCD display provides a visual representation of real-time pesticide levels. It
enables stakeholders to monitor the current status and changes in pesticide concentrations.

The LCD display, as a crucial output component, serves as a direct interface between
the pesticide content monitoring system and its stakeholders, providing them with the
necessary informationfor decision-making and proactive response to changes in pesticide
levels.
GNITS ECE-DEPT 37
Alert Messages via GSM:

Fig.5.3 Sending Alert Message


The message initiation starts as shown in fig 5.3. When pesticide levels exceed predefined
thresholds, the system triggers an alert. The GSM module sends alert messages via SMS to
predefined recipients, such as farmers, distributors, or regulatory authorities as shown in the
fig 5.4.

Fig.5.4 Alert Message Acknowledgement

By employing the GSM module and SMS alerts, the pesticide content monitoring
system ensures rapid and reliable communication, enabling stakeholders to take timely actions

GNITS ECE-DEPT 38
in response to elevated pesticide levels, ultimately contributing to improved food safety and
agricultural practices as shown in fig 5.5.

Fig.5.5 Alert Message

GNITS ECE-DEPT 39
6. ADVANTAGES & DISADVANTAGES
6.1. Advantages
The advantages of IoT based detection of pesticides in fruits and vegetables are:
 Consumer Safety: Ensures that consumers are not exposed to harmful levels of
pesticides,safeguarding their health and well-being. By identifying and quantifying pesticide
residues, consumers are assured of safer produce, reducing health risks associated with
consuming contaminated fruits and vegetables.

 Compliance with Regulations: Helps producers adhere to strict regulations regarding


permissible pesticide levels, avoiding legal repercussions and ensuring market compliance
and access.

 Improved Quality Control: Enables farmers and distributors to monitor and maintain the
quality of their produce, enhancing its market value and consumer trust.

 Environmental Protection: Identifies excessive pesticide use, helping minimize


environmental pollution and preserving ecosystem health. Efficient pesticide detection aids
in reducing the environmental impact by promoting responsible pesticide usage and
minimizing soil and water contamination.

 Data-Driven Insights: Provides valuable data for optimizing pesticide application


methods,improving farming practices, and minimizing unnecessary chemical usage. Data
collectedfrom detection systems offer insights for farmers to optimize pesticide use, and
timing, reducing overuse and minimizing environmental impact.

 Early Intervention and Prevention: Allows for early detection of pesticide contamination,
enabling swift action to mitigate further contamination or crop damage.

 Supply Chain Transparency: Enhances transparency by providing traceability, allowing


consumers to make informed choices and trust the food they consume. Consumers can
access information about the produce, its origins, and pesticide usage, fostering
transparency and trust in the food supply chain.

 Reduced Wastage: Early detection helps in taking proactive measures to prevent further
contamination, preserving crop quality and reducing potential wastage.

 Public Health Awareness: Raises awareness about importance of safe pesticide usage
and fostering a more conscious approach among producers and consumers.

GNITS ECE-DEPT 40
 Technology Integration: The use of advanced detection methods, including IoT, sensors,
and data analytics, facilitates efficient and accurate pesticide detection.

 Precision and Accuracy: Advanced detection methods ensure accurate measurement and
identification of pesticide residues, providing reliable data about the contamination levels.

 Real-time Monitoring: IoT-based systems continuously monitor pesticide levels, providing


immediate data, and enabling quick responses to any detected issues.
These advantages collectively contribute to a safer and more sustainable food system, ensuring
that fruits and vegetables are free from harmful pesticide residues, and promoting healthier
consumption practices worldwide.
6.2 Disadvantages
While the detection of pesticides in fruits and vegetables offers numerous benefits, there
are also some limitations and challenges associated with this process:

 Costly Equipment and Expertise: Implementing sophisticated detection methods such as


chromatography or biosensors requires expensive equipment and trained personnel, which
might not be readily accessible to all farmers or food processors.

 Time-Consuming Analysis: Traditional laboratory-based analysis methods can be time-


consuming, delaying the availability of results and impacting the efficiency of the supply
chain.

 Limitations in Detecting All Pesticides: Some detection methods may not be able to identify
all types of pesticides or their breakdown products, potentially leading to incomplete
information about pesticide residues.

 Threshold Levels and Sensitivity: Setting threshold levels for pesticide residues is
challenging, as some substances might have different acceptable limits in various regions
or for different produce. Additionally, achieving the required sensitivity in detection can be
difficult for some low-dosage pesticides.

 Complexity in Sample Preparation: Preparing samples for analysis, especially for complex
matrices like fruits and vegetables, can be intricate and time-intensive, affecting the
efficiency of the detection process.

 Lack of Standardization: Standardization of detection methods across different regions or


countries might be lacking, leading to inconsistencies in regulations.

GNITS ECE-DEPT 41
 Environmental Factors and Interferences: Environmental factors like temperature,
humidity, or natural compounds in produce can sometimes interfere with detection methods,
affecting their accuracy.
 Challenges in Implementation for Small-Scale Farmers: Small-scale or subsistence farmers
might face difficulties in adopting these technologies due to financial constraints or lack of
technical expertise.
 Continuous Monitoring and Maintenance: IoT-based systems require continuous
monitoring and maintenance, which can pose challenges in terms of reliability, power
supply, and connectivity, particularly in remote or rural areas.
 Consumer Perception and Trust: While detection ensures safety, excessive emphasis on
pesticide detection may lead to consumer concern or mistrust about the safety of all
produce, potentially affecting market demand.
Despite these challenges, ongoing advancements in technology and research aim to overcome
these limitations, making pesticide detection more accessible, efficient, and reliable in
ensuringthe safety and quality of fruits and vegetables.

GNITS ECE-DEPT 42
7. APPLICATIONS
The applications of pesticide detection in fruits and vegetables are vital across various
sectors and stages of the food supply chain:
 Pesticide Application Management: Monitoring and controlling pesticide application to
ensure compliance with regulations and minimize excess usage.
 Quality Control: Assessing produce quality before harvesting, ensuring that fruits and
vegetables meet safety standards.
 Quality Assurance: Checking incoming raw produce to guarantee it meets safety standards
and doesn't contain harmful levels of pesticides.
 Market Compliance: Meeting regulatory requirements to avoid legal issues related to
permissible pesticide residue levels.
 Innovation in Detection Methods: Researching and developing new and more efficient
detection technologies to improve accuracy, sensitivity, and speed of pesticide detection.
 Data Analysis for Improvement: Analyzing collected data to improve farming practices,
optimize pesticide application, and enhance food safety.
 Setting Standards and Regulatory Compliance: Establishing acceptable pesticide residue
limits in fruits and vegetables to safeguard consumer health and ensure compliance across
the industry.
 Enforcement and Inspection: Monitoring and inspecting produce for compliance with set
standards, ensuring adherence to regulations.
 Global Trade and Export by International Standards Adherence: Meeting international
standards for pesticide residues in agricultural products to facilitate trade and export of
fruits and vegetables.
 Building Trust and Market Access: Ensuring that exported produce meets the safety
requirements of importing countries, enhancing market access and consumer trust.
 Public Health Awareness Campaigns: Creating awareness among consumers about the
importance of safe pesticide usage and the significance of buying product with controlled
 Pre-harvest Monitoring: Ensuring that pesticide levels in crops are within acceptable limits
before harvesting is critical. Monitoring helps farmers make informed decisions about
pesticide application and withdrawal periods.
 Post-harvest handling: The Detecting pesticides in harvested produce helps prevent
contaminated fruits and vegetables from entering the market or being processed into food
products.

GNITS ECE-DEPT 43
 Food Processing: Pesticide detection is essential during food processing to ensure that
contaminants are not introduced during processing stages such as washing, peeling, and
cutting.
 Quality Control: Monitoring pesticide residues in fruits and vegetables is part of quality
control measures to meet regulatory standards and ensure consumer safety.
 Export and Import: Many countries have strict regulations regarding pesticide residues in
imported fruits and vegetables. Detection is necessary to comply with these regulations and
facilitate international trade.
 Consumer Safety Ultimately, pesticide detection in fruits and vegetables is crucial for
protecting consumer health and safety, as excessive pesticide residues can pose health risks.

GNITS ECE-DEPT 44
8. CONCLUSION AND FUTURE SCOPE
8.1 Conclusion:
The implementation of IoT-based detection systems for pesticides in apple and potato
cultivation presents a significant leap forward in ensuring food safety, environmental
sustainability, and efficient agricultural practices. This technology offers real-time
monitoring and data-driven insights, enabling farmers and stakeholders to make informed
decisionsregarding pest management. By leveraging sensor networks and data analytics, the
system notonly detects pesticide levels but also provides a comprehensive understanding of
environmentalconditions, crop health, and potential risks.
The IoT-based approach enhances precision in pesticide application, minimizing
overuse and reducing the environmental impact. It contributes to the promotion of sustainable
farming practices, protecting ecosystems and biodiversity. Furthermore, the real-time nature
ofthe system allows for immediate responses to emerging pest threats, preventing widespread
crop damage and ensuring higher yields.
The integration of IoT in pesticide detection aligns with the global push for smart agriculture,
where technology plays a pivotal role in addressing the challenges faced by the agricultural
sector. As we move towards a future of interconnected devices and smart farming practices,
the IoT-based detection of pesticides in apple and potato cultivation stands as a testament to
the potential of technology to revolutionize and optimize agricultural processes.
However, it is crucial to address challenges such as data security, standardization, and
accessibility to ensure the widespread adoption of these technologies. Collaborative efforts
from researchers, farmers, and policymakers will be essential to overcome these hurdles and
unlock the full potential of IoT in creating a sustainable and secure future for agriculture.
Overall, the IoT-based detection of pesticides represents a promising step towards safer and
more efficient food production systems, benefitting both farmers and consumers alike.
8.2 Future Scope:
The future scope of pesticide detection in fruits and vegetables is evolving rapidly due
to technological advancements, particularly in areas like IoT, nanotechnology, spectroscopy,
and data analytics. This evolution is driven by the growing concerns about food safety,
environmental sustainability, and the need for more efficient agricultural practices.
Advanced Sensors: Continued advancements in sensor technology, including miniaturization
and increased sensitivity, will enable the development of highly accurate and cost-effective
sensors for pesticide detection.

GNITS ECE-DEPT 45
 IoT Integration: Integration of IoT devices with these advanced sensors will facilitate
real-time monitoring of pesticide residues on fruits and vegetables throughout the supply
chain.
 Wireless Connectivity: Enhanced wireless connectivity will enable seamless
communication between sensors, data processing units, and cloud platforms, allowing
for rapid data analysis and decision-making.
 Nanotechnology and Spectroscopy: Nanotechnology-driven sensors hold promise for
ultra-sensitive and selective detection of pesticide residues at extremely low
concentrations, improving accuracy and detection limits. Advancements in
spectroscopic techniques, such as Raman spectroscopy and infrared spectroscopy, will
enable non-destructive and rapid detection of pesticides in produce.
 Big Data Analytics: Increased use of big data analytics will allow for the processing of
vast amounts of data generated by IoT devices and sensors, extracting meaningful
insights into pesticide usage patterns and contamination levels.
 Machine Learning and AI: Machine learning algorithms will continue to evolve,
enabling predictive analysis, anomaly detection, and optimization of pesticide
application strategies based on historical data and environmental factors.
 Smart Farming Practices: The integration of pesticide detection technologies into
precision agriculture systems will enable targeted and optimized pesticide
application, reducing Autonomous drones and robotic systems equipped with
detection overuse and minimizingenvironmental impact.
 Precision Agriculture: sensors will enable efficient and precise pesticide
application and monitoring across vastagricultural fields.
 Standardization and Regulation: There will be an increased focus on establishing
standardizeddetection methods and regulatory frameworks to ensure compliance with
safety standards.
 Consumer Empowerment: Consumers will have access to more information about the
producethey buy, including pesticide residue levels and farming practices, empowering
them to make informed choices.

GNITS ECE-DEPT 46
Challenges and Considerations:
 Cost and Accessibility: Adoption of advanced technologies might initially be costly,
limiting accessibility for smaller farmers.
 Data Security and Privacy: Ensuring the security and privacy of data collected from IoT
devices and sensors will be critical.
 Education and Adoption: Efforts are needed to educate farmers about the benefits and
proper utilization of these technologies for effective pesticide detection and
management.
In conclusion, the future of pesticide detection in fruits and vegetables lies in the integration
ofcutting-edge technologies, data-driven approaches, and sustainable agricultural practices.
As these innovations continue to evolve, they hold the potential to significantly enhance food
safety, minimize environmental impact, and improve overall agricultural productivity and
sustainability.

GNITS ECE-DEPT 47
9. REFERENCES
[1] D.Nagajyothi, P. Hema Sree, M.Rajani Devi, G.Madhavi, Sk Hasane Ahammad, “IOT-
Based Prediction of Pesticides and Fruits Diseases Detection Using SVM and Neural Networks”
in International Journal of Mechanical Engineering, January 2022.
[2] Selvi, S., Karthikeyan, R. and Vanitha, U., “Organic farming: Technology for environment-
friendly agriculture,” in Proc. International Conference on Advances in Engineering, Science
and Management (ICAESM), pp.132-136, March 2012.
[3] Mnif W, Hassine AIH, Bouaziz A et al (2011) Effect of endocrine disruptor pesticides: a
review. Int J Environ Res Public Health 8:2265–2303.
[4] Sharma A, Kumar V, Shahzad B et al, “Worldwide pesticide usage and its impacts on
ecosystem”. SN Appl Sci 1:1446 (2019).
[5] Narenderan ST, Meyyanathan SN, Babu B. Review of pesticide residue analysis in fruits
and vegetables. Pre-treatment, extraction and detection techniques. Food Res Int. 2020
Jul;133:109141.
[6] Archana B S et al. “Different Methods to Determine Pesticides in Fruits and Vegetables: A Review”,
IRJET, April 2021.
[7] Aradhana B S et al. “Quality and pesticides detection in fruit and vegetables”, JETIR May 2021.
[8] Sujitha, S., Vinoth Kumar, K., Shiva, R.V., Kulkarni, S., Ponnappa, M.M, “An
implementation of soft computing approach of smart control for induction motor using ANFIS”
proceedings - 4th International Conference on Smart Systems and Inventive Technology,
ICSSIT 2022.
[9] Shalini Gnanavel et all “Quality Detection of Fresh Fruits and Vegetables to Improve
Horticulture and Argo-industries” IEEE Xplore2017.
[10] Sujitha, S., Venkatesh.C, “Analysis of regulated PV fed switched reluctance motor drives
using repression resistor converter” in International Journal of Engineering and Technology,
2014, 6(3), pp. 1309–1313

GNITS ECE-DEPT 48
APPENDIX

Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
int count=0;
int a=0;
int b=0;
void setup() {
Serial.begin(9600);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(11, OUTPUT);
digitalWrite(11, LOW);
lcd.begin(16,2);
delay(500);
lcd.setCursor(0, 0);
lcd.print("Pesticide Level");
lcd.setCursor(0, 1);
lcd.print(" Monitor System");
delay(3000);
lcd.clear();
}
// the loop routine runs over and over again forever:
void loop() {
int ldr = analogRead(A0);
int gas = analogRead(A1);
if(digitalRead(A2)==LOW)
{
lcd.setCursor(0, 0);
lcd.print("checking... ");
GNITS ECE-DEPT 49
delay(3000);
lcd.clear();
ldr = analogRead(A0);
gas = analogRead(A1);
lcd.setCursor(0, 0);
lcd.print("LDR:");
lcd.print(ldr);
lcd.setCursor(8, 0);
lcd.print("GAS:");
lcd.print(gas);
delay(7000);
do
{
ldr = analogRead(A0);
gas = analogRead(A1);
lcd.setCursor(0, 0);
lcd.print("LDR:");
lcd.print(ldr);
lcd.setCursor(8, 0);
lcd.print("GAS:");
lcd.print(gas);
delay(1000);
if(gas>50 && b==0)
{
b=1;
a=0;
lcd.setCursor(0, 1);
lcd.print("High Pesticide ");
digitalWrite(11, HIGH);
Serial.println("AT+CMGF=1");
//To send SMS in Text Mode
delay(1000);
Serial.println("AT+CMGS=\"+919182849514\"\r");
GNITS ECE-DEPT 50
// change to the phone number you using
delay(1000);
Serial.println("Pesticide level: HIGH");
//the content of the message
delay(200);
Serial.print("LDR:");
//the content of the message
delay(200);
Serial.println(ldr);
delay(200);
Serial.print("GAS:");
//the content of the message
delay(200);
Serial.println(gas);
delay(200);
Serial.println((char)26);
//the stopping character
delay(1000);
Serial.println((char)26);
//the message stopping character
delay(1000);
digitalWrite(11, LOW);

}
if(gas<=50 && a==0)
{
a=1;
b=0;
lcd.setCursor(0, 1);
lcd.print("Low Pesticide ");
Serial.println("AT+CMGF=1");
//To send SMS in Text Mode
delay(1000);
GNITS ECE-DEPT 51
Serial.println("AT+CMGS=\"+919182849514\"\r");
// change to the phone number you using
delay(1000);
Serial.println("Pesticide level: LOW");
//the content of the message
delay(200);
Serial.print("LDR:");
//the content of the message
delay(200);
Serial.println(ldr);
delay(200);
Serial.print("GAS:");
//the content of the message
delay(200);
Serial.println(gas);
delay(200);
Serial.println((char)26);//the stopping character
delay(1000);
Serial.println((char)26);//the message stopping character
delay(1000);
}
}while(digitalRead(A2)==LOW);
}
}

GNITS ECE-DEPT 52
Code Explanation:
This Arduino code monitors the levels of gas and light, presumably related to pesticide
levels. If the gas level exceeds a threshold, it sends an SMS indicating "High Pesticide" along
with sensor readings. If the gas level is below the threshold, it sends an SMS indicating "Low
Pesticide". The system checks the sensor values periodically when triggered by a signal on
pin A2.
The code includes the LiquidCrystal library which allows control of LCD displays. An
instance of the LiquidCrystal class is created named lcd, which is connected to pins 7, 6, 5, 4,
3, and 2 of the Arduino board. Three integer variables are declared: count, a, and b. Count is
initialized to 0. Variables a and b are used as flags to indicate whether a certain condition has
been met or not. The setup() function initializes the program.
Serial communication is initiated at a baud rate of 9600.
Pins A0, A1, and A2 are set as input pins.
Pin 11 is set as an output pin and initially set to LOW.
The LCD is initialized with 16 columns and 2 rows.
"Pesticide Level Monitor System" is displayed on the LCD for 3 seconds.
The LCD is cleared.
The loop() function runs repeatedly. Analog readings of sensors connected to pins A0
(LDR sensor) and A1 (gas sensor) are stored in variables ldr and gas respectively. If pin A2
is LOW, the code inside the if statement executes. The LCD displays "checking..." for 3
seconds and then clears the display. Analog readings of LDR and gas sensors are taken again.
The values of LDR and gas are displayed on the LCD.
There's a delay of 7 seconds. A do-while loop runs as long as pin A2 is LOW. If gas level is
above 50 and flag b is 0, the code inside the if statement executes. If gas level is 50 or below
and flag a is 0, the code inside the if statement executes. Depending on whether the gas level
is high or low, an SMS is sent with the respective message and sensor reading.

GNITS ECE-DEPT 53
GNITS ECE-DEPT 54
GNITS ECE-DEPT 55
GNITS ECE-DEPT 56
GNITS ECE-DEPT 57
GNITS ECE-DEPT 58
GNITS ECE-DEPT 59
GNITS ECE-DEPT 60
GNITS ECE-DEPT 61
GNITS ECE-DEPT 62

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