Never forget to water your plants again with this super annoying project. It combines visual, auditory, and textual cues that will prevent you from doing anything else until you provide your plant with much-needed hydration. A piezo buzzer constantly blares a shrill note, while a super-bright LED annoys your peripheral vision. In addition, this project will send constant texts to your phone reminding you that your plant needs to be watered. Sounds like fun, right?
Step 1: Part Acquisition
All of the parts for this project can be purchased directly from DFRobot. The links are below:
Step 2: Part Assembly
All of the previously linked components utilize the gravity interface; connecting them is very simple. Start by plugging in the included 3-pin JST cables into the sockets on the capacitive moisture sensor, the buzzer, and the LED. Connect the black wires to ground (any of the GND pins on the Photon will do), and the red wires to the 3V3 pin. The Photon uses 3.3v logic so it's best to power the components with the same voltage.
The green wires are used to supply and send data to and from all of your input and output devices. Connect the green wire of the soil sensor to A0, the green wire of the LED to D7, and the green wire of the buzzer to D6. If your Photon isn't set up then you need to do so at https://setup.particle.io. This requires an active WiFi connection.
Once everything is all hooked up and working you can place it around your plant of choice. I chose to affix the buzzer and LED to the outside of the plant via double-sided tape. I also stuck the breadboard on the pot using the same double-sided tape. To manage wires I recommend bundling them together using twist-ties.
Step 3: Setup IFTTT
In order to send texts to your phone you'll need to create an IFTTT applet that connects to Particle.
Start by setting up the SMS service at https://ifttt.com/sms. If you already set this up then your current connection should work.
Visit https://ifttt.com/create to create a new applet. Select the "Particle" service for the service field (then).
Next select "new event published" from the list.
Use any unique name for the "Event Name Field." It doesn't matter what it is so long as you remember the event name.
For the "that" field select SMS. The message is irrelevant - you can write something like "Water your plant!"
Your Photon can now publish events and IFTTT will then pick these up and send you a text. There's generally a significant delay of up to 30 seconds between an event being posted and your message being delivered.
Step 4: The Code
//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);
}
}
Now it's time to get programming! You can copy and paste the above code into Particle's web or local IDE, and upload it to your Photon.
A few lines require changing. The first is the snippet that sends a text to your phone. On the line that has Particle.publish("Water Me Now!"); you need to replace Water Me Now! with the name of your own event that you set up in IFTTT.
In addition, you'll need to configure the THRESHOLD value defined at the top of the sketch. The easiest way to go about doing this is to stick your moisture sensor in some dry soil and use Serial.print() to view the output. Slowly add water until you reach the border between the soil being "dry" and the soil being "wet." This should be the point at which if you stuck your finger in the soil you would consider adding water to it soon. Record this value, and add it to the sketch. The default of 3000 should work for some scenarios but you really need to configure it to get the best results.
If you desire text alerts more/less frequently than every 30 seconds consider changing TEXTING_INTERVAL. This should be the length, in milliseconds, between each subsequent text.
Step 5: Going Further
The possibilities of this system are truly endless! To further increase how annoying your plant is you could tie the Photon in with any smart devices in your house.
For example, if you have WiFi-enabled lightbulbs, chances are IFTTT can control them. It would take a matter of seconds to set up an applet that continuously flashes the lights in your house until your plant is watered. Of course you could also just add more buzzers, but that's way less fun.
That's it! If you have any questions leave a comment below. You can check out more of my work at www.AlexWulff.com
CODE
//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);
}
}
This project is made by Alex Wulff, a very talent electronic engineer, the original post here.
More Particle Photon Projects: