AUTOMATICALLY WATERING PLANT USING ARDUINO AND CANYENNE IOT - Unika Repository

  

APPENDIX

Libraries

  //#define CAYENNE_DEBUG // Uncomment to show debug messages #define CAYENNE_PRINT Serial // Comment this out to disable prints and save space #include <CayenneEthernet.h> #include <Servo.h>

  Declare Variable and input token

  #define VS1 V1 //write to virtual pin 1 #define VS3 V3 //write to virtual pin 2 #define VW5 V5 //write to virtual pin 5 char token[] = "vp09anm9c9"; int inputCayenne = 0; int soil = A0; int soil2 = A1; int detik = 0; int menit = 0; int jam = 0; int a1 = 0; int a2 = 0; int a3 = 0; int frac = 0; int b1 = 0; int b2 = 0; int b3 = 0; //servo int servo = 4; Servo aturServo; //relay int relay = 5; int nilaiSoil = 0; int nilaiSoil2 = 0; byte sensorInterrupt = 0; byte sPin = 2; float cF = 4.5; volatile byte putaran; float fR; unsigned int flowMl; unsigned long totalMl; unsigned long oT;

Print IP and token

  Serial.print("IP = "); Serial.begin(9600); Cayenne.begin(token);

Setting variable for servo

  aturServo.attach(servo);

Setting Output and input device

  pinMode(relay, OUTPUT); pinMode(sPin, INPUT); digitalWrite(sPin, HIGH);

Setting the default number for the water flow sensor

   putaran = 0; fR = 0.0; flowMl = 0; TotalMl = 0; oT = 0; attachInterrupt(sensorInterrupt, putaran, FALLING); pinMode(relay, OUTPUT); digitalWrite(soil, HIGH); digitalWrite(soil2, HIGH);

Void to receive input from the IoT server

   CAYENNE_IN(V2) { int valueYangDidapat = getValue.asInt(); if ( valueYangDidapat == 1) { inputCayenne = inputCayenne + 1; } else { inputCayenne = 0; } }

  

To run the cayenne library so that the arduino can connect to cayenne

   Cayenne.run();

  Calling and running void water flow

   WaterFlow();

Setting the start and end limits of sensor readings

   nilaiSoil = analogRead(soil); nilaiSoil = map(nilaiSoil,0,1023,100,0); nilaiSoil2 = analogRead(soil2); nilaiSoil2 = map(nilaiSoil2,0,1023,100,0); delay(500);

Setting if arduino does not get input from the server

   //Serial.println(inputCayenne); if(inputCayenne == 0) {

  

Calling and running void atas() which contains a command to make the servo

move 180 degrees

   atas();

  

Calling and running void relayMati() which contains a command to make the

relay turn off.

   relayMati();

  

Call void checkSoil1 () which contains a command to check the ground state

  1

   cekSoil1();

  

Call void checkSoil2 () which contains a command to check the ground state

  2

   cekSoil2();

  

Call void level1() which contains a command to Watering if the soil on the 1st

plant is dry

   level1(); WaterFlow();

  

Call void level2() which contains a command to Watering if the soil on the

2nd plant is dry

   level2(); WaterFlow();

  

Call void level3() which contains a command to stop watering if the soil on

the 1st plant and 2nd plant is moist

   level3();

Check the soil moisture value

   Serial.print("kelembapan tanaman 1: "); Serial.print(nilaiSoil); Serial.print("%"); Serial.print("\t"); Serial.print("kelembapan tanaman 2: "); Serial.print(nilaiSoil2); Serial.println("%"); }

Setting if arduino get input from the server

   else if(inputCayenne == 1) {

  

Calling and running void bawah() which contains a command to make the

servo move 90 degrees

   bawah();

  

Calling and running void relayHidup() which contains a command to make

the relay turn on.

   relayHidup(); WaterFlow(); }

Sending sensor readings to IoT server

   float s1 = nilaiSoil; float s2 = nilaiSoil2; float w2 = totalMl; Cayenne.virtualWrite(VW5, w2); Cayenne.virtualWrite(VS1, s1); Cayenne.virtualWrite(VS3, s2); }

