Giannis Arvanitakis
Published © CC BY

Plant watering alarm system with arduino

A device that warns us with light sound and a sign when our plant needs water.

BeginnerFull instructions provided6 hours17,158
Plant watering alarm system with arduino

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
SparkFun Soil Moisture Sensor (with Screw Terminals)
SparkFun Soil Moisture Sensor (with Screw Terminals)
×1
LED (generic)
LED (generic)
×1
Buzzer
Buzzer
×1
Servos (Tower Pro MG996R)
×1
Resistor 221 ohm
Resistor 221 ohm
×2
Jumper wires (generic)
Jumper wires (generic)
×1
AA Batteries
AA Batteries
×1

Software apps and online services

Arduino IDE
Arduino IDE
Ardublockly

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schematic

Code

Plant water alarm code - arduino

Arduino
#include <Servo.h>  

Servo myServo;      //The sign servo
int buzzerPin = 8;  //The Buzzer pin
int redLed = 9;     //The led pin
int moisture;       //The moisture value
 
void setup() {
  pinMode(buzzerPin,OUTPUT);   
  pinMode(redLed,OUTPUT);      
  myServo.attach(11;          
}
 
void loop() {
  moisture = analogRead(A0);             //Read the moisture from sensor
  moisture = map(moisture,0,1023,100,1); //Map the moisture values to 1-100. 
  if (moisture < 50) {                   //If moisture is low
    myServo.write(165);                  //Turn motor to "No water" sign
    digitalWrite(redLed,HIGH);           //Turn on the led light
    tone(buzzerPin, 2000, 500);          //Play a buzzer tone for halph a second
    delay(1000);                         //delay for a second
    digitalWrite(redLed,LOW);            //Turn off the led light  
    delay(1000);                         //Delay another second
  } else {                               //If moisture is OK
    digitalWrite(redLed,HIGH);           //Just turn on the led light 
    myServo.write(20);                   //and turn motor to "plant ok" sign
  }
}

Credits

Giannis Arvanitakis

Giannis Arvanitakis

3 projects • 47 followers
I am a Computer Science Teacher and in charge of the Technology evening clubs at the Experimental Elementary School of Florina.

Comments