A
MINI PROJECT REPORT
                                           ON
                SMART SECURITY FOR CROP CULTIVATION
A dissertation submitted in partial fulfilment of the requirements for the award of degree
                                            of
                            BACHELOR OF TECHNOLOGY
                                           In
          Department of Computer Science and Engineering
                                           By
              B.SNEHA                                (15TQ1A0512)
              B.HARIKA                               (15TQ1A0538)
              P.SHASIDHAR                            (15TQ1A0567)
              N.MANEESHA                             (15TQ1A0565)
              G.MOKSHITH                             (15TQ1A0536)
               Under the estimated guidance of Dr.SRIHARI
    DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
     SIDDHARTHA INSTITUTE OF TECHNOLOGY AND SCIENCE
                   (Approved by AICTE & Affiliated to JNTUH)
        Korremula Road, Narapally, Ghatkesar(M), R.R District-501301
           Department of Computer Science and Engineering
            SIDDHARTHA INSTITUTE OF TECHNOLOGY AND SCIENCE
                  (Approved by AICTE & Affiliated to JNTUH)
          Korremula Road, Narapally, Ghatkesar, R.R District-501301
                                      2015-2019
                                    CERTIFICATE
This is to certify that the project entitled “SMART SECURITY FOR CROP CULTIVATION” being
submitted by B.SNEHA bearing hall ticket number 15TQ1A0512, B.HARIKA bearing hall ticket
number 15TQ1A0538, P.SHASIDHAR bearing hall ticket number 15TQ1A0567, N.MANEESHA
bearing hall ticket number 15TQ1A0565 and G.MOKSHITH bearing hall ticket number
15TQ1A0536 in the partial fulfilment for the award of the degree of Bachelor of Technology
in COMPUTER SCIENCE AND ENGINEERING to Siddhartha Institute of Technology and Science
is a record of bonafide work carried out by them under my guidance and supervision. The
results embodied in this project report have not been submitted to any other University or
institute for the award of any degree.
    INTERNAL GUIDE                                HEAD OF DEPARTMENT
                             ACKNOWLEDGEMENT
     It is our privilege and pleasure to express profound sense of respect, gratitude and
indebtedness to our guide Mr.Sri Hari, Assistant Professor, Dept. of Computer Science and
Engineering, Siddhartha Institute of Technology and Science, for his indefatigable
inspiration, guidance, cogent discussion, constructive criticisms and encouragement
throughout this dissertation work.
      We express our sincere gratitude to Dr. A. Satyanarayana, Professor and Head,
Department of Computer Science and Engineering, Siddhartha Institute of Technology and
Science, for his suggestions, motivations and co-operation for the successful completion
of the work.
       We extend our sincere thanks to, Principal, Dr. Syed Basha ,Siddhartha Institute of
Technology and Science,Narapally,Korremula Road,Ranga Reddy District.
                                                    B.SNEHA           (15TQ1A0512)
                                                    B.HARIKA          (15TQ1A0538)
                                                    P.SHASIDHAR       (15TQ1A0567)
                                                    N.MANEESHA        (15TQ1A0565)
                                                    G.MOKSHITH        (15TQ1A0536)
                                      Dept. of Computer Science and Engineering
                                     Siddhartha Institute of technology and Science
                                 DECLARATION
       We hereby declare that the project work entitled “Smart Security for Crop
Cultivation” submitted to the Siddhartha Institute of Technology and Science in
partial fulfilment of the requirements for the award of the degree of Bachelor of
Technology (B.Tech) in Computer Science and Engineering is a record of an original
work done by us under the guidance of Mr. Sri Hari, Assistant Professor and this
project work have not been submitted to any other university for the award of any other
degree or diploma.
                                                B.SNEHA          (15TQ1A0512)
                                                B.HARIKA         (15TQ1A0538)
                                                P.SHASIDHAR      (15TQ1A0567)
                                                N.MANEESHA       (15TQ1A0565)
                                                G.MOKSHITH       (15TQ1A0536)
                                                Date:
                                     CONTENTS
                                                     PG.NO
