Automatic Plant Watering
This is an automatic plant watering system. This system is designed to measure moisture in soil and water a plant when it reaches below a desired temperature. It also has a system shutdown switch as well as a speaker incorporated into the system.
Supplies
Materials:
- 1 Card board Box
- 1 Water Bottle (Life Wtr Recommended)
- 1 Sparkfun Kit (https://a.co/d/3UZerzf)
- 8 12" Wooden Dowels (https://a.co/d/eIVgXMw)
- 10' of 1/4" ID PVC Vinyl Tubing (https://a.co/d/7dnXYcI)
- 1 Flower Pot (https://a.co/d/3KAyRGe)
- 1 Moisture Sensor (https://www.sparkfun.com/products/13322)
- 1 5V Water Pump (https://a.co/d/5GoVopA)
- 1 5V Relay Module (https://a.co/d/bdVbqJo)
Materials for Construction:
- Hot Glue
- Duct Tape
- Filament (Optional)
Tools Required:
- Hot Glue Gun
- Small Saw
- Box Cutter
- 3D Printer (Optional)
Arduino Housing Unit Base
- Break down the box so that it would resemble the photo above
- Cut the cardboard into 2 36cm x 36cm pieces
- Fold in 10cm on each side of the cardboard so that it resembles a "U" shape
- Lay one piece with the 10cm folds facing the ceiling and the other piece with the 10cm folds facing the other piece
- Overlap the two pieces of cardboard at the 10cm folds taping the corners to make it more stable
- By overlapping small pieces of tape create double-sided tape and attach 4 pieces to the bottom of the Sparkfun base to attach to the cardboard
- Cut out a 18cm x 18cm square of cardboard and fold the piece down the middle. Tape this piece at the point where it touches the 10 cm folds that create the back of the main unit with the fold facing down.
Arduino Housing Unit Base
- Cut 2 10cm x 20cm pieces of cardboard attaching them horizontally with tape
- Fold the cardboard to make a 90 degree angle and attach them by hot gluing a wooden dowel diagonally across the cardboard
- Repeat steps 1 and 2 to create another piece
- Attach both pieces using tape to form the base
- Cut a 20cm x 20cm piece of carboard and tape in on top of the base
Create a Water Tank
- Take a 16.9 fluid oz water bottle and saw the bottom off. Remove the regular cap and replace with a nozzle bottle cap.
- Use the 1/4" rubber tubing and cut a 11.75" segment to attach one end to the nozzle bottle cap. Attach the other end to the input of the water pump.
- Cut a 13" segment of the 1/4" rubber tubing and attach that to the output of the water pump. On the other end, attach the 3D printed water head (Optional). Link for .stl is listed below.
- Tape or glue the shower head to the end of the ramp made in the ‘Arduino Housing Unit’ section. The shower head should be the furthest forward piece.
- Hot glue the bottle to the back of the Arduino housing unit.
Downloads
Ground/Power Wiring
- To wire the power wire, insert a wire in pin in the 5V port in the Arduino. Signaled by the red wire above in the picture. This wire then needs to also connect to the positive horizontal spot in the breadboard.
- Next, to wire the ground for the breadboard, insert a wire pin into the GRD port in the Arduino. This is represented by black wire in the above picture. Connect the other end of this wire to the negative horizontal row on the breadboard.
Moisture Sensor Wiring
- To power the moisture sensor, connect a red wire to the VCC spot on the moisture sensor. Connect this wire, then to the port 6 on the Arduino. This is represented by the red wire attached to the moisture sensor in the above picture.
- To ground the sensor, connect a wire to the GRD spot on the moisture sensor. Connect the other end of this wire to the horizontal in which you grounded the breadboard. This is represented by the black wire attached to the moisture sensor.
- For the information wire for the moisture sensor, connect a wire to the lower SIG port of the sensor. Attach the other end of this wire to the A3 port on the Arduino. This is represented by the green wire on the picture.
- Ensure the moisture sensor is hanging through the front.
Water Pump and Relay Wiring
- The relay has two sides for wires, one with screws used to secure connections, and one with breadboard-like holes
- Connect the red wire from the pump into the center slot on the screw side. First loosen the designated screw, then place the wire, then tighten the screw
- Hold the black wire and a Spark Fun jumper wire together and wrap with copper wire. Secure this connection with electrical tape
- Use as many jumper wires to then connect the original black (grounding) wire to the negative (ground) port within the breadboard
- With the relay unit facing you so that the text is upright, loosen the bottom-most screw. Place a jumper wire within the port and tighten the screw.
- Once again, use as many jumper wires connected through a copper wire and electrical tape wrap to connect to the positive side of the breadboard (5v)
- On the breadboard-connection side of the relay, with the same orientation, place a jumper wire connecting the digital pin 9 on the Arduino Uno board and the bottom slot on the relay
- Connect the middle port to the grounding portion of the breadboard (black)
- Connect the top port to the power portion of the breadboard (red)
Switch and Speaker Wiring
- Put the speaker from the Sparkfun kit in the breadboard.
- Connect the positive side to port 8 (brown wire).
- Connect the negative side to the negative row on the breadboard (black speaker wire).
- Put the switch on the breadboard.
- connect the left to the negative row on the breadboard (black switch wire) and the middle to the positive (red switch wire).
- Connect the right side of the switch to port 5 as shown by the blue wire in the picture.
Code
// Automated Plant Watering System
//
int moisturemin = 200; // minimum level of moisture
int soilPower = 7;//variable for the for the moisture sensor
int soilPin = A3; // variable for the moisture sensor
int speaker = 8; // variable for the speaker
int slide = 5; // variable for slideswitch
const int Relay_pin = 9; //constant variable for the water pump
int slideval;//variable used later to detect the on/off status of the slideswitch
float moistureval;//variable used later as the numerical values of the moisture levels detected
int initialmoisture;//variable used later as the initial numerical value of the moisture level
void setup() {
pinMode(soilPin, INPUT); // Explicitly set soilPin as INPUT
pinMode(slide, INPUT_PULLUP);//sets the slide as an input
pinMode(speaker, OUTPUT);//sets the speaker as an output
pinMode(soilPower, OUTPUT);//sets the power for the soil moisture sensor as an output
pinMode(Relay_pin, OUTPUT);//sets pin 9 as an output
digitalWrite(Relay_pin, HIGH); //sets pump to off
digitalWrite(soilPower, LOW); // Set the soil sensor power off initially
Serial.begin(9600);
}
void loop() {
slideval = digitalRead(slide);//detects whether the slide is ON or OFF
if (slideval == HIGH) { // Using an if statement to determine when the slide is set to activate the system
digitalWrite(soilPower, HIGH); // Power on the soil moisture sensor
moistureval = analogRead(soilPin); // Read moisture level
initialmoisture = moistureval; // Store an initial moisture value for later
Serial.print("The moisture is ");
Serial.print(moistureval);
if (moistureval < moisturemin) { // Check if moisture is below the minimum threshold
digitalWrite(Relay_pin, LOW);//turn on the water pump
delay(5000);//keep on for 2 and a half seconds
digitalWrite(Relay_pin,HIGH);//turn off the water pump
delay(2000);
if (abs(moistureval - initialmoisture) <= 5) { // Allow a small variation that determines if the moisture has changed
tone(speaker, 1000, 500); // 1000Hz tone for half a second
}
delay(10000);
}
}
}