Alex Wulff
Published © CC BY-NC-SA

Annoying Soil Moisture Sensor with Photon and IFTTT

Never forget to water your plants again with this extraordinarily annoying soil moisture monitor.

BeginnerFull instructions provided1 hour4,090
Annoying Soil Moisture Sensor with Photon and IFTTT

Things used in this project

Hardware components

DFRobot Piezo Buzzer
×1
DFRobot Super-Bright LED
×1
DFRobot Capacitive Soil Moisture Sensor
×1
Particle Photon
×1
DFRobot Micro USB Cable
×1
Breadboard (generic)
Breadboard (generic)
×1
Male-Male Jumper Wire
×1

Story

Read more

Code

AnnoyingPlant.ino

Arduino
//AnalogRead on particle ranges from 0 to 4095, so the values for Arduino will be different

#define THRESHOLD           3000
#define SENSOR_PIN          A0
#define LIGHT_PIN           7
#define BUZZER_PIN          6
#define TEXTING_INTERVAL    1800000 //30 minutes (1000ms * 60s * 30mins)

int buzzerOn = 0;
int thresholdMet = false;
unsigned long lastTextTime = 0;

void setup() {
    pinMode(SENSOR_PIN, INPUT);
    pinMode(LIGHT_PIN, OUTPUT);
    pinMode(BUZZER_PIN, OUTPUT);
}

void loop() {
    if (analogRead(SENSOR_PIN) > THRESHOLD) {
        thresholdMet = true;
        digitalWrite(LIGHT_PIN, HIGH);
        digitalWrite(BUZZER_PIN, HIGH);
        
        unsigned long now = millis();
        
        if (now - lastTextTime >= TEXTING_INTERVAL) {
            Particle.publish("Water Me Now!");
        }
    }
    
    else {
        thresholdMet = false;
        digitalWrite(LIGHT_PIN, LOW);
        digitalWrite(BUZZER_PIN, LOW);
    }
}

Credits

Alex Wulff

Alex Wulff

12 projects • 235 followers
I'm a maker and student at Harvard. I love Arduino, embedded systems, radio, 3D printing, and iOS development. www.AlexWulff.com

Comments