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
- Attach the VCC pin of the soil moisture sensor to the 5V pin on the Arduino.
- Connect the GND pin of the sensor to the GND pin on the Arduino.
- 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:
- Connect the emitter pin of the transistor to GND.
- Connect the collector pin to the positive terminal of the water pump.
- Connect the base pin to Arduino digital pin 8 via a 1kΩ resistor.
For N-Channel MOSFET:
- Connect the source pin of the MOSFET to GND.
- Connect the drain pin to the negative terminal of the water pump.
- Connect the gate pin to Arduino digital pin 8 via a 1kΩ resistor.
Step 4: Connect the Water Pump
- Attach the positive terminal of the water pump to the positive terminal of the external power supply.
- 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
- Connect the Arduino to your computer or a power source using a USB cable or a 5V adapter.
- Power the water pump using an external power supply that matches its voltage requirements.
Step 6: Upload the Code
- Copy the provided Arduino code into the Arduino IDE.
- Adjust the threshold value in the code based on the sensor readings for dry soil.
- Upload the code to the Arduino UNO.
Step 7: Test the System
- Place the soil moisture sensor in the soil of the plant.
- Observe the Arduino's serial monitor to check the soil moisture readings.
- When the soil is dry (reading exceeds the threshold), the Arduino will turn on the pump.
- 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
Post a Comment