Rafaelo FronzagliaNathan Dechambeau
Published

Plant Water Indicator

Always forgetting to water your indoor herbs? With this indicator kit, you will never forget to water your plants again!

IntermediateShowcase (no instructions)10 hours313
Plant Water Indicator

Things used in this project

Story

Read more

Schematics

Soil Moisture Detection

LED indicator

Code

Soil Moisture Detection

C/C++
This code takes the reading from the soil moisture detector, and outputs whether or not the plant needs to be watered.
int detectPin = D4;
    int plant = 0; 
    int sensorRead = 0; 
    
    void setup() {
        
        pinMode(detectPin, INPUT);
        Particle.variable("plant", &plant, INT);
        Particle.variable("sensorRead", &sensorRead, INT);
        
    }
    
    void loop(){
        sensorRead = digitalRead(detectPin);
        if (sensorRead >= 1)
        {
            
            Particle.publish("Parsley","Watered");
            delay(2000);
        }
        
            else if (sensorRead == 0)  {
                
                Particle.publish("Parsley","WATER ME!!");
                delay(2000);
                
            }
    }

LED indicator

C/C++
This code interprets the previous code, and blinks an LED depending on whether or not the plant needs water.
int led1 = D7;
void setup()
{                
    pinMode(led1, OUTPUT);  
    Particle.subscribe("Parsley",myHandler);
}

void myHandler(const char *event, const char *data)
{
    if (strcmp(data,"WATER ME!!")==0)
    {
        digitalWrite(led1, HIGH);
        delay(1000);
    digitalWrite(led1, LOW);
        delay(1000);

    }
    
    else
    {
    delay(100);
    }
}

Credits

Rafaelo Fronzaglia
1 project • 0 followers
Nathan Dechambeau
0 projects • 0 followers

Comments