Patchr
Published © CC BY-SA

Thirst Alert Plant Alarm

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.

BeginnerFull instructions provided2 hours6,747
Thirst Alert Plant Alarm

Things used in this project

Hardware components

ATmega328
Microchip ATmega328
×1
16 MHz Crystal
16 MHz Crystal
×1
Ceramic Disc Capacitor, 20 pF
Ceramic Disc Capacitor, 20 pF
×2
Linear Regulator (7805)
Linear Regulator (7805)
×1
LED (generic)
LED (generic)
Use whatever colors you want with this one!
×2
Resistor 10k ohm
Resistor 10k ohm
×1
Resistor 220 ohm
Resistor 220 ohm
×1
Through Hole Resistor, 470 ohm
Through Hole Resistor, 470 ohm
×1
Slide Switch
Slide Switch
×1
PTS 645 Series Switch
C&K Switches PTS 645 Series Switch
×1
Buzzer, Piezo
Buzzer, Piezo
×1
9V battery (generic)
9V battery (generic)
×1
9V Battery Clip
9V Battery Clip
×1
SparkFun Soil Moisture Sensor (with Screw Terminals)
SparkFun Soil Moisture Sensor (with Screw Terminals)
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
3D Printed Case
×1

Software apps and online services

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

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

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.

Schematics

Moisture + Buzzer Schematic Layout

Code

Thirst Alert - Arduino Code

Arduino
/*
 * 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--;
  }
}

Credits

Patchr

Patchr

4 projects • 18 followers
Patchr makes PCB design a snap. With our software, you can go from idea to a completed board in days, not weeks.
Thanks to Connor Nishijima.

Comments