Procedure for Automatic Plant Watering System without Flyback Diode

 

Procedure for Automatic Plant Watering System without Flyback Diode



Step 1: Gather Components

  • Arduino UNO
  • Soil moisture sensor
  • NPN transistor (e.g., 2N2222 or BC547) or N-channel MOSFET (e.g., IRF540N or IRLZ44N)
  • Water pump
  • 1kΩ resistor
  • 5V or 12V power supply for the pump (depending on the pump specifications)
  • Jumper wires
  • Breadboard

Step 2: Connect the Soil Moisture Sensor

  1. Attach the VCC pin of the soil moisture sensor to the 5V pin on the Arduino.
  2. Connect the GND pin of the sensor to the GND pin on the Arduino.
  3. Attach the A0 pin of the sensor to the A1 analog pin on the Arduino.

Step 3: Set Up the Transistor or MOSFET

For NPN Transistor:
  1. Connect the emitter pin of the transistor to GND.
  2. Connect the collector pin to the positive terminal of the water pump.
  3. Connect the base pin to Arduino digital pin 8 via a 1kΩ resistor.
For N-Channel MOSFET:
  1. Connect the source pin of the MOSFET to GND.
  2. Connect the drain pin to the negative terminal of the water pump.
  3. Connect the gate pin to Arduino digital pin 8 via a 1kΩ resistor.

Step 4: Connect the Water Pump

  1. Attach the positive terminal of the water pump to the positive terminal of the external power supply.
  2. Attach the negative terminal of the water pump to the transistor's collector (if using an NPN transistor) or the MOSFET's drain.

Step 5: Power the System

  1. Connect the Arduino to your computer or a power source using a USB cable or a 5V adapter.
  2. Power the water pump using an external power supply that matches its voltage requirements.

Step 6: Upload the Code

  1. Copy the provided Arduino code into the Arduino IDE.
  2. Adjust the threshold value in the code based on the sensor readings for dry soil.
  3. Upload the code to the Arduino UNO.

Step 7: Test the System

  1. Place the soil moisture sensor in the soil of the plant.
  2. Observe the Arduino's serial monitor to check the soil moisture readings.
  3. When the soil is dry (reading exceeds the threshold), the Arduino will turn on the pump.
  4. When the soil is moist, the pump will automatically turn off.

code

#define moisturePin A1  // Soil moisture sensor connected to analog pin A1
#define pumpPin 8       // Water pump (or motor) control pin connected to digital pin 8

int moistureValue = 0;  // Variable to store soil moisture level
int threshold = 600;    // Threshold value for dry soil (adjust based on your sensor's output)

void setup() {
  pinMode(pumpPin, OUTPUT);       // Set the pump control pin as output
  digitalWrite(pumpPin, LOW);     // Ensure the pump is OFF initially
  Serial.begin(9600);            // Start the serial communication for monitoring
}

void loop() {
  // Read the soil moisture sensor value
  moistureValue = analogRead(moisturePin);

  // Print the moisture value to the Serial Monitor
  Serial.print("Moisture Level: ");
  Serial.println(moistureValue);

  // Check if the soil is dry
  if (moistureValue < threshold) {
    Serial.println("Soil is dry. Turning on the pump.");
    digitalWrite(pumpPin, HIGH); // Turn ON the motor (pump)
  } else {
    Serial.println("Soil is moist. Turning off the pump.");
    digitalWrite(pumpPin, LOW);  // Turn OFF the motor (pump)
  }

  delay(2000); // Delay for 2 seconds before the next reading
}

Comments

Popular posts from this blog

Arduino projects

1.Using an LDR (Light Dependent Resistor) with Arduino to Measure Light Intensity