Introduction: Water Sensor for Soil

This project is an easy and very informative way to educate the students that are efficient at writing codes and understanding the mechanisms of the electronics involved with the arduino.

Materials Required:

- Arduino Microcontroller

- Water Sensor (max value 1023)

- Handful of Jumper Wires (Both male to male and female to male)

- Breadboard (Mini one is recommended)

- Servo Motor

Step 1: Step 1: Gather All Materials

Make sure to place all your materials in a empty space, put them in a place that is spacious and away from any food or drinks, this is because it can damage the electronics. I would also suggest keeping a wire stripper with you as well just in case you have regular wires instead of jumper cables.

Step 2: Step 2: Water Sensor Connections

1. Pick up three jumper cables (red, black and yellow) and the water sensor

2. Connect the red wire to the + on the water sensor, the black to the "-" and the yellow wire to the S

Step 3: Step 3: Arduino First Wiring

1. Connect two wires to the arduino, one to 5v and the other to GND

2. After that step, connect the one you connected to 5V to the positive on the breadboard and the GND to the negative

Step 4: Step 4: Water Sensor Connections

1. Connect the yellow wire of the water sensor to the A0

2. Connect the black to the negative or ground on the breadboard of the water sensor to the arduino

3. Connect the red to the positive to the breadboard of the water sensor to the arduino

Step 5: Step 5: Servo Motor

1. Connect the orange wire of the servo motor to a yellow wire

2. Connect the red wire to any color of your choice

3. Connect the brown to a different color of your choice

4. Once those steps are done, we are now going to connect the servo motor to the breadboard and arudino

5. Connect the yellow wire to pin 9.

6. Connect the wire that is connected to the red wire on the motor to the positive

7. Connect the wire that is connected to the brown wire on the servo motor to ground

Step 6: Step 6: Code

1. Connect your arduino to the computer and open up the Arduino software on your computer

2. Start by identifying the servo motor by saying "#include <Servo.h>

3. Identify each variable, the servo, water sensor which is connected to A0 as well as the "angle" which is simply the position of your servo motor

4. Now to begin void.setup, begin by initiating the serial begin (9600) and and also declare the servo which is attached to pin 9.

5. After that step, is the void loop, begin by using "int" followed by the sensor value which is your analog read which is the water sensor

6. Make sure to include the Serial.print command underneath and use "ln" so it's in a line when monitoring the humidity of the water

7. Then, using "int.angle" make sure the sensor value is between 500 to 180, this is because it depends on the humidity, even though the water sensor should be 1023 to 180 which is the max and min value, it varies depending on the use of the project as well as the max and min values according to your specific water sensor

8. Now add the same Serial,print ln underneath and include "my servo. write(angle) underneath that

9. The last step is to add the delay I added "delay(15)" followed by the } to conclude the code

Step 7: Step 7: Finalizing

Now that the code is functional and working, you can add the sensor in the motor and use serial monitor to detect the humidity of the water or soil. Also, make sure to add little slips of construction paper or display because the display could prove of your soil needs water or not depending on the humidity.