Introduction
A Smart Agriculture System is an IoT-based farming solution that uses sensors, automation, and data analytics to improve crop productivity and optimize resource usage. It continuously monitors soil moisture, temperature, humidity, and environmental conditions and automates irrigation and alerts farmers in real time.
This system supports precision farming, reduces water wastage, and increases agricultural efficiency.
Objective of the Project
- To monitor soil and environmental conditions in real time
- To automate irrigation based on soil moisture levels
- To reduce water wastage and manual effort
- To improve crop yield using smart technology
Working Principle
The system collects data from multiple sensors installed in the field and processes it using an IoT-enabled microcontroller.
Step-by-Step Working
- Soil moisture sensor measures water content in soil
- DHT11/DHT22 sensor measures temperature and humidity
- ESP32 / Arduino processes sensor data
- When soil moisture is low, water pump is automatically activated
- Data is sent to a cloud platform for remote monitoring
- Alerts can be sent to farmers via mobile app
Components Required
- ESP32 / ESP8266 / Arduino Uno
- Soil Moisture Sensor
- DHT11 / DHT22 Sensor
- Relay Module
- Water Pump / DC Motor
- Jumper Wires
- Breadboard / PCB
- Power Supply
- IoT Platform (Blynk / ThingSpeak / Firebase)
Block Diagram
Soil Moisture Sensor
Temperature & Humidity Sensor
↓
ESP32
↓
Relay Module
↓
Water Pump
↓
Crop Field
ESP32 → Wi-Fi → IoT Cloud → Mobile App
Circuit Connections
Soil Moisture Sensor
VCC → 3.3V / 5V
GND → GND
AO → GPIO34
DHT22 Sensor
VCC → 3.3V
GND → GND
DATA → GPIO4
Relay Module
IN → GPIO26
VCC → 5V
GND → GND
Arduino Code (Smart Irrigation System)
#include <WiFi.h>
#include "DHT.h"
#include "ThingSpeak.h"
#define SOIL_PIN 34
#define DHTPIN 4
#define DHTTYPE DHT22
#define RELAY_PIN 26
DHT dht(DHTPIN, DHTTYPE);
const char* ssid = "Your_WiFi";
const char* password = "Your_Password";
WiFiClient client;
unsigned long channelID = 123456;
const char* writeAPIKey = "YOUR_API_KEY";
void setup() {
Serial.begin(9600);
dht.begin();
pinMode(RELAY_PIN, OUTPUT);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
ThingSpeak.begin(client);
}
void loop() {
int soilValue = analogRead(SOIL_PIN);
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
Serial.print("Soil Moisture: ");
Serial.println(soilValue);
Serial.print("Temperature: ");
Serial.println(temperature);
Serial.print("Humidity: ");
Serial.println(humidity);
if (soilValue > 2500) { // Dry soil
digitalWrite(RELAY_PIN, HIGH); // Pump ON
} else {
digitalWrite(RELAY_PIN, LOW); // Pump OFF
}
ThingSpeak.setField(1, soilValue);
ThingSpeak.setField(2, temperature);
ThingSpeak.setField(3, humidity);
ThingSpeak.writeFields(channelID, writeAPIKey);
delay(20000);
}
Code Explanation
- Soil moisture sensor detects dryness of soil
- ESP32 automatically turns ON/OFF water pump
- Environmental data is uploaded to cloud
- Farmers can monitor conditions remotely
Advantages
- Efficient water usage
- Reduced labor cost
- Increased crop productivity
- Real-time monitoring and automation
Applications
- Smart farming and precision agriculture
- Greenhouses
- Agricultural research
- Smart irrigation systems
Future Enhancements
- Add weather forecasting integration
- AI-based crop disease prediction
- Fertilizer automation system
- Solar-powered agriculture systems
Conclusion
The Smart Agriculture System is a powerful IoT-based solution that improves farming efficiency by enabling real-time monitoring, automation, and smart decision-making. It supports sustainable agriculture and helps farmers increase yield with reduced resources.
