Project tutorial
Thirst Alert Plant Alarm

Thirst Alert Plant Alarm © CC BY-SA

Don’t you wish your plants would tell you when they needed to be watered? Take your project from breadboard to PCB with this fun tutorial.

  • 4,416 views
  • 3 comments
  • 39 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)
4966285
Solder Wire, Lead Free

Apps and online services

Patchr PCB Editor
Patchr PCB Manufacturing
Use the code "GoPatchr" at checkout to get 15% off your first order.
Ide web
Arduino IDE
Onshape
Our favorite 3D CAD tool

About this project

How It All Started:

I’ve got to come clean — I am a horrible plant parent. It’s nice to get that one off my chest. I can’t figure it out, whether it’s hitting the photosynthesis a little too hard or going light on the old H2O. It seems nothing I do will keep these dudes alive! I love their company, the way they brighten up an otherwise bleak space, setting the mood in ways an Ikea painting just can’t. So I set out to change things for the better by building a device that helps all those quiet plant killers like me become proud plant purveyors.

Introducing the Thirsty Plant Detector, a device that speaks for your plants, telling you exactly when they are ready for a refill.

This project has been really exciting, using the Explorer Uno at its core, combined with a soil moisture sensor and piezo buzzer that produces a beautiful cricket “chirp” when the plant has run dry. Interesting fact about this buzzer — it uses a piezo element, which can both generate sound or detect vibrations such as a knock. The soil moisture sensor is dead simple. The two prongs or probes sit within the soil acting like a variable resistor, generating analog values between 0 and 1023, dependent on the amount of moisture in the soil. The more water in the soil means there will be better conductivity between the probes, resulting in a lower resistance.

Watch this video we put together to learn how to build it:

Or follow along below to build your own! Happy building!!

Let's Breadboard Out the Project:

To get started, we are going to breadboard everything out to test the software before we design our PCB. I use an Arduino Uno to get everything up and running and, when ready, transfer the Atmega328 over into my PCB. I’ve included a diagram of how the components fit together to help build your own.

Note that we can use either an off-the-shelf moisture sensor (Sparkfun makes a great one) or simply build our own. If you choose to build your own, all you need are two metal “probes, ” some spare wire and a 47k ohm resistor. I used brass hobby rods. You can find them at any hobby store, usually next to the model car/train section.

Once you’ve got your breadboard put together, upload this code to your Arduino:

https://github.com/patchr-io/Thirst-Alert/blob/master/Thirst_Alert.ino

If all looks good, you should hear a cricket noise! Touch the probes to each other and the noise should stop.

It's PCB Design Time!

1. First let’s log in to Patchr. If you haven’t created an account, go ahead and do that now. Here is a great 4 minute video to help you get started.

Check out these helpful keyboard shortcuts:

  • Switch to top side of the PCB: Command + 1
  • Switch to bottom side of the PCB: Command + 2
  • Rotate a component: Command + R
  • Toggle pad view vs component view: Command + P (removes all the components icons to reveal the component footprints)
  • Show ghosted image of routes on the opposite side of the PCB: Command + H

2. We will be using our Explorer Uno template to skip the step of designing the Arduino. Select the project, give it a name, and we can start designing.

3. The first thing we should do is change the board footprint a bit to give us a larger area to place our moisture sensor and buzzer. Let’s do this by grabbing one of these points on the corner and dragging it out. We can always come back and change the shape to fit our enclosure and the components we have added to it.

4. Next, let’s place our resistor. Remember from the breadboard, one end of the resistor will go into the 5V side and the other end will go into A0. When in doubt, select the header and it will show you the pin name on the left rail. I've placed the 5V route on the bottom side of the board (shortcut: command + 2) in order to prevent a cross over with the GND line on the top side of the board. We will also place a single through hole and connect it to the resistor to solder the moisture probe to. Let’s place another through hole for the other probe and route it into one of the ground pins.

Let’s take a quick break, pour some coffee, stretch a bit… and do a little file+save. We don’t want to lose all the progress you’ve made.

5. Now it’s buzzer time! In looking at the breadboard, we notice that we need to connect two pins. One to GND and the other to digital pin 5.

6. This is your chance to double check your connections with your breadboard circuit. If it appears to be the same as what you’ve designed on your PCB, you are ready to export! I suggest using Patchr Manufacturing because you are guaranteed a high-quality PCB. Use our promo code “GoPatchr” to get 15% off your first order. You can also download the finished PCB file attached to the post below.

Designing the Enclosure

While your PCB is off getting manufactured, let’s design the enclosure. Take note of the footprint dimensions on the right rail under the BRD tab — this will help ensure you have enough room for the PCB in your final design. If you would like to use the one I designed, you can download it here or on Thingiverse. As for CAD software, my favorite is Onshape for more advanced designs or TinkerCAD when you need to get something done fast. If you don't have a 3D printer there are a lot of great sites you can use to get your 3D object printed, you can also build an enclosure using materials found around your house.

