Intro: Annoying Soil Moisture Sensor With Photon and IFTTT
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:
- Piezo Buzzer
- Super-Bright LED
- Capacitive Soil Moisture Sensor
- Particle Photon
- Micro USB Cable
- Male-Male Jumper Wires
Not all of these are strictly necessary. You could get by with just the capacitive soil moisture sensor, the USB cable, and the Photon, but the only output would be text alerts to your phone. For the full experience I recommend getting everything.
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.
- You can now setup the Particle service at https://ifttt.com/particle
- 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
Now it's time to get programming! Download the linked file and open it in your text editor of choice. You can then copy and paste it 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