Muhammad Alif FahmiMuhammad Solihin
Published

IOT-Based Plant Watering System

"Automate plant care 'IoT-Based Plant Watering System' with ESP32, monitored through Blynk for efficient and smart watering management. "

BeginnerFull instructions provided883
IOT-Based Plant Watering System

Things used in this project

Hardware components

Capacitive Soil Moisture Sensor
×1
Mikrokontroler ESP 32
×1
Water Pump
×1
LCD 16X2
×1
Relay 5v
×1
Project Board
×1
Kabel Jumper Male-Female
×1
I2C Serial Interface Board For LCD Character Adress Changeable Module
×1

Software apps and online services

Windows 10
Microsoft Windows 10
Arduino IDE
Arduino IDE
Blynk
Blynk

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Plier, Needle Nose
Plier, Needle Nose

Story

Read more

Custom parts and enclosures

Diagram Blok

Schematics

Schematic diagram of soil moisture monitoring with esp32

Code

This code is used to monitor soil moisture

Arduino
#define uS_TO_S_FACTOR 1000000 // Mengkonversi milisecon ke secon
#define TIME_TO_SLEEP 30  // waktu menuju sleep 30 secon

//Inisiasi Untuk Tampilan Blynk
#define BLYNK_TEMPLATE_ID "TMPL6MZS87Nhg"
#define BLYNK_TEMPLATE_NAME "soil moisture"
#define BLYNK_AUTH_TOKEN "_nf78rAe8RICzVcEBhtkIqDXOeSBYPj3"


#define BLYNK_PRINT Serial

//Library Yang Digunakan
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
 #include <LiquidCrystal_I2C.h>
#include <Wire.h>

char auth[] = BLYNK_AUTH_TOKEN;

// SSID dan Pasword yang  digunakan
char ssid[] = "Wifiku ";
char pass[] = "@polije.ac.id";



BlynkTimer timer;
//Pin alamat yang digunakan
LiquidCrystal_I2C lcd(0X27 ,16, 2);
const int relay = 4;    // deklarasi pin dht11 14
const int soilmoisture = 33;  //deklarasi pin sensor soilmoisture 34
float persen;

void setup()
{
  
  Serial.begin(115200);
  pinMode (relay,OUTPUT);
  Blynk.begin(auth, ssid, pass, "blynk.cloud", 8080);
  timer.setInterval(1000L, analogSense);   //Waktu pembacaan memory pada deepsleep
//Tampilan Awal  LCD
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("    Penyiram");
  lcd.setCursor(0,1);
  lcd.print("    Otomatis");
  delay(5000);
  lcd.clear();
//Pengulangan hasil pembacaan sensor
  for(int i=0; i<5; i++){
    analogSense();
    delay(500);
}
  //pengaturan untuk timer DeepSleep
  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
  Blynk.run();
  timer.run(); 
}

void loop()
{
  Blynk.run();
  timer.run();  
}
 void analogSense(){   //Sensor kelembaban tanah
    float soil = analogRead(soilmoisture);  //mendeteksi nilai dari sensor soil moisture
    persen=(soil/8192)*100;  //mempersentasikan hasil pembacaan nilai sensor ke persen
//Tampilan pada serial moitor
    Serial.print("\nSoil Moisture: ");
    Serial.print(soil);
    //delay(800);
    Serial.print("Hasil Persen: ");
    Serial.print(persen);
    //delay(900);
//Tampilan pada Blynk melalui virtual PIN
    Blynk.virtualWrite(V0, soil);
    Blynk.virtualWrite(V2, persen);

//Untuk kondisi tanah kering
     if(persen>25){  //jika kelembaban tanah <= 25, maka pompa on
    relayON();
    lcd.setCursor(0,0);
    lcd.print("T Kering: ");
    lcd.print(persen);
    lcd.print("%");
    lcd.setCursor(0,1);
    lcd.print("Pompa Nyala");

  }

//Untuk kondisi  tanah basah
    else if(persen<=25){// jika kelembaban tanah > 25 pompa off
    relayOFF();
    lcd.setCursor(0,0);
    lcd.print("T Basah: ");
    lcd.print(persen);
    lcd.print("%");
    lcd.setCursor(0,1);
    lcd.print("Pompa  Mati ");
    }
    delay(100);
  }

//Inisiasi penggunaan relay
  void relayON(){
  digitalWrite(relay, HIGH);
  WidgetLED relay(V1);
  relay.on();
}
  void relayOFF(){
  digitalWrite(relay, LOW);
  WidgetLED relay(V1);
  relay.off();
}

Credits

Muhammad Alif Fahmi
1 project • 1 follower
Muhammad Solihin
1 project • 1 follower

Comments