Project in progress
Automated Plant Watering System

Automated Plant Watering System © GPL3+

A device that waters plants and monitors temprature using an ESP8266 and Android app.

  • 5,319 views
  • 2 comments
  • 26 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)
Hy gluegun
Hot glue gun (generic)

About this project

My country has been badly affected by climate change due to heavy deforestation. So many campaigns arose planting more trees. However, to reduce my effort in gardening, I made something that water my plants based on an Android app.

The concept is simple: I designed a web server using ESP8266. Changed index a bit. Also, the ESP8266 controls the relay to water pump.

The second component is an Arduino Nano, which takes readings from DHT11 and displays on an OLED.

Please check this video out!

Code

Automated Garden Watering NanoArduino
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <DHT.h>


#define DHTPIN 2     // what pin we're connected to
#define DHTTYPE DHT11   // DHT 11
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);


// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);
String info;
boolean watering= false, status=false;
void setup()
{
  Wire.begin();
  dht.begin(); // initialize dht
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);// initialize with the I2C addr 0x3C (for the 128x32)(initializing the display)
  Serial.begin(9600);
}
void displayTempHumid(){
  delay(2000);
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit
  float f = dht.readTemperature(true);
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    display.clearDisplay(); // clearing the display
    display.setTextColor(WHITE); //setting the color
    display.setTextSize(1); //set the font size
    display.setCursor(5,0); //set the cursor coordinates
    display.print("Failed to read from DHT sensor!");
    return;
  }
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print("Humidity: "); 
  display.print(h);
  display.print(" %\t");
  display.setCursor(0,10);
  display.print("Temperature: "); 
  display.print(t);
  display.print(" C"); 
  display.setCursor(0,20);
  display.print("Temperature: "); 
  display.print(f);
  display.print(" F"); 
}

void loop()
{ 
  displayTempHumid();
  display.display();  
}
Automated Garden Watering Esp8266Arduino
The code for Esp8266 used in this project
/*
 *  This sketch demonstrates how to set up a simple HTTP-like server.
 *  The server will set a GPIO pin depending on the request
 *    http://server_ip/gpio/0 will set the GPIO2 low,
 *    http://server_ip/gpio/1 will set the GPIO2 high
 *  server_ip is the IP address of the ESP8266 module, will be 
 *  printed to Serial when the module is connected.
 */

#include <ESP8266WiFi.h>

const char* ssid = "ASH";
const char* password = "12345678";

// Create an instance of the server
// specify the port to listen on as an argument
WiFiServer server(80);

boolean waternow=false;

void setup() {
  Serial.begin(9600);
  delay(10);
  pinMode(2, OUTPUT);

 
  
  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  
  // Start the server
  server.begin();
  Serial.println("Server started");

  // Print the IP address
  Serial.write(WiFi.localIP());
}

void loop() {
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client) {
    return;
  }
  
  // Wait until the client sends some data
  Serial.println("new client");
  while(!client.available()){
    delay(1);
  }
  
  // Read the first line of the request
  String req = client.readStringUntil('\r');
  client.flush();
  
  
  int val;
  
  if (req.indexOf("manu/ON") != -1){
  waternow=true;}
  else if (req.indexOf("manu/OFF") != -1){
   waternow=false;}
    
  else {
    Serial.println("invalid request");
    client.stop();
    return;
  }

  
  
  client.flush();

 
  delay(1);
  Serial.println("Client disonnected");
  if (waternow==true){ digitalWrite(2, HIGH);
  delay (30000);
  waternow=false;}
  else{digitalWrite(2, LOW);}

  // The client will actually be disconnected 
  // when the function returns and 'client' object is detroyed
}

Schematics

Automated Garden Watering
Circuit Design I made. I lack a lot of skills so be creative
Auto garden bb qmpfzplrwm

Comments

Similar projects you might like

Home Plant Watering System

Project tutorial by Alexander

  • 15,191 views
  • 2 comments
  • 42 respects

Plant watering alarm system with arduino

Project tutorial by Giannis Arvanitakis

  • 3,394 views
  • 1 comment
  • 5 respects

Automatic Plant Watering System with Arduino

Project tutorial by Team RobotGeek Projects Team

  • 32,775 views
  • 2 comments
  • 45 respects

Plant Watering System

Project showcase by Niko123

  • 3,690 views
  • 2 comments
  • 12 respects
Add projectSign up / Login