Assembly!!!

Have you ever just popped off your headphones, turned the volume to 11, pushed away from your desk and danced a little jig? Excited because your PCBs have just arrived and you can’t wait to start your favorite part of every project? Assembly!!!! Because it’s that time, my favorite time…soldering. To quote Bob Pease: “My favorite programming language is solder.” I could not agree with him more... So warm up your iron, put on your favorite beat and let’s do this thing!

Use your Patchr project as a resource and the circuit diagrams to help you as you put things together. A few things to note, I wanted the buzzer to exist towards the top of the enclosure I designed so I am soldering wires between the buzzer and the PCB. If you want to place the buzzer directly on the PCB, just make sure you have allowed enough room for the component during the design phase.

Let’s hope the only crispy, crunchy, dried-out plants in your life are the dehydrated kale chips you had for lunch yesterday, thanks to the Thirst Alert Plant Alarm. As usual, hit me in the comments below with questions, cool gifs, dad jokes, or your favorite soldering jams.

Check out the build video here. Share your Plant Alarm hacks here.

Annnnd from my workbench to yours…happy building!


Code

Thirst Alert - Arduino CodeArduino
/*
 * Built for Patchr.io's Thirst Alert Plant Alarm
 * Tutorial: www.hackster.io/patchr
 * PCB Design: www.patchr.io
 * November 2019
*/

#include "Volume.h" /* Developed by Connor Nishijima (2016) */

int sensorPin = A0; //set the pin for the moisture sensor
int sensorValue;
int limit = 300;

Volume vol; 

void setup()
{
  Serial.begin(9600);
  vol.begin();
  vol.setMasterVolume(1.00); //Set this between 0.00 and 1.00 dependent on how loud you want the project to be
  vol.delay(500);
}

void loop()
{ 
  sensorValue = analogRead(sensorPin);
  Serial.println(sensorValue);

  if (sensorValue>limit) {
    Serial.println("*cricket*"); //if the sensor value is greater than 300 then play the cricket noise at a random interval between 1 an 30 seconds
    chirp();
    vol.delay(random (1000, 30000));
  } 
  else {
    vol.noTone();
  }
}


void chirp() { //this part of the software was written by Connor Nishijima and creates the chirp tones
  int freq = random(3700, 4000);
  float volume = random(10, 100+1) / 100.00;

  int chirpType = 1;

  if (chirpType == 1) {
    Serial.println("2");
    int chirpCount = random (1,3);
    chirp(chirpCount, freq, volume);
  }
}

void chirp(byte times, int freq, float volume) {
  float fadeOut = 1.00;
  while (times > 0) {
    float mv = 0;
    while (mv < 1.00) {
      int v = 0;
      while (v < 255) {
        vol.tone(freq, v * volume * mv * fadeOut);
        v += 4;
      }
      v = 255;
      while (v > 0) {
        vol.tone(freq, v * volume * mv * fadeOut);
        v -= 4;
      }
      vol.delay(20);
      mv += 0.2;
    }
    mv = 1.00;
    while (mv > 0.00) {
      int v = 0;
      while (v < 255) {
        vol.tone(freq, v * volume * mv * fadeOut);
        v += 4;
      }
      v = 255;
      while (v > 0) {
        vol.tone(freq, v * volume * mv * fadeOut);
        v -= 4;
      }
      vol.delay(20);
      mv -= 0.2;
    }
    vol.noTone();
    fadeOut -= 0.75;
    times--;
  }
}

Custom parts and enclosures

Enclosure Top
Enclosure Bottom
Thirst Alert Enclosure
Thirst Alert PCB
This is the gerber file you can use to upload to Patchr Manufacturing.
thirstalertpcb_5kbOAcFilw.zip

Schematics

Moisture + Buzzer Schematic Layout
Breadboard thirstalert qcglkapxa9

Comments

Similar projects you might like

Plant watering alarm system with arduino

Project tutorial by Giannis Arvanitakis

  • 6,700 views
  • 1 comment
  • 12 respects

Burglar Alarm

Project tutorial by Salman Faris

  • 7,444 views
  • 0 comments
  • 14 respects

ATmega Alien Themed Slot Machine

Project tutorial by Dan Murphy

  • 2,403 views
  • 6 comments
  • 25 respects

Plant Waterer Controller

Project in progress by Paulo Soares

  • 1,751 views
  • 2 comments
  • 7 respects

Personal Home Assistant

Project tutorial by 3 developers

  • 5,387 views
  • 0 comments
  • 29 respects

Arduino Project: Burglar Zone Input Tester

Project tutorial by Cezarjar

  • 1,862 views
  • 2 comments
  • 7 respects
Add projectSign up / Login