Gus BrownJackson Amick
Published

Group 2 MEGR 3171 Automatic Plant Watering System

Do you love beautiful flowers and plants, but find yourself struggling to keep them alive with your busy schedule? We are here to help!

IntermediateFull instructions provided255
Group 2 MEGR 3171 Automatic Plant Watering System

Things used in this project

Hardware components

Argon
Particle Argon
×2
Gravity: Analog Capacitive Soil Moisture Sensor- Corrosion Resistant
DFRobot Gravity: Analog Capacitive Soil Moisture Sensor- Corrosion Resistant
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Battery, 3.7 V
Battery, 3.7 V
×2
Solenoid Water Valve
×1
Circular Connector Cable Seal, Heat Shrinkable Sealing Boot
Circular Connector Cable Seal, Heat Shrinkable Sealing Boot
×1
Garden Drip Line Kit
×1
Breadboard (generic)
Breadboard (generic)
×2
Breadboard Wire Kit
Digilent Breadboard Wire Kit
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Maker service
IFTTT Maker service
Youtube Video
PTC Creo

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

Enclosure Top

Enclosure Bottom

Schematics

Valve Schematic

Moisture Sensor Schematic

Moisture Sensor Graph

Graph showing the moisture sensor output graphed over time using IFTTT. The gap/spike in the graph shows when the plant was watered.

IFTTT

Looks for Particle Publish of sensor data and then sends that data to a Google Sheet where it is then automatically added to the graph.

Argon Box #1

This is the first enclosure with an argon and relay attached to the normally closed hose valve. Hole was drilled into enclosure so valve wires would fit precisely and was sealed with epoxy to maintain water tight fit.

Argon Box #2

This is the second box composed of an argon, breadboard, 3.7 V battery, Moisture Sensor, and Temp/Humidity Sensor.

Hose Valve

110Vac Solenoid Water Valve, Normally Closed.

Relay Valve Test Video

Test Video showing valve functionality using the Tinker program.

Code

Moisture/Temp/Humidity Sensor Code

Arduino
// This #include statement was automatically added by the Particle IDE.
#include <Grove_Temperature_And_Humidity_Sensor.h>//Library needed for the temp and humidity sensor (DHT)
#include <math.h>//library needed for pow() function

#define DHTPIN D2 //defining what pin will be used for the DHT sensor
DHT dht(DHTPIN);

int sensorPin = A3;//Pin that will be used for capacitance moisture sensor input

//Initalizing values used later in code
int val;
int getTemp;
int getHumid;
String moisture_percent;

void setup() {
    dht.begin();
    pinMode(sensorPin, INPUT); 
   
    //Defining particle variables that will read us the values we want to see
    Particle.variable("Temp F", getTemp);
    Particle.variable("Humidity Analog Value", getHumid);
    Particle.variable("Moisture Percent", moisture_percent);
}

void loop() {
    //Aquiring sensor values:
    getTemp = dht.getTempFarenheit();//gets temp
    getHumid = dht.getHumidity();//gets humidity
    val = analogRead(sensorPin);//gets analog signal input
    moisture_percent = calcMoisturePercent(val);//takes analog sensor input and uses function to calc moisture percent
    
    delay(3000);//Values are recalculated every 3 seconds, mainly due DHT sensor only being able to take readings every few seconds

    Particle.publish("MoisturePercent", String(moisture_percent));
}


String calcMoisturePercent(int value){ //takes in analog sensor value and will return moisture percent
    //Capacitance moisture sensor calibration:
    int moisture_0 =2899;//Value in "dry" air, will act as our 0% reading
    int moisture_100 = 2100;//Value in water, will act as 100% reading
    
    if (value <= moisture_0 && value >= moisture_100){
        int mp = (value - moisture_0) * pow(moisture_100 - moisture_0, -1) * 100;//Formula came from Thermodynamics quaility formula lol
        return String(mp) +"%  " + String(value);
    }
    else {
        return "ERROR, " + String(value); // Will return error and sensor value if sensor reading is not within calibration values
    }
}

Water Valve Control

Arduino
//Initializing variables:
int relayTrig = D10;

void setup() {
    pinMode(relayTrig, OUTPUT);//Setting pin mode to output

    digitalWrite(relayTrig, LOW);//start with valve off
    
    Particle.subscribe("MoisturePercent",moistureLevel); //subscribe to moisture sensor percentage from other argon
}

void moistureLevel(String event, String data){
    int ml = data.toInt();
    if (ml <= 10 && ml >= 0){
        waterPlants();//watering function, will run again if after delay moisture level is still low
    } 
    else if (ml > 10 && ml <= 100){
        digitalWrite(relayTrig, LOW); //Do nothing/make sure valve is off
    }
    else {
        Particle.publish("Water Valve", "ERROR"); //publishes an error so user knows there is an error somewhere not allowing valve to turn on
    }
}

void waterPlants(){  //function to water plants
    digitalWrite(relayTrig, HIGH);
    delay(60000);//waters for 60 seconds
    digitalWrite(relayTrig, LOW);
    delay(30000);//30 second delay to allow water to settle
} 

void loop() { // no loop needed
}

Credits

Gus Brown

Gus Brown

0 projects • 1 follower
Jackson Amick

Jackson Amick

0 projects • 0 followers

Comments

Add projectSign up / Login