Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Hackster is hosting Impact Spotlights: Smart Home. Watch the stream live on Thursday!Hackster is hosting Impact Spotlights: Smart Home. Stream on Thursday!
Novandio Fahmi
Published

Esp32 based automated plant watering project + Blynk App

The use of automatic watering can help take care of plants by using the BlynkApp application,.

BeginnerProtip2 days5,902
Esp32 based automated plant watering project + Blynk App

Things used in this project

Story

Read more

Schematics

Circuit Diagrams

Code

Source Code

Arduino
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

LiquidCrystal_I2C lcd(0x27,16,2);
char auth[] = "yeOTwBo8cPnpAEI6E0IoJp4E5ReIJCKI";

char ssid[] = "monitor";
char pass[] = "monitor2021";

BlynkTimer timer;


const int AirValue = 3300;    //Value_1
const int WaterValue = 1124;  //Value_2
const int SensorPin = 36;
int soilMoistureValue = 0;
int soilmoisturepercent=0;

const byte pinRly=23;
int statusAuto;
WidgetLCD lcd1(V0);

BLYNK_CONNECTED() {
  
  Blynk.syncAll();

}

BLYNK_WRITE(V2)
{
  int Status = param.asInt();
  if(Status){
      digitalWrite(pinRly,LOW);
  }else{
      digitalWrite(pinRly,HIGH);
  }
}
BLYNK_WRITE(V3)
{
  statusAuto = param.asInt();
  Blynk.syncVirtual(V2);
}
void myTimerEvent()
{
  Serial.println(statusAuto);
  
  Blynk.virtualWrite(V1, soilmoisturepercent);
}
 
void setup() {
  Serial.begin(115200);
  
  lcd.init();
  lcd.backlight();
  
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("   PENYIRAMAN   ");
  lcd.setCursor(0,1);
  lcd.print("    OTOMATIS    ");

  pinMode(pinRly,OUTPUT);
  digitalWrite(pinRly,HIGH);
  Blynk.begin(auth, ssid, pass,"blynk-cloud.com", 8080);  
  timer.setInterval(1000L, myTimerEvent);  

  lcd1.clear(); //Use it to clear the LCD Widget
  lcd1.print(4, 0, "PENYIRAMAN"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
  lcd1.print(4, 1, "OTOMATIS");   
}
 
 
void loop() 
{
soilMoistureValue = analogRead(SensorPin);  //put Sensor insert into soil
soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);

if(soilmoisturepercent > 100)
{
  soilmoisturepercent=100;
}
else if(soilmoisturepercent <0)
{
  soilmoisturepercent=0;  
}

lcd.clear();
lcd.setCursor(0,0);
lcd.print(" SOIL MOISTURE  ");
lcd.setCursor(5,1);
lcd.print(soilmoisturepercent);
if(statusAuto){
  if(soilmoisturepercent<=50){
      digitalWrite(pinRly,LOW);
  
  }else{
      digitalWrite(pinRly,HIGH);
  }
}
  delay(1000); 
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}

Credits

Novandio Fahmi
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.