Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP8266 NodeMCU Controlled Smart Plant Watering System with Blynk App Integration

View and Edit Project In Cirkit DesignerImage of ESP8266 NodeMCU Controlled Smart Plant Watering System with Blynk App Integration

Smart Plant System Documentation

Summary

The Smart Plant System is designed to monitor and control the environmental conditions of a plant. It utilizes an ESP8266 NodeMCU microcontroller to read data from a DHT11 humidity and temperature sensor, a soil moisture sensor, and a PIR motion sensor. The system displays the collected data on an I2C LCD screen and controls a water pump through a 1-channel relay. The water pump can be activated either automatically based on the soil moisture level or manually using a pushbutton. Additionally, the system is capable of sending data to the Blynk app for remote monitoring.

Component List

ESP8266 NodeMCU

DHT11 Humidity and Temperature Sensor

PIR Sensor

I2C LCD 16x2 Screen

1-Channel Relay (5V 10A)

Soil Moisture Module

SparkFun Soil Moisture Sensor

Water Pump

Battery Case

Pushbutton

Wiring Details

ESP8266 NodeMCU

DHT11 Humidity and Temperature Sensor

PIR Sensor

I2C LCD 16x2 Screen

1-Channel Relay (5V 10A)

Soil Moisture Module

SparkFun Soil Moisture Sensor

Water Pump

Battery Case

Pushbutton

Documented Code

/*
 * Smart Plant System with Blynk
 * This code reads data from a DHT11 sensor, a soil moisture sensor, and a PIR sensor.
 * It displays the data on an I2C LCD and controls a water pump via a relay.
 * The water pump can be activated automatically based on soil moisture levels
 * or manually using a pushbutton. Data is also sent to the Blynk app.
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#include <BlynkSimpleEsp8266.h>

#define DHTPIN D4
#define DHTTYPE DHT11
#define SOIL_MOISTURE_PIN A0
#define PIR_PIN D5
#define RELAY_PIN D3
#define BUTTON_PIN D7

char auth[] = "YourAuthToken";
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

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

void setup() {
  pinMode(RELAY_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT);
  dht.begin();
  lcd.begin();
  lcd.backlight();
  lcd.print("Smart Plant");
  delay(2000);
  lcd.clear();
  Blynk.begin(auth, ssid, pass);
}

void loop() {
  Blynk.run();
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  int soilMoisture = analogRead(SOIL_MOISTURE_PIN);
  int pirState = digitalRead(PIR_PIN);
  int buttonState = digitalRead(BUTTON_PIN);

  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(t);
  lcd.print("C");
  lcd.setCursor(0, 1);
  lcd.print("Humidity: ");
  lcd.print(h);
  lcd.print("%");
  delay(2000);

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Soil: ");
  lcd.print(soilMoisture);
  lcd.setCursor(0, 1);
  lcd.print("PIR: ");
  lcd.print(pirState ? "Motion" : "No Motion");
  delay(2000);

  Blynk.virtualWrite(V1, t);
  Blynk.virtualWrite(V2, h);
  Blynk.virtualWrite(V3, soilMoisture);
  Blynk.virtualWrite(V4, pirState);

  if (soilMoisture < 300 || buttonState == HIGH) {
    digitalWrite(RELAY_PIN, HIGH);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Watering...");
    Blynk.virtualWrite(V5, 1);
    delay(5000);
    digitalWrite(RELAY_PIN, LOW);
    Blynk.virtualWrite(V5, 0);
  }
}

This code is designed to be uploaded to the ESP8266 NodeMCU microcontroller. It initializes the connected sensors and LCD, reads sensor data, and controls the relay based on soil moisture or button press. It also sends data to the Blynk app for remote monitoring.