이정후김동희Choi AhYoung김민주
Created July 13, 2018

Automatic Residual Checking Spray System

Curious about the amount of pesticide left? Do you want automatic spraying of pesticides?

79
Automatic Residual Checking Spray System

Things used in this project

Hardware components

WIZ750SR-TTL-EVB Kit
WIZnet WIZ750SR-TTL-EVB Kit
×1
Arduino Mega 2560
Arduino Mega 2560
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1

Software apps and online services

Arduino IDE
Arduino IDE
MQTT
MQTT

Story

Read more

Schematics

Circuit of Ardino and Sensors

Circuit Flow

Code

Wiz750SR with Broker and Arduino

C/C++
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "DHT.h"

#define DHTPIN 2    
#define DHTTYPE DHT11  

LiquidCrystal_I2C lcd (0x27,16,2);
DHT dht(DHTPIN, DHTTYPE);

char tm[]="tm";
char ht[]="";
char data[10];
int Trig_Pin = 9;
int Echo_Pin = 8;
int Led1 = 10;
int Led2 = 11;

void setup() 
{
  Serial.begin(9600);
  Serial2.begin(9600);
  
  pinMode(Echo_Pin,INPUT);
  pinMode(Trig_Pin,OUTPUT);
  pinMode(Led1,OUTPUT);
  pinMode(Led2,OUTPUT);
 
  lcd.begin(16,2);
  lcd.init();
  lcd.backlight();
  
  dht.begin();
}

void loop() 
{
  unsigned long duration; 
  float distance;
  int top = 15;
  //duration = the time from trig to echo
  //distance = distance from top to liquid
 
  float h = dht.readHumidity(); 
  float t = dht.readTemperature();
  
  if (isnan(h) || isnan(t)) 
  { Serial.println("Failed to read from DHT sensor!"); }
  
  digitalWrite(Trig_Pin,LOW);
  digitalWrite(Echo_Pin,LOW);
  delayMicroseconds(10);
  digitalWrite(Trig_Pin,HIGH);
  delayMicroseconds(10);
  digitalWrite(Trig_Pin,LOW);

  duration = pulseIn(Echo_Pin,HIGH);
  distance = ((float)(340*duration)/10000)/2;

  Serial.print("Residue : ");
  Serial.println(top-distance);
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  
  Serial2.print("/");
  Serial2.print(t);
  Serial2.print("/");    
  Serial2.print(h);
  Serial2.print("/");
  
  delay(1000);


  if((top-distance) < (top*0.1))
  {
    digitalWrite(Led2,HIGH);
    lcd.clear();
    lcd.setCursor(0,1);
    lcd.print("Empty");
    Serial.println("Empty");
    Serial2.println("Empty");
    delay(1000);
    lcd.clear();
  }
  else {digitalWrite(Led2,LOW); Serial2.println('0'); delay(500);}
  
  lcd.setCursor(0,0);
  lcd.print("Temperature : ");
  lcd.setCursor(0,1);
  lcd.print(t);
  delay(500);
  lcd.clear();
  
  lcd.setCursor(0,0);
  lcd.print("Humidity : ");
  lcd.setCursor(0,1);
  lcd.print(h);
  delay(500);
  
  lcd.setCursor(0,0);
  lcd.print("Residue : ");
  lcd.setCursor(0,1);
  lcd.print(top-distance);
  delay(500);
 
if( (t>=27 && t<=36) || (h>=70 && h<=80) )
 {
    digitalWrite(Led1,HIGH);
    lcd.clear();
    delay(500);
    lcd.setCursor(0,0);
    lcd.print("Spray the ");
    lcd.setCursor(0,1);
    lcd.print("pesticide!!");
    Serial.println("temperature data is:  ");
    Serial.println(t);  
   delay(500);
 }
 else { 
 digitalWrite(Led1,LOW);
    delay(500);
}  

}

Credits

이정후

이정후

1 project • 1 follower
김동희

김동희

0 projects • 0 followers
Choi AhYoung

Choi AhYoung

0 projects • 1 follower
김민주

김민주

0 projects • 1 follower

Comments