This guide will help you create an IoT-based Smart Agriculture Monitoring System. The system will monitor critical environmental parameters such as soil moisture, temperature, humidity, and light levels to help optimize farming practices and improve crop yield.

Components Required

  • Arduino (Uno or similar)
  • Soil moisture sensor
  • DHT22 or DHT11 sensor (for temperature and humidity)
  • LDR (Light Dependent Resistor) for light intensity
  • Relay module (for controlling irrigation systems)
  • Wi-Fi module (ESP8266 or similar)
  • Connecting wires and breadboard
  • Power supply (for Arduino and sensors)
  • Cloud service account (for real-time monitoring and alerts)

Setting Up the Hardware

Follow these steps to set up the hardware:

  1. Connect the Soil Moisture Sensor

    Attach the soil moisture sensor to the Arduino to measure soil moisture levels. Ensure proper wiring for accurate readings.

  2. Connect the Temperature and Humidity Sensor

    Install the DHT22 or DHT11 sensor to monitor temperature and humidity levels. Connect it to the Arduino for data collection.

  3. Set Up the Light Sensor

    Connect the LDR to measure light intensity. Use a suitable resistor to ensure correct readings.

  4. Integrate the Relay Module

    Use the relay module to control irrigation systems based on soil moisture levels. Ensure that the relay can handle the load of the irrigation system.

  5. Connect the Wi-Fi Module

    Attach the Wi-Fi module to the Arduino for communication with a cloud service to send data and receive alerts.

  6. Power the System

    Ensure all components are properly powered using the appropriate power supply.

Programming the Arduino

Program the Arduino to collect data from sensors and control the relay based on soil moisture readings. Here’s a basic outline of the code:


                #include <DHT.h>
                #include <ESP8266WiFi.h>

                #define DHTPIN 2
                #define DHTTYPE DHT22
                #define MOISTURE_PIN A0
                #define LIGHT_PIN A1
                #define RELAY_PIN D1

                DHT dht(DHTPIN, DHTTYPE);
                WiFiClient client;

                const char* ssid = "your_ssid";
                const char* password = "your_password";
                const char* cloud_url = "http://your-cloud-service-url";

                void setup() {
                Serial.begin(9600);
                dht.begin();
                pinMode(MOISTURE_PIN, INPUT);
                pinMode(LIGHT_PIN, INPUT);
                pinMode(RELAY_PIN, OUTPUT);
                WiFi.begin(ssid, password);

                while (WiFi.status() != WL_CONNECTED) {
                    delay(1000);
                    Serial.print(".");
                }

                Serial.println("Connected to Wi-Fi");
                }

                void loop() {
                int soilMoisture = analogRead(MOISTURE_PIN);
                float temperature = dht.readTemperature();
                float humidity = dht.readHumidity();
                int lightIntensity = analogRead(LIGHT_PIN);

                Serial.print("Soil Moisture: ");
                Serial.println(soilMoisture);
                Serial.print("Temperature: ");
                Serial.print(temperature);
                Serial.println(" C");
                Serial.print("Humidity: ");
                Serial.print(humidity);
                Serial.println(" %");
                Serial.print("Light Intensity: ");
                Serial.println(lightIntensity);

                if (soilMoisture < 300) {  // Threshold for soil moisture
                    digitalWrite(RELAY_PIN, HIGH);  // Turn on irrigation
                    sendAlert("Irrigation On");
                } else {
                    digitalWrite(RELAY_PIN, LOW);  // Turn off irrigation
                    sendAlert("Irrigation Off");
                }

                sendDataToCloud(soilMoisture, temperature, humidity, lightIntensity);

                delay(60000);  // Wait 1 minute before next reading
                }

                void sendDataToCloud(int moisture, float temp, float hum, int light) {
                if (client.connect(cloud_url, 80)) {
                    client.print("GET /update?api_key=your_api_key");
                    client.print("&field1=");
                    client.print(moisture);
                    client.print("&field2=");
                    client.print(temp);
                    client.print("&field3=");
                    client.print(hum);
                    client.print("&field4=");
                    client.print(light);
                    client.println(" HTTP/1.1");
                    client.println("Host: your-cloud-service-url");
                    client.println("Connection: close");
                    client.println();
                }
                }

                void sendAlert(String message) {
                if (client.connect(cloud_url, 80)) {
                    client.print("GET /alert?api_key=your_api_key&message=");
                    client.print(message);
                    client.println(" HTTP/1.1");
                    client.println("Host: your-cloud-service-url");
                    client.println("Connection: close");
                    client.println();
                }
                }
            

This code reads data from sensors, controls the irrigation system, and sends data to the cloud service.

Setting Up the Cloud Service

Configure your cloud service to receive and display data from the IoT system. Here’s a basic overview:

  1. Create an Account

    Sign up for a cloud service that supports HTTP requests and data visualization (e.g., ThingSpeak, Blynk).

  2. Set Up Data Fields

    Create data fields to store soil moisture, temperature, humidity, and light intensity. Set up alerts and notifications as needed.

  3. Integrate with IoT Device

    Use the provided API key and endpoint in your Arduino code to send data to the cloud service.

Testing and Calibration

Test the system in different environmental conditions to ensure accurate readings and reliable operation. Calibrate the sensors and adjust the system settings as needed for optimal performance.

Conclusion

The IoT-based Smart Agriculture Monitoring System provides a comprehensive solution for monitoring and managing farm conditions. By integrating various sensors with IoT technology, this project enhances agricultural efficiency and productivity through real-time data and automated control.