1. Introduction……………………………………………………………………..
   Purpose
   Background
   Scope
   Features
2. Existing System…………………………………………………………………
3. Proposed System………………………………………………………………..
4. Technologies Used………………………………………………………………
  4.1-------- Software Interfaces
5. Architecture……………………………………………………………………..
   5.1-------- Authorized user
   5.2--------Un-Authorized user
6. Design Modules…………………………………………………………………
   6.1-------- Detailed Activity diagrams
   6.2-------- Use-cases
   6.3-------- Software Requirement Specifications
7. Implementation………………………………………………………………….
   7.1-------- IOT Technology
   7.2-------- Device Construction steps
8. Sample Code……………………………………………………………………..
9. Testing……………………………………………………………………………
10. Conclusion ………………………………………………………………………
11. Bibliography……………………………………………………………………..
                            ABSTRACT
Most of the farmers are facing an issue of protecting their agricultural farms
being attacked by birds and animals. Birds and animals attack the farm for their
food which causes a greater loss to the farmer. We came up with a solution to
overcome such issues, our approach involves in smart monitoring the farm.
Smart monitoring system monitors the farm and if it detects any unusual
activity then it will notify the farmer about that activity based on that rappelers
can be used to keep animals and birds ward away from the farm.This project
aims to provide an effective solution to the problem stated above in the form
of an ELECTRONIC SURVEILLANCE SYSTEM. This system will enable the
farmers to protect their fields and orchards effectively, without any human
intervention, by warding off the animals with automatically and manually
controlled ultrasonic animal repellent buzzers. It will also enable them
to remotely monitor their fields from any place, thus eliminating the need of
physical presence of a person in the fields.
                     INTRODUCTION
Surveillance plays a major role in many fields be it at home, hospitals, schools, public
places, farmlands etc. It helps us to monitor a certain area and prevent theft and
provides proof of evidence in case of occurrence of such incidents. In the case of
farmlands or agricultural lands surveillance is very important to prevent unauthorized
people from gaining access to the area as well as to protect the area from animals.
Various methods aim only at surveillance which is mainly for human intruders, but we
tend to forget that the main enemies of such farmers are the animals which destroy
the crops. The problem of wild animal attacks on crop fields i.e. Crop vandalization
is becoming a very common phenomenon in the state of Telangana, Himachal
Pradesh, Punjab, Haryana and many other states. Wild animals like monkeys, estray
animals especially cows and buffaloes, wild dogs, nilgais, bisons, elephants, deer, wild
pigs and even birds like parakeets cause a lot of damage to crops either by running
over them or eating them and vandalizing them completely. This leads to poor yield
of crops. These animals attack on fruit orchards and destroy the flowerings and fruits.
In both cases, this leads to significant financial loss to the farmers and orchard owners.
The problem is so pronounced that sometimes farmers decide to leave the area barren
due to these animal attacks. The main aim of this project is to provide an effective
solution to this problem, so that the economic losses incurred by our farmers are
minimized and they have a good crop yield.
1.1 Purpose
In India two- third of population is directly depending on agricultural sector for their
livelihood. The animals from the wild area are continuously attacking to crop from so
many years and the protection of this crop field from wild animals is the serious issue.
The wild animals face an shortage of water and food due to which they move towards
the agriculture area which creates great loss to the crops and annual income of
farmers, It has been estimated that at minimum conservative average damage per
household of ₹6,000, 15 million families could suffer a cumulative loss of ₹ 9,000
crore every year. This is a very huge amount to loose in a country like India. When
wild animals enter in a farm there is a need for an alert system to prevent crops from
damages from wild animal.
This project aims to provide an effective solution to the problem stated above in the
form of an ELECTRONIC SURVEILLANCE SYSTEM. This system will enable the
farmers to protect their fields and orchards effectively, without any human
intervention, by warding off the animals with automatically and manually
controlled ultrasonic animal repellent buzzers. It will also enable them to
remotely monitor their fields from any place, thus eliminating the need of physical
presence of a person in the fields
 1.2 Background
