Automatic plants watering system

I have a problem with this system the water pump does not work I connected like this picture, and I tried connecting with the relay, but the same problem😐.
Help please the deadline on Monday.

Can you describe what is working and what not ?

Can you blink the led at pin 13 of the Arduino Uno board ?
Do you see something on the display ?
Can you activate the relay and the pump ?
Can you measure the soil-moisture-sensor, I hope that your sketch sends something to the Serial Monitor.

1 Like

Hi, @noor803
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

This will help with advice on how to present your code and problems.

A fritzy image is not a good way to show to show your circuit.
For example what is the TO-220 device that switches the pump?
MOSFET or BJT?

Can you please post a hand drawn circuit please.
Include power supply, component names and pin labels.

Do you have a DMM?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

You cannot supply any significant load from the UNO circuit board .
Relays , pumps etc need an external supply of power .

Everything is working just water pump

This is my connection and code.

// Include Libraries
#include "Arduino.h"
#include "LiquidCrystal.h"
#include "Relay.h"
#include "SoilMoisture.h"
#include "Pump.h"

// Pin Definitions

#define LCD_PIN_RS 8
#define LCD_PIN_E 7
#define LCD_PIN_DB4 2
#define LCD_PIN_DB5 3
#define LCD_PIN_DB6 4
#define LCD_PIN_DB7 6
#define RELAYMODULE_PIN_SIGNAL 9
#define SOILMOISTURE_5V_PIN_SIG A3
#define WATERPUMP_PIN_COIL1 5

#define MAXDRYNESS 5000
#define WATERPOSTDELAY 1

// Global variables and defines

// object initialization
LiquidCrystal lcd(LCD_PIN_RS,LCD_PIN_E,LCD_PIN_DB4,LCD_PIN_DB5,LCD_PIN_DB6,LCD_PIN_DB7);
Relay relayModule(RELAYMODULE_PIN_SIGNAL);
SoilMoisture soilMoisture_5v(SOILMOISTURE_5V_PIN_SIG);
Pump waterpump(WATERPUMP_PIN_COIL1);
void setup()
{
digitalWrite(WATERPUMP_PIN_COIL1, LOW);
pinMode(WATERPUMP_PIN_COIL1, OUTPUT);
Serial.begin(9600);
lcd.begin(16,2);

}

void loop()
{
int moisturePin = analogRead(A3); //read analog value of moisture sensor
int moisture = ( 100 - ( (moisturePin / 1023.00) * 100 ) ); //convert analog value to percentage
Serial.print("Current moisture: ");
lcd.clear();
Serial.println(moisture);
lcd.print("surr moisture: ");
lcd.print(moisture);
delay(2000);
lcd.setCursor(0,1);
lcd.clear();

if (moisture < 40) //change the moisture threshold level based on your calibration values
{
Serial.println("Soil dry, start watering\n");
lcd.clear();
lcd.print("Soil dry");
lcd.setCursor(0,1);
delay(2000);
lcd.clear();
lcd.print("Motor is On");
lcd.setCursor(0,1);
digitalWrite(WATERPUMP_PIN_COIL1, HIGH); // turn on the motor
lcd.print("watering started");
Serial.println("watering started\n");
digitalWrite(5, HIGH);
delay(MAXDRYNESS);
digitalWrite(WATERPUMP_PIN_COIL1, LOW);
lcd.clear();
}
else
{
Serial.println("\nSoil is good\n");
Serial.println("Motor is Off\n");
lcd.print("Soil is good");
delay(3000);
lcd.clear();
lcd.print("Motor is Off");
delay(3000);
lcd.clear();
digitalWrite(WATERPUMP_PIN_COIL1,LOW);
delay(60000*WATERPOSTDELAY);
}
delay(2000);
}


Here I put the battery to the water pump, but still doesn't work

The wires connecting power to the water pump, where ae they? Is the water pump plugged into the USB port? How exactly is the water pump wired to power.

What does the relay do?

Post a schematic.

Let your teacher know you procrastinated and you'll not be making the Monday deadline.

Code tags, use them.

Yes it's into the USB
Really!!!! I've been working on it for two weeks.
I asked for help from my teacher, but he didn't help me and said try and search. I try everything I see on the Internet but without benefits. What should I do???

Post the sketch well formated, with comments and in code tages "</>".

Let your teacher know you'll be missing the deadline.

Next, order a new relay module that is not powered by the USB plug.

