Fattah
Published

Automated Plant Watering System Based on Internet of Things

With this project, we will be able to water our plant automatically and monitor it from our smartphone.

BeginnerShowcase (no instructions)2 hours6,653
Automated Plant Watering System Based on Internet of Things

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
Grove - Relay
Seeed Studio Grove - Relay
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
SparkFun Soil Moisture Sensor (with Screw Terminals)
SparkFun Soil Moisture Sensor (with Screw Terminals)
×1
DC 12 V Pump
×1

Software apps and online services

Blynk
Blynk

Story

Read more

Schematics

Schematic

Code

Main Code

Arduino
#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp8266.h>
char auth[] = "XXXXXXXXXXXXXXXX"; //Auth Blynk
char ssid[] = "XXXXXXXXXXXXXXXX"; //SSID WiFi
char pass[] = "XXXXXXXXXXXXXXXX"; //Pass WiFi
BlynkTimer timer;

#include "DHT.h"
#define DHTPIN 4 //Deklarasi pin DHT11 = 4 (D2)
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

int relay = 5; //Deklarasi pin relay = 5 (D1)
float persen;

void setup() {
  Blynk.begin(auth, ssid, pass);
  dht.begin();
  pinMode (relay, OUTPUT);
  timer.setInterval(1000L, analogSense);
  timer.setInterval(1000L, th);
}

void loop() {
  Blynk.run();
  timer.run();
}
void analogSense(){ //Sensor Kelembaban Tanah
  float s1 = analogRead(A0);
  persen=((1024-s1)/1024)*100; 
  Blynk.virtualWrite(V7, persen);
  if(persen<=60){ //Jika Kelembaban Air <= 40, maka Pompa ON
    relayON();
  }
  else if(persen>60){ //Jika Kelembaban Air > 40, maka Pompa Off
    relayOFF();
  }
}
void th(){ //Suhu dan Kelembaban (DHT11)
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
}
void relayON(){
  digitalWrite(relay, LOW);
  WidgetLED relay(V8);
  relay.on();
}
void relayOFF(){
  digitalWrite(relay, HIGH);
  WidgetLED relay(V8);
  relay.off();
}

Credits

Fattah

Fattah

15 projects • 17 followers
Electronics Engineer - Embedded System Enthusiast

Comments