Date post: | 15-Jan-2017 |
Category: |
Engineering |
Upload: | parvesh-taneja |
View: | 302 times |
Download: | 4 times |
–
Automation of a Greenhouse
(Controlling Temperature &
Humidity)
Introduction: Internet of Things
PARVESH TANEJA 130020201057
During the period 1995 to 2050, the world's
population is projected to increase by 72
percent and will reach to 9.7 billion.
Raspberry Pi 2 Model B v1.1
v1
-FAO (USA)
CERTIFICATE
This is to certify that the Project entitled “Automation of a Greenhouse
(Controlling Temperature & Humidity)” which is being submitted by-
S. No. Name Enrolment Number
1. Parvesh Taneja 130020201057
is a bonafide work done under my guidance & supervision.
Dr. Sandeep Nagar
(ASSISTANT PROFESSOR)
ACKNOWLEDGEMENT
I would like to take this opportunity to express my profound gratitude and deep regards to
my guide Dr. Sandeep Nagar for his exemplary guidance, monitoring and constant
encouragement throughout the course of this thesis.
I am obliged to staff members of GDGU especially Mr. Lallji Mauryia & Mr. Smruti
Ranjan for the valuable information provided by them in their respective fields. I am
grateful for their cooperation during the period of my assignment.
At last I would like to thank GD Goenka University for introducing this course (IoT) in our
curriculum.
ABSTRACT
The aim of this project is to make a SCADA (Supervisory Control And Data Acquisition)
system, which automatically controls the environmental condition (Humidity and
Temperature) of the greenhouse (Supervisory Control) as well as will enables us to
remotely control and view the status (Conditions) of the greenhouse (Remotely monitoring
and controlling).
For healthy growth of crops certain conditions should be favourable like temperature, Sun
Light, Water and humidity etc.
Global Warming and is one of the biggest threat to crops so we need to control all the
conditions which might destroy our crops, Moreover with increase in human population
land for farming will decrease, which will ultimately result in increased of food items.
Terrace farming (rooftop farming) also saves money one can grow vegetables at 50p/kg1.
This project is based on Raspberry pi (credit-card sized computer) which will control the
system, will monitor the system and will log all the data to database (LAMP Server).
It will keep track of-
Temperature
Humidity
All of the processes can be controlled and monitored remotely.
1 For More information- http://timesofindia.indiatimes.com/city/kolkata/Go-for-terrace-farming-for-organic-veggies-at-50p/kg/articleshow/48992436.cms
CONTENTS
1. INTRODUCTION: INTERNET OF THINGS .................................................................................... 1
2. SOME POPULAR APPLICATIONS OF INTERNET OF THINGS ................................................... 2
1. SMART HOME ............................................................................................................................ 3
2. SMART CITY .............................................................................................................................. 3
3. SMART GRIDS ........................................................................................................................... 3
4. SMART FARMING ...................................................................................................................... 4
3. LIST OF COMPONENTS USED/ ITEMS REQUIRED .................................................................... 5
4. DETAILS/SPECIFICATIONS OF COMPONENTS USED ............................................................... 6
1. RASPBERRY PI (MODEL B V1.1) .............................................................................................. 6
2. CONNECTING WIRES / JUMPER WIRES ............................................................................... 12
3. HUMIDITY & TEMP. SENSOR: DHT 11 OR DHT22 ................................................................. 13
4. RELAY MODULE (8 CHANNEL RELAY MODULE) .................................................................. 18
5. DC AXIAL COOLING/VENTILATING FAN ................................................................................ 21
6. POWER OUTLET ..................................................................................................................... 21
7. POWER CORD ......................................................................................................................... 22
8. HEATING BULB & BULB HOLDER ........................................................................................... 22
5. MAKING OF DEVICE . ................................................................................................................. 23
1. INSTALLING RASPBIAN ON RASPBERRY PI ......................................................................... 23
STEP 1: DOWNLOADING NOOBS .............................................................................................. 23
STEP 2: PREPAIRING SD CARD ................................................................................................ 24
STEP 3: COPYING FILES TO SD CARD ..................................................................................... 24
STEP 4: CONNECTING RASPBERRY PI .................................................................................... 24
STEP 5: FOLLOW INSTRUCTION ON SCREEN ......................................................................... 25
STEP 6: FOLLOW INSTRUCTION ............................................................................................... 25
STEP 6: CONFIGURE RASPBERRY PI AFTER INSTALLING RASPBIAN .................................. 26
STEP 7: FINISH AND SHUTDOWN RASPBERRY PI .................................................................. 26
2. INSTALLING LAMP SERVER ON RASPBERRY PI .................................................................. 28
STEP 1: INSTALLING LAMP ........................................................................................................ 28
STEP 2: CREATING MYSQL PASSWORD FOR DATA BASE ..................................................... 29
STEP 3: OPENING WEBSITE (LOCAL SERVER) ........................................................................ 29
STEP 4: INSTALLING PHP .......................................................................................................... 30
STEP 5: INSTALLING WIRING PI ................................................................................................ 30
STEP 6: INSTALLING DRIVERS FOR DHT22 SENSOR ............................................................. 30
3. INSTALLING THE TEMPERATURE AND HUMIDITY SENSOR ............................................... 31
STEP 1: CONNECTING SENSOR TO RPI ................................................................................... 31
STEP 2: CHECKING DATA FROM SENSOR ............................................................................... 31
STEP 3: INSTALLING SENSOR DATABASE ............................................................................... 32
STEP 4: ACCESSING SENSOR DATABASE FROM BROWSER ................................................ 32
STEP 5: CREATING CRONJOB ................................................................................................... 33
4. INSTALLING RELAYS ............................................................................................................. 34
STEP 1: WIRING RELAYS ........................................................................................................... 34
STEP 2: OPENING CONTROLLING BUTTONS IN BROWSER ................................................... 34
STEP 3: CONNECT POWER SOCKET AND BULB HOLDER ...................................................... 35
5. INSTALLING DC FAN .................................................................................................................. 36
STEP 1: WIRING FAN .................................................................................................................. 36
STEP 2: SETTING THRESHOLD VALUE..................................................................................... 36
STEP 3: CREATING CRONJOB ................................................................................................... 36
6. REFEERENCES ........................................................................................................................... 37
1
1. INTRODUCTION: INTERNET OF THINGS
The Internet of Things (IoT) as the name suggests is the system (web) of physical articles like gadgets,
vehicles, structures and different things, inserted with hardware, programming, sensors, and system
availability that empowers these items to gather
information.
"Things," in the IoT sense, can allude to a wide
assortment of gadgets, for example, heart checking
inserts, biochip transponders on ranch creatures,
electric shellfishes in beach front waters, autos with
implicit sensors, DNA examination gadgets for
natural/sustenance/pathogen observing or field
operation gadgets that help firefighters in hunt and
protect operations.
Lawful researchers recommend to take a look at "Things" as close blend of equipment, programming,
information and administration. These gadgets gather valuable information with the assistance of different
existing advancements and afterward self-ruling stream the information between different gadgets.
Current business sector illustrations incorporate sharp indoor regulator frameworks and washer/dryers that
utilization Wi-Fi for remote observing.
Internet of Things is one of the platforms for today's Smart City, and Smart Energy Management Systems.
Figure 1
“Because the Internet of Things has the
potential to awaken 99 percent of the
devices around us, it’s more important
than ever for educational institutions and
organizations to remain on the cutting
edge of this evolution,”
- Rus adds.
2
2. SOME POPULAR APPLICATIONS OF INTERNET OF
THINGS
Here are ten most popular applications of IoT according to www.iot-analytics.com (http://iot-
analytics.com/).
Figure 2
3
1. SMART HOME
Smart Home unmistakably emerges, positioning as most noteworthy Web of Things
application on all deliberate channels. More than 60,000 individuals as of now scan
for the expression "Smart Home" every month.
More organizations are dynamic in smart home than some other application in the
field of IoT. This rundown incorporates noticeable startup names, for example,
Home or AlertMe and in addition various multinational enterprises like Philips,
Haier, or Belkin.
2. SMART CITY
Smart city traverses a wide assortment of utilization cases, from movement
administration to water conveyance, to waste administration, urban security and
ecological checking. Its prominence is energized by the way that numerous Smart
City arrangements guarantee to mitigate genuine agonies of individuals living in
urban communities nowadays. IoT arrangements in the territory of Smart City tackle
activity blockage issues, diminish commotion and contamination and make urban
communities more secure.
3. SMART GRIDS
Brilliant networks is a unique one. A future brilliant matrix guarantees to utilize data
about the practices of power suppliers and customers in a robotized style to enhance
the effectiveness, dependability, and financial aspects of power. 41,000 month to
month Google seeks highlights the idea's notoriety. Notwithstanding, the absence of
tweets (Only 100 every month) demonstrates that individuals don't have much to say
in regards to it.
4
4. SMART FARMING
Smart cultivation is a regularly neglected business-case for the internet of Things.
This thought has not yet achieved huge scale consideration. Brilliant cultivating will
turn into the essential application field in the overwhelmingly agricultural item.
5
3. LIST OF COMPONENTS USED/ ITEMS REQUIRED
S. No. Name of Component/ Item Name Quantity
1. Raspberry Pi 1
2. Connecting Wires / Jumper Wires 30-35approx.
3. Humidity & Temp. Sensor (DHT11) 1
4. Relay Module 1 (8 channel relay module)
5. DC Axial cooling/ventilating fan 1
6. Power Cord 1
7. Power Outlet (Power Socket) 1
8. 2N222 Transistors 1
9. 10k resistors 1
10. Heating Bulb 1
11. Bulb Holder 1
12. Power Supply (Mobile Charger) 1
13. Empty Plastic Box 1
14. Multipurpose PCB 1
15. LED 2
16. Laptop/PC2 1
2 It is not a part of the Device, It was used to access Raspberry Pi using SSH.
6
4. DETAILS/SPECIFICATIONS OF COMPONENTS USED
1. RASPBERRY PI (MODEL B V1.1)
Figure 3
FEATURES
The Raspberry Pi 2 Model B is the second generation Raspberry Pi.Compared to the
Raspberry Pi 1 it has:
A 900MHz quad-core ARM Cortex-A7 CPU
1GB RAM
4 USB ports
40 GPIO pins
Full HDMI port
Ethernet port
Combined 3.5mm audio jack and composite video
Camera interface (CSI)
Display interface (DSI)
Micro SD card slot
7
RASPBERRY PI HARDWARE
GPIO
General Purpose Input/Output pins on the Raspberry Pi, One powerful feature of the Raspberry Pi is the
row of GPIO (general purpose input/output) pins along the edge of the board.
Figure 4
These pins are a physical interface between the Pi and the outside world. At the simplest level, you can
think of them as switches that you can turn on or off (input) or that the Pi can turn on or off (output).
Seventeen of the 26 pins are GPIO pins; the others are power or ground pin
Figure 5
You can program the pins to interact in amazing ways with the real world. Inputs don't have to come
from a physical switch; it could be input from a sensor or a signal from another computer or device, for
example. The output can also do anything, from turning on an LED to sending a signal or data to another
8
device. If the Raspberry Pi is on a network, you can control devices that are attached to it from
anywhere and those devices can send data back.
Connectivity and control of physical devices over the internet is a powerful and exciting thing, and the
Raspberry Pi is ideal for this.
Working of GPIO
Ignoring the Pi for a moment, one of the simplest electrical circuits that you can build is a
battery connected to a light source and a switch (the resistor is there to protect the LED):
Figure 6
When we use a GPIO pin as an output, the Raspberry Pi replaces both the switch and
the battery in the above diagram. Each pin can turn on or off, or go HIGH or LOW in
computing terms. When the pin is HIGH it outputs 3.3 volts (3v3); when the pin is LOW
it is off.
Here's the same circuit using the Raspberry Pi. The LED is connected to a GPIO pin
(which can output +3v3) and a ground pin (which is 0v and acts like the negative terminal
of the battery):
9
Figure 7
A note on pin numbering
When programming the GPIO pins there are two different ways to refer to them: GPIO numbering and
physical numbering.
GPIO numbering
These are the GPIO pins as the computer sees them. The numbers don't make any sense to humans, they
jump about all over the place, so there is no easy way to remember them. You will need a printed
reference or a reference board that fits over the pins.
Figure 8
10
Physical numbering
The other way to refer to the pins is by simply counting across and down from pin 1 at the top left
(nearest to the SD card). This is 'physical numbering' and it looks like this:
Figure 9
11
Power Supply
The device is powered by a 5V micro USB supply. Exactly how much current (mA) the
Raspberry Pi requires is dependent on what you connect to it. We have found that
purchasing a 1.2A (1200mA) power supply from a reputable retailer will provide you
with ample power to run your Raspberry Pi.
Typically, the model B uses between 700-1000mA depending on what peripherals are
connected; the model A can use as little as 500mA with no peripherals attached. The
maximum power the Raspberry Pi can use is 1 Amp. If you need to connect a USB
device that will take the power requirements above 1 Amp, then you must connect it to an
externally-powered USB hub.
The power requirements of the Raspberry Pi increase as you make use of the various
interfaces on the Raspberry Pi. The GPIO pins can draw 50mA safely, distributed across
all the pins; an individual GPIO pin can only safely draw 16mA. The HDMI port uses
50mA, the camera module requires 250mA, and keyboards and mice can take as little as
100mA or over 1000mA Check the power rating of the devices you plan to connect to the
Pi and purchase a power supply accordingly.
Figure 10
12
2. CONNECTING WIRES / JUMPER WIRES
Figure 11
There are 3 types of Jumper Wires-
1. Male to Male Jumper wires (Wires on Right side in Fig. 11)
2. Female to Male Jumper wires (Wires in between in Fig. 11)
3. Female to Female Jumper wires (Wires on Left side in Fig. 11)
13
3. HUMIDITY & TEMP. SENSOR: DHT 113 OR DHT22
Figure 12
Humidity and Temperature sensor measures temperature and humidity. DHT11 has been
used in this project. It is recommended to use DHT22 instead of DHT11 for better results.
There are 3 pins Vcc, Ground and Data (Signal)
3 Data sheet of DHT 11 attached in last part of this report.
14
Working and Principle of DHT11 / DHT22
Figure 13
These humidity and temperature sensor consist of 2 components-
1. Humidity Component
2. Thermistor (or NTC temperature sensor)
Connected to an IC behind the sensor.
15
Humidity Measurement
Strictly speaking no sensor measures humidity directly but measures the effect (property)
like change in resistance when temperature increases or humidity increases.
Here a moisture holding substrate (usually a salt or conductive plastic polymer) is used it
hold (absorbs for short time) water vapors that are present in the air.
This substrate is present between electrodes (Attached surface to surface) as the moisture
increases the substrate ions are released which increases conductivity (Decreases
resistance) between both the elctrodes.
This change in resistance is measured and processed by the IC which and sends the
processed signals to Raspberry Pi.
Figure 14
16
Temperature Measurement
NTC4 temperature sensor (thermistor) is used for measurement of temperature.
A thermistor is a variable resistor whose value of resistance changes with change in
temperature.
These sensors are made by sintering of semi conductive materials such as ceramics or
polymers.
Figure 15
4 A Negative Temperature Coefficient (NTC) is a condition wherein the resistance or ( some other characteristic) of a material decreases with increasing temperature
17
Comparison between DHT11 and DHT22
Table above shows the difference between both DHT11 and DHT22.
DHT 22 is more costly than DHT11. DHT 22 is recommended but here for this project
one can use DHT 11, if maximum and minimum temperature falls within the range.
Since, operating voltages and maximum current is same any of them can be used with
same setup.
18
4. RELAY MODULE (8 CHANNEL RELAY MODULE)
Figure 16
Relays5 are electromechanical switches as the name suggests it electronic + mechanical device, relay has
an inductor coil inside it which energises when current is passed through it and acts like a magnet. This
inductor coil is responsible for opening and closing of switch.
5 Here in this project SPDT (Single pole double throw) relay have been used.
19
Working and principle of a relay
Figure 17
Principle behind working of a relay is that whenever a current is passed through a coil
(inductor) magnetic field is generated which is responsible for the mechanical mechanism
(attraction of Armature) which results in closing and opening of the circuit.
Electric relay contact types
SPST – Single Pole Single Throw
SPDT – Single Pole Double Throw
DPST – Double Pole Single Throw
DPDT – Double Pole Double Throw
20
Figure 18
Single Pole Double Throw
Figure 19
These single pole double throw type connections are used in this project.
NC = Normally Closed
NO = Normally Open
C = Common
B-M = Break-Make
21
5. DC AXIAL COOLING/VENTILATING FAN
Figure 20
These are normal CPU fans that are used for cooling and ventilating. Here in this project
they are used ventilation Fan for exhausting water vapours.
These fans operate on 5 Volts which can be easily supplied by Raspberry Pi.
6. POWER OUTLET
Figure 21
This is a normal socket to plug in Pump. In this project 220V AC has been used.
22
7. POWER CORD
Figure 22
This is for connecting AC supply to socket.
8. HEATING BULB & BULB HOLDER
Figure 23
23
5. MAKING OF DEVICE .
1. INSTALLING RASPBIAN ON RASPBERRY PI
STEP 1: DOWNLOADING NOOBS
Figure 24
NOOBS is an installer package for Raspberry Pi for installing an Operating System.
It can be downloaded for free from http://www.raspberrypi.org/downloads/
24
STEP 2: PREPAIRING SD CARD
Plug in your memory card to your laptop, you can use a card too if you can’t directly plug
it into your laptop.
Format your memory card to FAT.
Minimum 16 GB and a class 10 memory card is recommended to use in Raspberry Pi.
STEP 3: COPYING FILES TO SD CARD
Unzip the downloaded NOOBS zip folder and copy all the files directly to your SD card
and unmounts it safely from laptop/PC.
STEP 4: CONNECTING RASPBERRY PI
Connect HDMI cable, USB keyboard, USB mouse and Network cables along with the
Micro USB Power Supply directly from your mobile charger.
Don’t forget to plug in your memory card.
25
STEP 5: FOLLOW INSTRUCTION ON SCREEN
Figure 25
STEP 6: FOLLOW INSTRUCTION
Select Raspbian and press enter.
26
STEP 6: CONFIGURE RASPBERRY PI AFTER INSTALLING RASPBIAN
Figure 26
When Raspbian is installed open Terminal either clicking from menu or simply by
pressing “Cntrl+T ”.
Type sudo raspi-config , change password “qaz”(in my case) and enable SSH
server.
Set time and date and boot to command line.
STEP 7: FINISH AND SHUTDOWN RASPBERRY PI
Type sudo halt -p and press Enter in the command line to shut down your
Raspberry Pi.
27
This is how your screen will look like when you restart your raspberry pi.
Figure 26
28
2. INSTALLING LAMP SERVER ON RASPBERRY PI
LAMP is a standard model of web service solution of its original four open-source
components.
L = Linux operating system (Raspbian).
A = Apache HTTP Server.
M = MySQL (Relational database management system (RDBMS)).
P = PHP (Programming Language).
Since SSH has been enabled now one can access it using SSH client like Putty and can
control everything without using screen, keyboard and mouse.
STEP 1: INSTALLING LAMP
Install LAMP by entering sudo apt-get install apache2 mysql-server php5-mysql build-essential git-core
When asked to install type y press enter to confirm
Figure 27
29
STEP 2: CREATING MYSQL PASSWORD FOR DATA BASE
Figure 28
Enter password “qaz”(in my case).
STEP 3: OPENING WEBSITE (LOCAL SERVER)
Checking if everything is working fine open browser and write IP in browser
Figure 29
30
STEP 4: INSTALLING PHP
Install PHP5 module for Apache2
sudo apt-get install libapache2-mod-php5
STEP 5: INSTALLING WIRING PI
Install Wiring Pi
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
STEP 6: INSTALLING DRIVERS FOR DHT22 SENSOR
Install the DHT22 Sensor drivers.
Type cd ~ to return to your home directory.
git clone https://github.com/technion/lol_dht22
cd lol_dht22
./configure
sudo make install
31
3. INSTALLING THE TEMPERATURE AND HUMIDITY SENSOR
STEP 1: CONNECTING SENSOR TO RPI
Wire the DHT22 sensors to raspberry pi
Ground to black - pin 6
VCC to 3.3v red - pin 1
Data to pins any of one yellow - pins 3, 5, 7
Figure 30
STEP 2: CHECKING DATA FROM SENSOR
Login by typing your user name and password and open terminal
type: sudo loldht 8
If everything is fine you will see all the data (current values of temperature and humidity)
32
STEP 3: INSTALLING SENSOR DATABASE wget http://www.raspiviv.com/databases/datalogger.sql
mysql -u root -p < datalogger.sql
Create a new Mysql user
mysql -u root -p
CREATE USER 'datalogger'@'localhost' IDENTIFIED BY
'datalogger';
GRANT ALL PRIVILEGES ON datalogger . * TO
'datalogger'@'localhost';
STEP 4: ACCESSING SENSOR DATABASE FROM BROWSER
Make sure to copy all the files provided on github by me.
(https://github.com/TanejaParvesh)
sudo php /var/www/html/sensor.php
Figure 31
33
STEP 5: CREATING CRONJOB
Type sudo crontab -e in the terminal and press Enter
Add the sensor cron job: * * * * * php /var/www/html/sensor.php
Add the history cron job: 59 23 * * * php /var/www/html/history.php
Press Ctrl+x save by pressing y and Enter
34
4. INSTALLING RELAYS
STEP 1: WIRING RELAYS
Wire the relays -
ground pin 6
5v pin 1
Signal to relay by physical pins 11, 12
STEP 2: OPENING CONTROLLING BUTTONS IN BROWSER
Open a browser and Open IP of your Raspberry Pi buttons will be shown.
LED indicator lights along with the classic relay click will let you know they're working.
Figure 32
35
STEP 3: CONNECT POWER SOCKET AND BULB HOLDER
Connect power socket and bulb holder
One wire from relay
Other wire directly from supply
36
5. INSTALLING DC FAN
STEP 1: WIRING FAN
Connect the positive fan wires to 5 volt pin
Connect the negative terminal of fan wires to E (Emitters) of the transistors
Ground both C (Collectors) of the transistors
Connect pin 18 to B (Base) of the transistors with a 10K resistor.
Figure 33
STEP 2: SETTING THRESHOLD VALUE
Set the fan's humidity threshold
sudo nano /var/www/html/fanh1.php
Edit the threshold to your desired value
STEP 3: CREATING CRONJOB
Create a cron job to regulate humidity.
*/5 * * * * php /var/www/html/fanh1.php
37
6. REFEERENCES
S. NO. Sources
1 http://www.acumera.net/2015/07/white-paper-protecting-your-network-from-vendor-
vulnerabilities/
2 http://iot-analytics.com/10-internet-of-things-applications/
3 https://www.raspberrypi.org/
4 http://i.ebayimg.com/00/s/NTAwWDUwMA==/z/BcAAAOSwxp9W3DYq/$_12.JPG
5 http://cmostronics.in/product_info.php/humidity-temperature-sensor-dht-p-313
6 http://howtomechatronics.com/tutorials/arduino/dht11-dht22-sensors-temperature-and-
humidity-tutorial-using-arduino/
7 http://howtomechatronics.com/tutorials/arduino/dht11-dht22-sensors-temperature-and-
humidity-tutorial-using-arduino/
8 http://hub360.com.ng/shop-2/8-channel-relay/
9 http://www.electronics-tutorials.ws/io/io_5.html
10 http://www.phidgets.com/docs/3051_User_Guide
11 http://www.amazon.in/Axial-Cooling-Fan-SIZE-9-2x9-2x2 5cm/dp/B01A7E74N4?tag=googi
nhydr 18418-21&tag=googinkenshoo-21&ascsubtag=96977eea-ff9f-4b9e-ba9e-
6e263c8a6302
12 http://www.amazon.in/Anchor-Multi-Socket-30373 White/dp/B00V4VIHH2?tag=googinhydr
18418-21&tag=googinkenshoo-21&ascsubtag=96977eea-ff9f-4b9e
13 http://teamnovak.com/shop/index.php?main_page=index&cPath=14_59
14 http://news.mit.edu/2016/mit-professional-education-announces-new-online-course-internet-
things-0408
38