Various traditional techniques are used for providing security but up to date, complete
security is not discovered.
1. Electric fencing around the crop
2. Building of wall around the crop fields
3. Use of local dogs for scaring away wild boars
4. Fencing around the crop
1.3 Scope
The main objective of this project is to provide an effective solution to this problem,
so that the economic losses incurred by our farmers are minimized and they have a
good crop yield. It helps to save time and money by reducing the manual work that is
otherwise required if the farmers themselves had to provide protection to their
farmlands with their constant manual supervision. The manual work done to keep
away the animals from the crops is automated, hence such constant supervision is a
thing of the past with such smart protection systems, which can identify and taking
the required actions themselves without any human intervention.
1.4 Features
Our proposed system overcomes all the security problems in existing system and
provides high security and efficiency. This is a perfect/optimal solution for protecting
the farm from wild animals and birds. The features of our product are briefly described
below:
1.4.1 Effective
This system requires almost no human supervision, except for the task of switching
the system on and off. The system can turn the buzzers on automatically and
warding off the animals thus protecting the fields from any damage.
1.4.2 Requires no human supervision
It determines the presence of animals in the fields and sounds the buzzer. This
system is very effective in driving off the animals from the fields and keeping them
away.
1.4.3 Economical
This system is economical as compared to many of the existing solutions like electric
fences, brick walls and manual supervision of the fields. The cost of the existing
solutions is very high and the cost of this system is only a fraction of their cost.
Thus, it saves a lot of money of the farmer.
1.4.4 Real time monitoring
This system works in real time to detect the animals in the fields. The system
enables the farmer to have a real time view of his fields from any place via internet
and even provides manual buzzer controls if the need arises to use them. Thus, the
farmer is in effective control of the system and can manually sound the buzzer if
needed. The system also provides a history of the events taking place in the fields,
in the form of images and textual log records.
1.4.5 Causes no harm to animals and humans
This system is totally harmless and doesn’t injure animals in any way. It also doesn’t
cause any harm to humans. Also, this system has a very low power requirement
thus reducing the hazards of electric shocks.
1.4.6 Highly Flexibility
This system, although primarily aimed at crop protection, can be used for other
purposes also. It may be used as a remote monitoring system, or as a standalone
system. Thus it can be installed at places like godowns, places prone to robbery,
shops, offices etc.
                              EXISTING SYSTEM
The existing systems mainly provide the surveillance functionality. Also, these systems
don’t provide protection from wild animals, especially in such an        application area.
They also need to take actions based on the on the type of animal that tries to enter
the area, as different methods are adopted to prevent different animals from entering
such restricted areas. Also the farmers resort to the other methods by erecting human
puppets and effigies in their farms, which is in effective in warding off the wild animals,
though is useful to some extent to ward off birds. The other commonly used methods
by the farmers in order to prevent the crop vandalization by animals include building
physical barriers, use of electric fences and manual surveillance and various such
exhaustive and dangerous methods.
                             PROPOSED SYSTEM
Our proposed system overcomes all the security problems in existing farmland and
provides high security and efficiency. This is a perfect/optimal solution for farm
protection. It can be operated in two modes automatic and manual.
In automatic mode whenever any bird or animal enter near to the farm then our PIR
sensor will detect that some living object has come near the farm then it will be notified
to the farmer, and at the same time reppelers like Ultrasonic sensor, Buzzer, Light are
used to ward of animals and birds away from the farm. In manual mode after notifying
the farmer, the farmer can decide which repellent can be used to ward off the animals
and birds through the interface provided to him where he can choose different options
consisting of an option for buzzer and other for ultrasonic and light. Farmer can choose
either buzzer option to repel birds and animals or ultrasonic to repel animals.
                        TECHNOLOGIES USED