Here is a opto-ioslated double relay module that works at 3.3V.
AmazonSmile: SunFounder 2 Channel DC 5V Relay Module with Optocoupler Low Level Trigger Expansion Board for Arduino R3 MEGA 2560 1280 DSP ARM PIC AVR STM32 Raspberry Pi : Electronics

You should get with Water pump is not working - Using Arduino / Motors, Mechanics, Power and CNC - Arduino Forum, his pump will not stop running.

1 Like

// Include Libraries
#include "Arduino.h"
#include "LiquidCrystal.h"
#include "Relay.h"
#include "SoilMoisture.h"
#include "Pump.h"

// Pin Definitions

#define LCD_PIN_RS  8
#define LCD_PIN_E 7
#define LCD_PIN_DB4 2
#define LCD_PIN_DB5 3
#define LCD_PIN_DB6 4
#define LCD_PIN_DB7 6
#define RELAYMODULE_PIN_SIGNAL  9
#define SOILMOISTURE_5V_PIN_SIG A3
#define WATERPUMP_PIN_COIL1 5

#define MAXDRYNESS 5000
#define WATERPOSTDELAY 1

// Global variables and defines

// object initialization
LiquidCrystal lcd(LCD_PIN_RS,LCD_PIN_E,LCD_PIN_DB4,LCD_PIN_DB5,LCD_PIN_DB6,LCD_PIN_DB7);
 Relay relayModule(RELAYMODULE_PIN_SIGNAL);
SoilMoisture soilMoisture_5v(SOILMOISTURE_5V_PIN_SIG);
Pump waterpump(WATERPUMP_PIN_COIL1); 
void setup()
{ 
     digitalWrite(WATERPUMP_PIN_COIL1, LOW);
  pinMode(WATERPUMP_PIN_COIL1, OUTPUT);
  Serial.begin(9600);
     lcd.begin(16,2);
  
}

void loop()
{ 
  int moisturePin = analogRead(A3); //read analog value of moisture sensor
  int moisture = ( 100 - ( (moisturePin / 1023.00) * 100 ) ); //convert analog value to percentage
   Serial.print("Current moisture: ");
  lcd.clear();
  Serial.println(moisture);
  lcd.print("surr moisture: ");
  lcd.print(moisture);
  delay(2000);
  lcd.setCursor(0,1);
  lcd.clear();

   if (moisture < 40)  //change the moisture threshold level based on your calibration values
 {
    Serial.println("Soil dry, start watering\n");
    lcd.clear();
    lcd.print("Soil dry");
    lcd.setCursor(0,1);
    delay(2000);
    lcd.clear();
    lcd.print("Motor is On");
    lcd.setCursor(0,1);
     digitalWrite(WATERPUMP_PIN_COIL1, HIGH); // turn on the motor
    lcd.print("watering started");
    Serial.println("watering started\n");
    digitalWrite(5, HIGH);
       delay(MAXDRYNESS);
         digitalWrite(WATERPUMP_PIN_COIL1, LOW);
     lcd.clear();   
  }
 else 
   {
     Serial.println("\nSoil is good\n");
     Serial.println("Motor is Off\n");
     lcd.print("Soil is good");
     delay(3000);
     lcd.clear();
     lcd.print("Motor is Off");
     delay(3000);
     lcd.clear();
     digitalWrite(WATERPUMP_PIN_COIL1,LOW);
     delay(60000*WATERPOSTDELAY);
   }
    delay(2000);
  }

Thanks for posting the code but you do understand that your motor will not work for this project as is? First did you look at the project linked to from post#13 and how he is using the relay?

If you insist on using those parts to power the motor, you will want your relay to operate in place of the on/off switch on the power module. By using a multi meter you should be able to figure out the switches closed and open pins and the current paths of the various solder points. Then you'll solder some wires to replace the switch functions that go from the switch to the relay. Now the relay can operate the power supply to the motor.

Let's start with the pump:
What is it's rated voltage and current (or wattage)?
Then the transistor:
Is it a BJT or a MOSFET, what is the part number?
Then, what do you have plugged in the barrel jack, voltage and current capacity?

Show us a good schematic of your proposed circuit.


image

Please confirm you have accounted for the breaks in the power rails.
:astonished:

1 Like

Hi,

nope

Tom... :smiley: :+1: :coffee: :australia:

Hi, @noor803

Please draw a circuit diagram of your project please!!!!

At least the basic circuit of how you are trying to control your pump motor.

Do you have a DMM?

Tom... :smiley: :coffee: :coffee: :coffee: :australia: