www.svsembedded.com SVSEMBEDDED
svsembedded@gmail.com,
CONTACT: 9491535690,
7842358459
Automatic irrigation using Arduino Nano and soilmoisture sensor
Creating an automatic irrigation system using an Arduino Nano and a soil moisture sensor is a practical and useful project for keeping your plants watered efficiently. The basic idea is to use the soil moisture sensor to measure the moisture level of the soil, and then trigger the irrigation system when the moisture level falls below a certain threshold. Here's a step-by-step guide to help you get started:
Components you'll need:
- Arduino Nano or any compatible Arduino board
- Soil moisture sensor (analog or digital)
- Relay module (to control the water pump or solenoid valve)
- Water pump or solenoid valve (to deliver water to the plants)
- Power supply (for Arduino and the water pump/valve)
- Jumper wires
- Breadboard or perfboard (optional)
Step 1: Connect the Components
Connect the soil moisture sensor to the Arduino:
- For analog soil moisture sensor, connect VCC to 5V, GND to GND, and A0 to an analog pin (e.g., A0).
- For digital soil moisture sensor, connect VCC to 5V, GND to GND, and D0 to a digital pin (e.g., D2).
Connect the relay module to the Arduino:
- Connect the IN1 pin of the relay module to a digital pin (e.g., D3) on the Arduino.
- Connect the VCC and GND pins of the relay module to 5V and GND on the Arduino, respectively.
- Connect the COM (Common) and NO (Normally Open) terminals of the relay to the positive and negative terminals of the water pump/valve, respectively.
Step 2: Write the Arduino Code Now, you need to program the Arduino to read the soil moisture sensor data and control the relay based on the moisture level. You can use the Arduino IDE for this purpose:
const int moisturePin = A0; // Analog pin to read the moisture sensor const int relayPin = 3; // Digital pin connected to the relay module int moistureThreshold = 500; // Adjust this value based on your sensor and plants' needs void setup() { pinMode(relayPin, OUTPUT); digitalWrite(relayPin, LOW); // Turn off the relay initially Serial.begin(9600); } void loop() { int moistureValue = analogRead(moisturePin); Serial.print("Moisture: "); Serial.println(moistureValue); if (moistureValue < moistureThreshold) { // If moisture level is below the threshold, turn on the irrigation digitalWrite(relayPin, HIGH); Serial.println("Water pump ON"); delay(2000); // Adjust the delay time to control the watering duration digitalWrite(relayPin, LOW); Serial.println("Water pump OFF"); } delay(1000); // Delay between moisture readings }
Step 3: Upload the Code to Arduino Connect your Arduino Nano to your computer using a USB cable and upload the code using the Arduino IDE.
Step 4: Calibration and Adjustment
Place the soil moisture sensor in the plant's soil and adjust the moistureThreshold
value in the code to suit the moisture level at which you want the irrigation to start. You may need to experiment and calibrate the threshold according to your specific soil type and plant requirements.
Step 5: Power Supply Make sure to use an appropriate power supply for your water pump/valve and consider the power requirements when choosing the relay module.
With this setup, your Arduino will continuously monitor the soil moisture level, and when it drops below the threshold, it will activate the water pump or valve to water your plants. Remember to be cautious when working with water and electricity, and follow safety guidelines to avoid any accidents.
Note: Always be careful when dealing with electrical components and water to avoid any damage or harm.