Design a System That Can Automatically Water Plants based On Soil Moisture Levels

 Here is a basic code for an automatic plant watering system using an Arduino board:

Python Code:

const int moistureSensor = A0; // Pin to which the moisture sensor is connected const int waterPump = 8; // Pin to which the water pump is connected void setup() { pinMode(moistureSensor, INPUT); pinMode(waterPump, OUTPUT); } void loop() { int moistureValue = analogRead(moistureSensor); // Read the value from the moisture sensor if (moistureValue < 400) { // If the soil is dry, turn on the water pump digitalWrite(waterPump, HIGH); delay(1000); // Water for 1 second digitalWrite(waterPump, LOW); } delay(1000); // Check the moisture level again after 1 second }

Hardware and electronic items required:

  • Arduino board (e.g. Arduino Uno)
  • Moisture sensor (e.g. Soil Hygrometer)
  • Water pump (e.g. DC water pump)
  • Power supply (e.g. 9V battery)
  • Breadboard (optional, for prototyping)
  • Jumper wires

Circuit diagram:

How to connect the hardware components:

  1. Connect the positive (+) and negative (-) terminals of the 9V battery to the power supply pins of the Arduino board and the water pump.
  2. Connect the positive (+) terminal of the moisture sensor to A0 on the Arduino board.
  3. Connect the negative (-) terminal of the moisture sensor to GND on the Arduino board.
  4. Connect the positive (+) terminal of the water pump to digital pin 8 on the Arduino board.
  5. Connect the negative (-) terminal of the water pump to GND on the Arduino board.

Note: The pin connections may vary depending on the type of moisture sensor and water pump you use. Make sure to consult the datasheets for the specific components you are using.

The code I provided is not a complete program. It's just a sample code to control a water pump based on the soil moisture level read from a moisture sensor using an Arduino board. To use this code, you will need to upload it to the Arduino board using the Arduino Integrated Development Environment (IDE). The code I provided assumes that you have the necessary hardware components connected to the Arduino board as described in the circuit diagram.

No comments:

Post a Comment

Please disable your ad blocker to support this website.

Our website relies on revenue from ads to keep providing free content.