Software Interfaces:
We are using Raspbian Noobs and python programming language for writing the
project code.
Software Requirements:
1. Raspbian Noobs Version 3 Model B
2. Androids OS
Hardware Requirements:
1. RAM: 1.GB SDRAM
2. Hard Disk: 8GB Memory
3. Processor: ARM Cortex A53
4. Sensors:
      a. Ultrasonic
       b. PIR Sensor
       c. Buzzer
       d. Led Bulb
                               ARCHITECTURE
The above diagram shows the architecture of the Smart security for crop protection
with its interfaces. The Raspberry pi microcontroller centrally controls all the devices
connected to it. The program must be fed into the Raspberry pi board and connected
to the power supply. The devices are triggered according to the flow of the code. First
PIR sensor will senses if any motion has occurred or not. If any motion has occurred
the data is sent to the microcontroller. From microcontroller the data is sent to the
cloud and to user. The rappelers like Buzzer, Ultrasonic, Light are activated to ward
off animals and birds.
                            DESIGN MODULES
6.1 Detailed Activity diagrams:
The below diagrams describe the architecture of the farm security with its interfaces.
The Raspberry microcontroller centrally controls all the devices connected to it. The
program must be fed into the Raspberry and connected to the power supply. The
devices are triggered according to the flow of the code.
6.3 USECASES:
6.3.1 Automatic mode:
Our proposed system overcomes all the security problems in existing system and
provides high security and efficiency. This is a perfect/optimal solution for
saving/protecting farm from birds and animals. When the module is turned on in
automatic mode and if any animal or bird comes near to the farm then our PIR sensor
detects the motion of the body and sends a alerting signal to the farmer through
raspberry pi interface and cloud and at the same time it will turn on the reppelers i.e.
Buzzer which is used to make a buzz sound, Light to create luminous effect and
Ultrasonic sensors for generating the Ultrasonic waves. Through reppelers our device
can ward off animals and birds.
6.3.2 Manual:
In manual mode if PIR sensor detects any motion then immediately it will be uploaded
to cloud through Raspberry pi gateway and alert will be sent to the farmer then farmer
can manually turn on the repellers to ward off animals and birds.
        6.5 Software Requirement Specification:
    •      SRS:
Software Requirement Specification (SRS) is the starting point of the software
developing activity. As system grew more complex it became evident that the goal of
the entire system cannot be easily comprehended. Hence the need for the requirement
phase arose. The software project is initiated by the client needs. The SRS is the means
of translating the ideas of the minds of clients (the input) into a formal document (the
output of the requirement phase).
The SRS phase consists of two basic activities:
•       Problem/Requirement Analysis:
          The process deals with understanding the problem, goal and constraints.
•       Requirement Specification:
            Here, the focus is on specifying what has been found giving analysis such as
representation, specification languages and tools, and checking the specifications are
addressed during this activity.
            The Requirements phase terminates with the production of the validate SRS
document producing the SRS document is the basic goal of this phase.
•     Document Conventions:
             We have used Tahoma (text size 12). Bold font is used for Main headings
    (text size 16). Normal font is used for sub headings (text size 14).
Font: Tahoma
Main Heading: Bold Font
                          IMPLEMENTATION:
 • IOT Technology:
7.1.1 Internet of Things
        The Internet of Things (IOT) is a system of interrelated computing devices,
mechanical and digital machines, objects, animals or people that are provided with
unique identifiers and the ability to transfer data over a network without requiring
human-to-human or human-to-computer interaction.
 7.1.2 Raspberry Pi
 The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer
 monitor or TV, and uses a standard keyboard and mouse. It is a capable little device
 that enables people of all ages to explore computing, and to learn how to program in
 languages like Scratch and Python. It’s capable of doing everything you’d expect a
 desktop computer to do, from browsing the internet and playing high-definition video,
 to making spreadsheets, word-processing, and playing games. What’s more, the
 Raspberry Pi has the ability to interact with the outside world, and has been used in
 a wide array of digital maker projects, from music machines and parent detectors to
 weather stations and tweeting birdhouses with infra-red cameras. We want to see the
 Raspberry Pi being used by kids all over the world to learn to program and understand
 how computers work.