If the soil is dry variable "a1" so worth 1

  void cekSoil1(){ if(nilaiSoil >= 0 && nilaiSoil <= 39) { a1 = 1; a2 = 0; a3 = 0; //Serial.print("Tanaman 1 Kering"); }

  If the soil is moist variable "a2" so worth 1

   else if(nilaiSoil >= 40 && nilaiSoil <= 79)

   { a1 = 0; a2 = 1; a3 = 0; //Serial.print("Tanaman 1 Lembab"); }

If the soil is too much water variable "a3" so worth 1

   else if(nilaiSoil < 80) { a1 = 0; a2 = 0; a3 = 1; //Serial.print("Tanaman 1 Terlalu banyak Air"); } }

If the soil is dry variable "b1" so worth 1

  void cekSoil2(){ if(nilaiSoil2 >= 0 && nilaiSoil2 <= 39) { b1 = 1; b2 = 0; b3 = 0; //Serial.println("Tanaman 2 Kering"); }

If the soil is moist variable "b2" so worth 1

   else if(nilaiSoil2 >= 40 && nilaiSoil2 <= 79) { b1 = 0; b2 = 1; b3 = 0; //Serial.println("Tanaman 2 Lembab"); }

  If the soil is too much water variable "b3" so worth 1

   else if(nilaiSoil2 < 80) { b1 = 0; b2 = 0; b3 = 1; //Serial.println("Tanaman 2 Terlalu banyak Air"); }

  }

  

If the soil 1 and 2 are dry thenthe machinewill do watering for three and a

half seconds

  void level1(){ if(a1 == 1 && b1 == 1) { //Serial.println("Stage 1 -1 "); bawah(); relayHidup(); delay(2000); relayMati(); atas(); delay(1500); }

  

If the soil 1 is dry and soil 2 are moist thenthe machinewill do watering for

two seconds

   if(a1 == 1 && b2 == 1) { //Serial.println("Stage 1 -2 "); bawah(); relayHidup(); delay(1000); relayMati(); atas(); delay(1000); }

  

If the soil 1 is dry and soil 2 are too much water then the machine will do

watering for 1,7 seconds

   if(a1 == 1 && b3 == 1) { //Serial.println("Stage 1 -3 "); bawah(); relayHidup(); delay(1300); relayMati(); atas(); delay(400); } }

  

If the soil 1 is moist and soil 2 dry then the machine will do watering for 2,8

seconds

  void level2(){ if(a2 == 1 && b1 == 1) {

   //Serial.println("Stage 2 - 1 "); bawah(); relayHidup(); delay(1500); relayMati(); atas(); delay(1300); }

If the soil 1 is moist and soil 2 moist then the machine will not do watering

   if(a2 == 1 && b2 == 1) { //Serial.println("Stage 2 - 2 "); //bawah(); //delay(2000); relayMati(); atas(); }

  

If the soil 1 is moist and soil 2 too much water then the machine will not do

watering

   if(a2 == 1 && b3 == 1) { //Serial.println("Stage 2 - 3 "); //bawah(); //delay(1000) relayMati(); atas(); } }

  

If the soil 1 is too much water and soil 2 dry then the machine will do

watering for 2 second

  void level3(){ if(a3 == 1 && b1 == 1) { //Serial.println("Stage 3 -1 "); bawah(); relayHidup(); delay(1000); relayMati(); atas(); delay(1000); }

  

If the soil 1 is too much water and soil 2 moist then the machine will not do

watering

   if(a3 == 1 && b2 == 1)

   { //Serial.println("Stage 3 -2 "); //bawah(); //delay(2000) relayMati(); atas(); }

  

If the soil 1 is too much water and soil 2 too much water then the machine

will not do watering

   if(a3 == 1 && b3 == 1) { //Serial.println("Stage 3 -3 "); //bawah(); //delay(1000) relayMati(); atas(); } }

To set the degree of rotation on the servo

  void atas() { aturServo.write(90); } void bawah() { aturServo.write(180); }

To set the status of the relay to on or off

  void relayHidup(){ digitalWrite(relay,0); //WaterFlow(); } void relayMati(){ digitalWrite(relay,1); }

  

Void to calculate how much water has passed through the water flow sensor

  void WaterFlow() { if((millis() - oT) > 1000) { fR = ((1000.0 / (millis() - oT)) * putaran) / cF; oldTime = millis(); flowMl = (fR / 60) * 1000; totalMl += flowMl;

   Serial.print("Air yang kluar: "); Serial.print(int(fR)); Serial.print("."); frac = (fR - int(fR)) * 10; Serial.println(frac, DEC) ; Serial.print("L/min"); Serial.print(" Current Liquid Flowing: "); Serial.print(flowMl); Serial.print("mL/Sec"); Serial.print(" Total Air yang kluar: "); Serial.print(totalMl); Serial.println("mL"); putaran = 0; } } void putaranCounter() { // Increment the pulse counter putaran++; }

  Filename: Sindhu_Hartono_Wibowo_13.02.0050_Automatically_watering_plant_using_Ardvino.pdf Date: 2017-07-27 04:11 UTC Results of plagiarism analysis from 2017-07-27 04:13 UTC 2718 matches from 136 sources, of which 32 are online sources.

  PlagLevel: 4.8% /82.4%

[0] (326 matches, 0.0%82.4%) from

  (+ 1 documents with identical matches)

[2] (307 matches, 0.0%78.1%) from

[4] (31 matches, 0.0%6.2%) from

[5] (21 matches, 2.5% /3.5%) from

(+ 1 documents with identical matches)

[7] (21 matches, 2.6% /3.4%) from

[9] (20 matches, 2.4% /3.4%) from (+ 2 documents with identical matches) [12] (20 matches, 2.4% /3.4%) from (+ 2 documents with identical matches) [15] (20 matches, 2.4% /3.3%) from

  (+ 1 documents with identical matches)

[18] (19 matches, 2.4% /3.3%) from

[19] (19 matches, 2.3% /3.3%) from

(+ 1 documents with identical matches)

[21] (19 matches, 2.5% /3.3%) from

[23] (19 matches, 2.5% /3.3%) from

[25] (19 matches, 2.4% /3.3%) from

(+ 1 documents with identical matches)

[27] (19 matches, 2.4% /3.2%) from

[29] (18 matches, 2.5% /3.4%) from

[31] (18 matches, 2.5% /3.4%) from

[33] (18 matches, 2.3% /3.2%) from

(+ 1 documents with identical matches)

[35] (18 matches, 2.3% /3.2%) from

(+ 1 documents with identical matches)

[37] (18 matches, 2.2% /3.2%) from

[39] (18 matches, 2.3% /3.2%) from

(+ 1 documents with identical matches)

  

[49] (18 matches, 2.3% /3.1%) from a PlagScan document of your organisation...R_&_HISTOGRAM.odt" dated 2017-07-25

[50] (18 matches, 2.3% /3.1%) from

[51] (18 matches, 2.3% /3.1%) from

[53] (18 matches, 2.3% /3.1%) from

  (+ 1 documents with identical matches)

[56] (18 matches, 2.3% /3.1%) from

[57] (18 matches, 2.3% /3.1%) from (+ 1 documents with identical matches)

[59] (17 matches, 2.2% /3.1%) from

(+ 3 documents with identical matches)

[63] (17 matches, 2.1% /3.0%) from

[65] (17 matches, 2.2% /3.1%) from

  (+ 1 documents with identical matches)

[68] (17 matches, 2.2% /3.1%) from

[69] (17 matches, 2.2% /3.1%) from

[71] (17 matches, 2.2% /3.0%) from

  (+ 2 documents with identical matches) [75] (17 matches, 2.2% /3.0%) from

[76] (17 matches, 2.2% /3.1%) from

(+ 1 documents with identical matches)

[78] (17 matches, 2.2% /3.1%) from

  (+ 1 documents with identical matches) [81] (17 matches, 2.2% /3.1%) from

[82] (17 matches, 2.2% /3.1%) from

(+ 1 documents with identical matches)

[84] (17 matches, 2.0% /3.1%) from

  (+ 2 documents with identical matches) [88] (8 matches, 1.3% /1.8%) from

[89] (9 matches, 1.2% /1.8%) from

[91] (7 matches, 1.2% /1.8%) from

[93] (7 matches, 0.9% /1.4%) from [95] (7 matches, 0.0%1.4%) from [97] (5 matches, 0.7% /1.2%) from [99] (6 matches, 0.0%1.0%) from

  [106] (6 matches, 0.6% /0.8%) from (+ 1 documents with identical matches) [108] (3 matches, 0.0%0.8%) from

  [109] (2 matches, 0.0%0.7%) from (+ 1 documents with identical matches) [112] (4 matches, 0.2% /0.5%) from

  [113] (2 matches, 0.2% /0.5%) from [115] (3 matches, 0.0%0.4%) from [117] (3 matches, 0.3% /0.6%) from [119] (3 matches, 0.3% /0.6%) from

[121] (3 matches, 0.3% /0.5%) from [123] (4 matches, 0.4% ) from [125] (3 matches, 0.0%0.4%) from [127] (3 matches, 0.2% /0.3%) from

[129] (1 matches, 0.0%0.2%) from [131] (1 matches, 0.0%0.3%) from (+ 1 documents with identical matches) [133] (2 matches, 0.0%0.3%) from [135] (2 matches, 0.1% /0.2%) from

  Settings Sensitivity: Medium Bibliography: Consider text Citation detection: Reduce PlagLevel Whitelist: --

Analyzed document

  =====================1/39====================== PROJECT REPORT AUTOMATICALLY WATERING PLANT USING ARDUINO AND CANYENNE IOT SINDHU HARTONO WIBOWO 13.02.0050 Faculty of Computer Science

Dokumen yang terkait

LAAS OM2M IOT LAB

1 47 34

RANCANG BANGUN SISTEM PENYIRAMAN TANAMAN SECARA OTOMATIS MENGGUNAKAN SENSOR SUHU LM35 BERBASIS MIKROKONTROLER ATMega8535 THE DEVELOPMENT OF AN AUTOMATICALLY PLANTS WATERING SYSTEM USING TEMPERATURE SENSOR LM35 BASED ON MICROCONTROLLER ATMega8535

27 155 66

WEB-BASED EXPERT SYSTEMS FOR DIAGNOSING PEST AND DISEASE IN CHILI PLANT USING FORWARD CHAINING

1 1 15

TEST RESPONSE OF MORPHOLOGICAL RICE PLANT (Oryza sativa L.) IR64, CIHERANG AND PANDAN WANGI VARIETIES USING POLYETHYLENE GLICOL 6000

0 2 13

DESAIN DAN IMPLEMENTASI SISTEM PENGUKURAN KELEMBAPAN TANAH MENGGUNAKAN SMS GATEWAY BERBASIS ARDUINO DESIGN AND IMPLEMENTATION OF SOIL MOISTURE MEASUREMENT SYSTEM USING SMS GATEWAY BASED ON ARDUINO

0 0 7

DESAIN DAN IMPLEMENTASI PEMBANGKIT LISTRIK TENAGA GELOMBANG LAUT MENGGUNAKAN PENDULUM DESIGN AND IMPLEMENTATION OF SEA WAVE POWER PLANT USING THE PENDULUM

0 2 8

SISTEM PERINGATAN DAN MONITORING KEAMANAN PERLINTASAN KERETA API OTOMATIS DENGAN MENGGUNAKAN ARDUINO DAN ANRDROID AUTOMATED RAILWAY CROSSING ALERT AND MONITORING SYSTEM USING ARDUINO AND ANDROID

0 0 7

SISTEM KENDALI PENYIRAMAN DAN PENCAHAYAAN TANAMAN OTOMATIS PADA SMART GREENHOUSE MENGGUNAKAN LOGIKA FUZZY AUTOMATIC LIGHTING AND WATERING PLANTS CONTROL SYSTEM ON SMART GREENHOUSE USING FUZZY LOGIC

0 6 8

SISTEM MONITOR PADA PENGAIRAN OTOMATIS BERDASARKAN KELEMBABAN TANAH DAN SUHU MENGGUNAKAN ANDROID MONITORING SYSTEM OF WATERING AUTOMATION SYSTEM BASED ON SOIL MOISTURE AND TEMPERATURE USING ANDROID

1 1 8

RANCANG BANGUN DAN UJI KINERJA SISTEM KONTROL OTOMATIS PADA IRIGASI TETES MENGGUNAKAN MIKROKONTROLLER ARDUINO MEGA DESIGN AND TEST PERFORMANCE SYSTEM AUTOMATIC CONTROL ON DRIP IRRIGATION USING MICROCONTROLLER ARDUINO MEGA

1 1 10