Grow-C - MAN 1 Kota Kediri | Akademi Madrasah Digital (AMD) 2021
Table of Contents
Introduction
This tutorial outlines how to implement the Grow-C IoT solution developed by MAN 1 Kota Kediri, designed to assist farmers in monitoring and maintaining optimal soil moisture and air temperature using real-time sensor technology. By following these steps, you will learn how to set up a system that allows for efficient remote monitoring and automated irrigation, ultimately improving agricultural productivity.
Step 1: Understand the System Components
Familiarize yourself with the key components of the Grow-C system:
-
Sensors:
- DHT22: Measures air temperature and humidity.
- Soil Moisture Sensor: Monitors the moisture level in the soil.
-
Pumps:
- Pump 1: Activates to irrigate the soil when moisture is low.
- Pump 2: Activates to cool the air when temperature is too high.
Step 2: Setting Up the DHT22 Sensor
To monitor air temperature, follow these steps:
-
Connect the DHT22 Sensor:
- Wire the DHT22 to your microcontroller (e.g., Arduino).
- Ensure you connect the power (VCC), ground (GND), and data pin correctly.
-
Install the Required Library:
- If you are using Arduino, install the DHT library from the Arduino Library Manager.
-
Write the Code:
- Use the following code snippet to read data from the DHT22 sensor:
#include "DHT.h" #define DHTPIN 2 // Pin where the DHT sensor is connected #define DHTTYPE DHT22 // DHT 22 (AM2302) DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); dht.begin(); } void loop() { float h = dht.readHumidity(); float t = dht.readTemperature(); if (isnan(h) || isnan(t)) { Serial.println("Failed to read from DHT sensor!"); return; } Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.println(" *C"); delay(2000); }
Step 3: Setting Up the Soil Moisture Sensor
Follow these steps to monitor soil moisture:
-
Connect the Soil Moisture Sensor:
- Wire the sensor to the microcontroller, connecting power, ground, and the signal pin.
-
Write the Code:
- Integrate this code snippet to read the moisture level:
int moisturePin = A0; // Analog pin for soil moisture sensor void setup() { Serial.begin(9600); } void loop() { int moistureLevel = analogRead(moisturePin); Serial.print("Soil Moisture Level: "); Serial.println(moistureLevel); delay(2000); }
Step 4: Automating the Pump Control
To automate the irrigation process based on sensor readings:
-
Define Pump Control Logic:
- If soil moisture is below a certain threshold, activate Pump 1.
- If air temperature exceeds a threshold, activate Pump 2.
-
Implement the Control Logic:
- Extend your code to include pump control:
int pump1Pin = 3; // Pump 1 control pin int pump2Pin = 4; // Pump 2 control pin void setup() { pinMode(pump1Pin, OUTPUT); pinMode(pump2Pin, OUTPUT); // Other setup code... } void loop() { // Read sensor values... if (moistureLevel < threshold) { digitalWrite(pump1Pin, HIGH); // Activate Pump 1 } else { digitalWrite(pump1Pin, LOW); // Deactivate Pump 1 } if (temperature > threshold) { digitalWrite(pump2Pin, HIGH); // Activate Pump 2 } else { digitalWrite(pump2Pin, LOW); // Deactivate Pump 2 } // Other loop code... }
Conclusion
By following these steps, you can set up the Grow-C IoT system to effectively monitor soil moisture and air temperature, automating the irrigation process for farmers. This system enhances efficiency and provides a means for remote monitoring, making agricultural practices more sustainable. For further development, consider integrating a mobile app for notifications or remote control of the pumps.