Raspberry Pi Foundation
 The Raspberry Pi Foundation is a registered educational charity (registration number
 1129409) based in the UK. Our Foundation’s goal is to advance the education of adults
 and children, particularly in the field of computers, computer science and related
 subjects.
7.1.3 Applications of Raspberry pi
 The different applications of the raspberry pi model are
       Media steamer
       Tablet computer
       Home automation
       Internet radio
       Controlling robots
       Cosmic Computer
       Arcade machines
       Raspberry pi based projects
7.2 Software development
7.2.1 Raspberry Pi - Environment Setup
We can start our Raspberry Pi application development on either of the following
operating systems
•         Microsoft Windows XP or later version.
•         Mac OS X 10.5.8 or later version with Intel chip.
•         Linux including GNU C Library 2.7 or later.
Second point is that all the required tools to develop Arduino applications are freely
available and can be downloaded from the Web.
    7.2 Device construction steps:
    Step 1: Solution and Module Preparing.
    Step 2: Hardware Connection.
    Step 3: Dump the code into Raspberry and run.
    Step 4: Get the Sensor connections done.
    Step 5: Make the Sensors Work and System Installation.
7.2.1 Screenshots
                    Raspberry pi
         PIR
   Ultrasonic Sensor
Buzzer
Final Setup
                          SAMPLE CODE
