Using a Arduino, Relay Module and Soil Moisture Sensor to Control a Water Pump.

by lemieuxn in Circuits > Arduino

2761 Views, 3 Favorites, 0 Comments

Using a Arduino, Relay Module and Soil Moisture Sensor to Control a Water Pump.

IMG_0597 Small.jpeg

I made an automatic watering system with a relay module, soil moisture sensor, arduino, and water pump. I made this because my client wanted a way to keep their plants watered without extra work.

Supplies

  1. wires
  2. Arduino
  3. Breadboard
  4. Capacitive soil Moisture Sensor
  5. Relay module (A 4 Channel Relay is what I used)
  6. Water Pump
  7. Small screwdriver
  8. Fish Tubing

Connecting the Soil Moisture Sensor

IMG_0592 2 Small.jpeg

Connect the wires on the Soil Moisture Sensor to the Arduino


GND --> GND

VCC --> 3.3 V

AOUT --> A0

Connect the Arduino's Power With the Relay

IMG_0596 Small.jpeg
IMG_0593 Small.jpeg

For this step you will need to use the Breadboard, arduino, and relay module. As well as some wires to connect everything.

So start off with connecting the 5v pin on the Arduino to the positive line on the breadboard. Once that is done connect the positive line of pins on the breadboard to the VCC pin on the Relay Module as well as connect a line from the positive pins into the common port (middle port) on the relay switch you are using.

Controlling the Pump

IMG_0594 Small.jpeg
IMG_0593 Small.jpeg

Now that we have connected the power we need to control the pump so we need to connect the negative wire from the pump into one of the ground pins on the arduino. Once that is done connect the positive wire from the pump to the open -circuit port (left port). Next, Connect digital pin number 7 with the relay pin IN1. Now finally connect the fish tubing onto the water pump.

Enter the Code

Now that everything is connected insert the code



// C++ code

//

int SoilSensor = 0;


int RelayControl1 = 7;


int Pump = 0;


void setup()

{

pinMode(A0, INPUT);

Serial.begin(9600);

pinMode(3, OUTPUT);

Serial.begin(9600);

pinMode(RelayControl1, OUTPUT);

}


void loop()

{

if (SoilSensor > 500) {

digitalWrite(RelayControl1,HIGH);// NO1 and COM1 Connected (Pump on)

} else {

digitalWrite(RelayControl1,LOW);// NO1 and COM1 disconnected (Pump off)

}

SoilSensor = analogRead(A0);

Serial.println(SoilSensor);

delay(10); // Delay a little bit to improve simulation performance

}

Completed

Now stick the Soil moisture sensor into the soil you are using and the water pump into the water you want to go onto the soil and aim the fish tubing onto the soil. Now when the moisture level of the soil gets too low the water pump will activate and will water your plant.