Irrigation using soil sensor and Arduino

Description: This project deals with watering of plants in agriculture based on the soil moisture content using Arduino Uno. Also there is a GSM SIM 800A module to send data to the server and use it for analytics and prediction. (This is a prototype).

Materials Required: (links to buy given at the end of the page)

Circuit Diagram

Code


#include <SIM800.h>
//TX 10
//RX 11
int GLED= 8; // Wet Indicator at Digital PIN D13
int RLED= 9; // Dry Indicator at Digital PIN D12
int SENSE= 0; // Soil Sensor input at Analog PIN A0
int value= 0;
int GPRSstart= 0;
int MOTOR = 5;
unsigned long bauds = 9600;
void setup() {
Serial.begin(bauds);
pinMode(GLED, OUTPUT);
pinMode(RLED, OUTPUT);
pinMode(MOTOR, OUTPUT);
Serial.println("SOIL MOISTURE SENSOR");
Serial.println("-----------------------------");
while (!Serial) {;}
SIM.begin(bauds);
delay(100);
digitalWrite(MOTOR, LOW);
SIM.setTimeout(5000);
}
void loop() {
Serial.println(GPRSstart);
if(GPRSstart==0){
SIM.ipBearer(SET, "3,1,\"Contype\",\"GPRS\""); // Configure profile 1 connection as "GPRS"
SIM.ipBearer(SET, "3,1,\"APN\",\"www\""); // Set profile 1 access point name to "internet". This is for vodafone India
SIM.ipBearer(SET, "1,1"); // Open GPRS connection on profile 1
SIM.ipBearer(SET, "2,1"); // Display IP address of profile 1
String response;
while (Serial.available() > 0) {
response += Serial.read();
delay(100);
}
const char *res = response.c_str();
Serial.println(response);
if(strcmp(res, "OK")){
GPRSstart=1;
StoreData();
}
}
else
{
StoreData();
}
// Terminate HTTP functionality
//SIM.ipBearer(SET, "0,1");
}
void StoreData(){
value= analogRead(SENSE);
value= value/10;
Serial.println(value);
if(value<30)
{
digitalWrite(RLED,LOW);
digitalWrite(GLED, HIGH);
digitalWrite(MOTOR, LOW);
}
else
{
digitalWrite(GLED, LOW);
digitalWrite(RLED,HIGH);
digitalWrite(MOTOR, HIGH);
}
delay(3000);
SIM.httpInit(EXE); // Initialize HTTP functionality
SIM.httpParams(SET, "\"CID\",1"); // Choose profile 1 as HTTP channel
String URL="\"URL\",\"---IP Address---/save.php?soilMoisture="+(String)value+"\"";
const char *url = URL.c_str();
SIM.httpParams(SET, url); // Set URL to www.sim.com
SIM.httpAction(SET, "0"); // Get the webpage
while(!SIM.available()) {;} // Wait until the webpage has arrived
SIM.httpRead(EXE); // Send the received webpage to Arduino
SIM.httpEnd(EXE);
}

Extra Libraries


SIM800.h  Aspen_SIM800-1.0.1.zip (How to insert Library on Arduino)

2 thoughts on “Irrigation using soil sensor and Arduino

  1. There is a small connection error the green wire from 8 should be connected to the positive end of the LED on the left.

Leave a Reply

Your email address will not be published. Required fields are marked *

RSS
Follow by Email
Facebook
Twitter