Farm Security
import RPi.GPIO as GPIO
from firebase_admin import db
import firebase_admin
from firebase_admin import credentials
from firebase_admin import auth
import time
import urllib
import urllib.request
PIN_TRIGGER = 7
PIN_ECHO = 11
cred =credentials.Certificate('farm-672f9-firebase-adminsdk-2eud9-
ba87c485bd.json') # name of the downloaded json file
default_app = firebase_admin.initialize_app(cred, {'databaseURL' :'https://farm-
672f9.firebaseio.com//'}) # data base url of your project
root = db.reference()
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(18,GPIO.OUT)#led
GPIO.setup(23, GPIO.IN) #PIR
GPIO.setup(24, GPIO.OUT) #BUzzer
GPIO.setup(PIN_TRIGGER, GPIO.OUT)
GPIO.setup(PIN_ECHO, GPIO.IN)
base_url = " https://api.thingspeak.com/update?api_key=56CU24ALSVDFJM77"
def ultrasonic():
    GPIO.output(PIN_TRIGGER, GPIO.LOW)
   print("Transmitting Ultrasonic Waves")
    time.sleep(2)
    print("Calculating the object distance")
    GPIO.output(PIN_TRIGGER, GPIO.HIGH)
    time.sleep(0.00001)
    GPIO.output(PIN_TRIGGER, GPIO.LOW)
    while GPIO.input(PIN_ECHO)==0:
        pulse_start_time = time.time()
    while GPIO.input(PIN_ECHO)==1:
        pulse_end_time = time.time()
    pulse_duration = pulse_end_time - pulse_start_time
    distance = round(pulse_duration * 17150, 2)
    print("Object is at",distance,"cm")
time.sleep(2) # to stabilize sensor
def get():
  print("get");
  x = str(db.reference('farm-672f9/farm-
672f9/Command/Command'.format()).get())
  print(x)
  if(x == '"ON"'):#Led on
      print("led is on")
      GPIO.output(18,1)
  if (x == '"OFF"'):#Led off
      print("led is off")
      GPIO.output(18,0)
  if(x == '"BON"'):#buzzer_on
      print("Buzzer on")
      GPIO.output(24, True)
  if(x == '"BOFF"'):#buzzer off
      print("Buzzer off")
      GPIO.output(24, False)
  if(x == '"UON"'):#Ultrasonic on
      print("Ultrasonic on")
      ultrasonic()
  if(x == '"UOFF"'):#ultrasonic off
      print("Ultrasonic off")
  if(x == '"ROFF"'):#Repellers off
      print("Repellers off")
      GPIO.output(24, False)
      GPIO.output(18,0)
  if(x == '"RON"'):#Repellers on
      print("Repellers on")
      GPIO.output(24, True)
      GPIO.output(18,1)
  if(x == '"MOFF"'):
      automatic()
def manual():
  print("manual")
  while True:
      print("testing")
      if GPIO.input(23):
              print("Motion Detected...")
              url = base_url+"&field1=1"
              print(url)
              f = urllib.request.urlopen(url)
              response=f.read()
              print('response')
              print(response)
              f.close()
      get()
      time.sleep(1)
def automatic():
  print("automatic")
  while True:
     x = str(db.reference('farm-672f9/farm-
672f9/Command/Command'.format()).get())
     if(x == '"MOFF"'):
        if GPIO.input(23):
              print("Motion Detected...")
              url = base_url+"&field1=1"
              print(url)
              f = urllib.request.urlopen(url)
              response=f.read()
              print('response')
              print(response)
              f.close()
              ultrasonic()
              GPIO.output(24, True)#buzzer
              GPIO.output(18, True)#led
              time.sleep(15) #Buzzer turns on for 0.5 sec
        else:
              print("not detected")
              GPIO.output(24, False)
              GPIO.output(18, False)
              time.sleep(1)
        time.sleep(0.1) #loop delay, should be less than detection delay
     if(x == '"MON"'):
        manual()
while True:
  print("testing")
  x = str(db.reference('farm-672f9/farm-
672f9/Command/Command'.format()).get())
  if (x=='"MON"'):
      manual()
  if(x=='"MOFF"'):
      automatic()
  time.sleep(1)
SCREEN SHOTS
TEST CASES:
Introduction:
The purpose of testing is to discover errors. Testing is the process of trying to
discover every conceivable fault or weakness in a work product. It provides a way to
check the functionality of components, sub-assemblies, assemblies and/or a finished
product. It is the process of exercising software with the intent of ensuring that the
software system meets its requirements and user expectations and does not fail in
an unacceptable manner. There are various types of test. Each test type addresses a
specific testing requirement.
Types of Test:
Unit Testing:
  Unit testing is essentially for the verification of the code produced during the coding
 phase and the goal is test the internal logic of the module/program. In the Generic
 code project, the unit testing is done during coding phase of data entry forms
 whether the functions are working properly or not. In this phase all the drivers are
 tested they are rightly connected or not. Unit testing is usually conducted as part of
 a combined code and unit test phase of the software lifecycle, although it is not
 uncommon for coding and unit testing to be conducted as two different phases.
Execution Testing:
The program is successfully loaded and executed with no execution errors. All the
modules of whole application is tested. The complete performance of the project
“CSE-Labs” is good.
                             CONCLUSION
The problem of crop vandalization by wild animals has become a major social
problem in current time. It requires urgent attention for this problem. Thus, this
project carries a great social relevance as it aims to address this problem. This
project will help farmers in protecting their orchards and fields and save them from
significant financial losses and will save them from the unproductive efforts that they
endure for the protection their fields. This will also help them in achieving better
crop yields thus leading to their economic well-being.
                       12. BIBLIOGRAPHY
http://www.ijariie.com/AdminUploadPdf/A_SMART_FARMLAND_USING_RASPBERRY
_PI_CROP_VANDALIZATION_PREVENTION___INTRUSION_DETECTION_SYSTEM_14
04.pdf
https://www.electroschematics.com/3864/ultrasound-and-insects/
https://www.researchgate.net/publication/256494027_Damage_to_agricultural_yield
_due_to_farmland_birds_present_repelling_techniques_and_its_impacts_an_insight_
from_the_Indian_perspective
http://www.entomoljournal.com/archives/?year=2018&vol=6&issue=3&part=K&Arti
cleId=3641
http://www.ijecscse.org/papers/IETE2017/13.pdf