You are on page 1of 26

ANDROID BASED FARM AUTOMATION USING

GR-SAKURA
INTRODUCTION AND MOTIVATION
With the worlds population growing day by day, and land resources remaining unchanged,
there is a growing need in optimization of agricultural productivity, and this can be achieved by
automation of agriculture.
Farmers are already using computers on tractors to make agriculture more efficient. So called
i-farming' uses GPS to tell tractors where less pesticide is needed, therefore reducing the
usage of pesticide.
But still there has not been any autonomous process where the farmer need not spend more
time in his farm, and lands controlling the action of fertilizers and pesticides, the harvesting of
fruits, the irrigation, the management of power or the maintenance of plants.
Our system aims at automating the agricultural , by availing the farmers a portable and an easy
tool to use that will automate the various processes that the farmer does.

OUR GOAL
Our goal is to develop a portable system, with one end being a Smart Phone with an Android
application, and the other end being a monitoring system using GR-SAKURA interfaced with
LabVIEW, which commands a wireless controlled robot that performs the tasks of the famer
such as applying pesticides and fertilizer, maintaining the plants, harvesting fruits, analysing the
conditions of crops, managing the power being used in the farm, and controlling the irrigation.

THE CHALLENGE
The challenges of this project are:
-

To implement a Real Image Processing based system that will send real time field
images from a wireless camera to a base station.
To integrate a Robotic Arm to a wireless robot, whose operation will be controlled
remotely from an Android application, and which has the capability to identify and track a
targeted object, such as a fruit on a tree.
To integrate pesticide and fertilizer spraying mechanisms on the wireless controlled
robot.
To control the generation of energy using solar power; the power system needs to switch
to this source, whenever the energy from it is sufficient.
To control the irrigation process, by recycling the used waters.

THE SOLUTION
To the above mentioned problems, we propose a remote controlled robot equipped with a
robotic arm and a wireless camera, whose operation will be controlled by an android application
through GR-SAKURA interfaced to the base station to make easier the task of the farmer by
using the various tools of the robot.
This remote controlled robot will include the following modules:
-

A solar panel that recharges the battery of the Robot, and ensures large power
autonomy of the Robot.
An on-board wireless camera that acquire the field image, and transmit them to the base
station, processes the acquired images, and gives results such as crop quality, insects
found, whether a fruit is ripened or not, etc.
An on board robotic arm used for picking fruits from trees, and some other farm products
,and ultimately can be used to pick various plastic and non-alterable dirtiness on the way
when developed.
A mechanism for assuring an accurate spraying of fertilizer and pesticides.
Monitoring and management of power sources. It will monitor the solar energy source,
and will switch to it whenever its energy is sufficient to power the farm robot.

UTILIZATION OF GR-SAKURA IN THE PROJECT


The GR-SAKURA provided an excellent platform for building our prototype utilizing all the
features on the SAKURA board like its Ethernet, SD memory card slot and the arduino
compatible pins.
The following is the explanation on how the board features were utilized.

Arduino Compatible Pins:


All the real time parameters and its values from the field were fed into the GR-SAKURA
by the sensors. The various parameters are soil moisture content, temperature, security
alarm to monitor if animals intrude into the farm, rainfall, humidity, light intensity, wind
direction and speed monitoring. All these are continuously monitored and GR-SAKURA
with its Arduino compatible pins aids in this process.

Ethernet slot:
Using this feature we are able to make the GR-SAKURA act as a server thereby gaining
access to it and controlling the farm activities just by typing the public IP address of the
router present there. Thus through the web farm can be controlled.The port forwarding
has been configured in the router so as to access the SAKURA which is a server. The IP
address of the SAKURA is also configured by us in the range of the router.

Micro SD card slot:


Farmers can use this feature to retrieve stored data in it, may it be temperature,
humidity, rainfall, etc. The data are stored for prescribed number of days in the memory
card. The sdmmc header file is included in the program to include the SD feature into
the project.

The base station monitors the internet database for new updates from the android application,
based on the updates from the android application; the LabVIEW station controls the remote
Robot actions. The station also analyses the images acquired from the wireless camera on the
remote Robot. Apart from these, the LabVIEW station is also equipped with a sensor network
with the GR-SAKURA that monitors the weather, the temperature and the quality of soil and
water;
The LabVIEW station transmits the various data that it has acquired from the farm to an internet
database, which the farmer can monitor using his android application, and from which he can
enable some actions remotely such as the spray of fertilizer, irrigation, fruit picking, etc.
Our project also includes DTMF based control system to control the farm activities in places
which is void of internet. Thus GSM based technology can be used to activate and deactivate
irrigation, fertilizer and other activities.

Images of our project:

APPLICATIONS
This system may find extensive application in agriculture and farming; this concept may further
be applied in areas such as industry, and urban cleaning and maintenance.
It also finds an application in power management, by managing the use of alternative source of
energy.

CONCLUSION AND FUTURE DEVELOPMENT


If implemented, this system may improve the way agriculture is done all over the world by
helping the farmer to save money, time and energy, by doing some of the tasks the farmer
usually does or for which he needs workers.
This system may monitor and report real time situation of the farm in an accurate manner to the
famers mobile, thus helping the farmer to be aware of the condition of the crops and plants,
whether they have been infected by any insects, whether the soil condition is good, etc.
This system also gives to the farmer a tool to activate the spraying of fertilizer and pesticides, to
harvest fruits, to control the irrigation process by recycling used water, to remove unwanted
elements and other dirtiness from the ground, and finally to manage the usage of power.
In future development, a web site can be included in this system, where farm products order can
be placed, and from which order can be processed, packed and made ready for delivery.

Note:
Project demonstration video link :
http://youtu.be/DtOSvFkG_aA

Appendix I

Source code 1 ( For automation system )


/*GR-SAKURA Sketch Template Version: V1.06*/
/*GR-SAKURA Sketch Template Version: V1.06*/
#include <rxduino.h>
#include <serial.h>

// To do serial communication via usb port

#include <string.h>

// To do string manupulation

#include <sdmmc.h>
#include <servo.h>

// To do file access using sd card- external memory


// To do servo control

#include <stdio.h>
#include <stdlib.h>

SDMMC mySD;
using namespace std;

// Function declarations

void myFileAccess();
void writeSerial();
void readSerial();
void irrigateServo(int i);

#define INTERVAL 100

int tempPin = A0; // Analog Pin for temperature sensor


int windPin = A1; // Analog Pin for wind speed sensor
int wind_Dir_Pin = A2 ;// Analog Pin for wind direction sensor
int battery_Pin = A3 ;// Analog Pin for battery voltage sensor
int solar_Pin = A4 ;// Analog Pin for solar voltage sensor
int grid_Pin = A5 ;// Analog Pin for grid pwer sensor
int moisture_Pin = A6 ;// Analog Pin moisture sensor

int waterEnable = 1; // Digital Pin


int robotEnable = 2; // Digital Pin
int alarmEnable = 3; // Digital Pin
int solartrackerEnable = 4; // Digital Pin
int fertilizerEnable = 5; // Digital Pin
int tankEnable = 9; // Digital Pin , PWM pin for servo of irrigation
int opened = 0;

Servo myservo; // create servo object to control a servo

// Identification header letters for each sensor value


String strt = "T",strw = "W",strd = "D",strb = "B";
String strs = "S",strg = "G",strm = "M";

int val;

String temp_val,wind_val,wind_Dir_val,battery_val,solar_val,grid_val,moisture_val;

void setup ()
{
pinMode ( PIN_LED0 , OUTPUT );
pinMode ( PIN_LED1 , OUTPUT );
pinMode ( PIN_LED2 , OUTPUT );
pinMode ( PIN_LED3 , OUTPUT );

pinMode ( waterEnable , OUTPUT );


pinMode ( robotEnable , OUTPUT );
pinMode ( alarmEnable , OUTPUT );
pinMode ( solartrackerEnable , OUTPUT );
pinMode ( fertilizerEnable , OUTPUT );
pinMode ( tankEnable , OUTPUT );

pinMode ( tempPin , INPUT );


pinMode ( windPin , INPUT);
pinMode ( wind_Dir_Pin , INPUT);
pinMode ( battery_Pin , INPUT);

pinMode ( solar_Pin , INPUT);


pinMode ( grid_Pin , INPUT);
pinMode ( moisture_Pin , INPUT);

mySD.begin(); //Start file access from sd card

myservo.attach(9);
myservo.write(0);

Serial.begin (19200,SCI_AUTO); // Open a communication port with PC

Serial.setDefault(); // Set default output stream to the Serial port

Serial1.begin (19200,SCI_USB1);

//string convertInt (int number );

void loop ()

writeSerial(); // calling function writeSerial()

readSerial(); // calling function readSerial()

Serial.println(val);

// Function for read a file and show the file contet

void myFileAccess()
{
digitalWrite(PIN_LED2, 1);
File myFile = mySD.open("sample.txt", FILE_WRITE);

if(myFile == false){
Serial.println("Fail to access MMC");
digitalWrite(PIN_LED2, 0);
//goto nextstate;

}
else
{
//Read
myFile = mySD.open("sample.txt", FILE_READ);
while(myFile.available()){
Serial.print((char)myFile.read());
delay(50);
}

delay(200);
myFile.close();
digitalWrite(PIN_LED2, 0);

// End of myFileAccess()

// Function for getting analog sensor values and writing them into serial

void writeSerial()
{

// Reading Temperature Sensor value and write into serial port

temp_val = String(analogRead(tempPin ));


Serial.println((strt+temp_val));
delay(10);

// Reading Wind Speed Sensor value and write into serial port
wind_val = String(analogRead( windPin ));
Serial.println((strw+wind_val));
delay(10);

// Reading Wind Direction Sensor value and write into serial port
wind_Dir_val = String(analogRead( wind_Dir_Pin ));
Serial.println((strd+wind_Dir_val));
delay(10);

// Reading battery voltage Sensor value and write into serial port
battery_val = String(analogRead( battery_Pin ));
Serial.println((strb+battery_val));
delay(10);

// Reading solar voltage Sensor value and write into serial port
solar_val = String(analogRead( solar_Pin ));
Serial.println((strs+solar_val));
delay(10);

// Reading grid power voltage Sensor value and write into serial port
grid_val = String(analogRead( grid_Pin ));

Serial.println((strg+grid_val));
delay(10);

// Reading grid moisture Sensor value and write into serial port
moisture_val = String(analogRead( moisture_Pin ));
Serial.println((strm+moisture_val));
delay(10);

// End of writeSerial()

// Function for read serial data and activate actuators based on that

void readSerial()
{

if ( Serial.available()>0)
{

delay(10);
val = int(Serial.read());

if ( val == 49)
{
digitalWrite ( PIN_LED0, 1);
digitalWrite ( waterEnable, 1);

}
else if ( val == 50 )
{
digitalWrite ( PIN_LED0, 0);
digitalWrite ( waterEnable, 0);
}
else if ( val == 51 )
{
digitalWrite ( PIN_LED1, 1);
digitalWrite ( robotEnable, 1);
}
else if ( val == 52 )
{
digitalWrite ( PIN_LED1, 0);
digitalWrite ( robotEnable, 0);
}
else if ( val == 53 )
{
digitalWrite ( PIN_LED2, 1);
myFileAccess();
digitalWrite ( PIN_LED2, 0);
}
else if ( val == 54 )
{
digitalWrite ( PIN_LED3, 1);

digitalWrite ( solartrackerEnable, 0);


}
else if ( val == 55 )
{
digitalWrite ( PIN_LED3, 0);
digitalWrite ( solartrackerEnable, 0);
}
else if ( val == 56 )
{
digitalWrite ( fertilizerEnable, 1);
}
else if ( val == 56 )
{
digitalWrite ( fertilizerEnable, 0);
}
else if ( val == 65 )
{
irrigateServo(1);
}
else if ( val == 66 )
{
irrigateServo(0);
}

else
{

// End of readSerial()

void irrigateServo(int enable)


{

int pos1 = 0;

// variable to store the servo position

int pos2 = 75;

if (enable==1 && opened == 0)

{
opened = 1;

for(pos1 = 0; pos1 <= 75; pos1 += 1) // goes from 0 degrees to 75 degrees


{
myservo.write(pos1);
delay(15);
}

// in steps of 1 degree
// tell servo to go to position in variable 'pos'
// waits 15ms for the servo to reach the position

if (enable==0 && opened == 1 )

opened = 0;
for(pos2 = 75; pos2 >=0; pos2 -=1)

// goes from 75 degrees to 0 degrees

{
myservo.write(pos2);
delay(15);

// tell servo to go to position in variable 'pos'


// waits 15ms for the servo to reach the position

digitalWrite(13,HIGH);
}

}
}

Source code 2 ( For web server configuration )


/*GR-SAKURA Sketch Template Version: V1.08*/
#include <rxduino.h>
#include <SPI.h>
#include <Ethernet.h>
TEthernet Ethernet;

// Enter a MAC address and IP address for your controller below.


// The IP address will be dependent on your local network:
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
byte ip[] = {192,168,2,109};

// Initialize the Ethernet server library


// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
EthernetClient client = 0;

int val;
char query;
int home_page = 1;
int temperature = 0;
int light_1;
int light_2;

void setup()
{
pinMode(PIN_LED0,OUTPUT);
pinMode(PIN_LED1,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);

digitalWrite(7, 0);
digitalWrite(9, 0);
digitalWrite(6, 0);
digitalWrite(8, 0);

// start the Ethernet connection and the server:


Ethernet.begin(mac, ip);
server.begin();

delay(500);
digitalWrite(PIN_LED0, 1);
}

void loop()
{
client = server.available();

if (client)
{
while (!client.connected());
digitalWrite(PIN_LED1, 1);

if(home_page)
{
client.println("<html>");
client.println("<head>");

client.println("<style type=\"text/css\">");
client.println("a{ padding: 5px 5px; background:#F33; color: #FFF;}");
client.println("</style>");
client.println("<title>GR SAKURA</title>");
client.println("</head>");
client.println("<body>");
client.println("<div align=\"center\"><span style=\"font-family:Rockwell; fontsize:48px; color:#3fa9f5;\">&nbsp;Emtronizian</span><span style=\"font-family:Rockwell; fontsize:48px; color:#595959;\"> - SCT </span>");
client.println("</div>");
client.println("<div align=\"center\" style=\"font-size:32px; color:#60F;
margin:20px;\"><b>ANDROID BASED FARM AUTOMATION USING GR SAKURA</b>");
client.println("</div>");
client.println("<div align=\"center\" style=\"font-size:24px; color:#060;
margin:20px;\">This is a front panel of the farm automation system using GR SAKURA board to
control irrigation and read temperature of a field, using internet connected device from
anywhere around the world.<br>");
client.println("</div>");
client.println("<div align=\"center\" style=\"font-size:24px; color:#040;
margin:20px;\">GR SAKURA board is configured as a webserver for the farm
automation.<br>");
client.println("</div>");
client.println("<center><a
href=\"http://117.207.111.111:80/c\">START</a></center>");
client.println("</body>");
client.println("</html>");

home_page = 0;
}
else

{
Ethernet.processPackets();
query = client.read();
Ethernet.processPackets();
query = client.read();
Ethernet.processPackets();
query = client.read();
Ethernet.processPackets();
query = client.read();
Ethernet.processPackets();
query = client.read();

Ethernet.processPackets();
query = client.read();

if(query == 'a')
{
digitalWrite(6, 1);
digitalWrite(8, 0);
light_1 = 1;
light_2 = 0;

client.println("<html>");
client.println("<head>");
client.println("<title>My Page</title>");
client.println("</head>");

client.println("<body bgcolor=\"#3fa9f5\">");
client.println("<div align=\"center\">");
client.println("<form action=\"http://117.207.111.111:80/a\">");
client.println("<input type=\"submit\" value=\"LIGHT1\">");
client.println("</form>");
if(light_1)
client.println("Irrigation system is activated");
else
client.println("Irrigation system is deactivatedF");
client.println("<form action=\"http://117.207.111.111:80/b\">");
client.println("<input type=\"submit\" value=\"LIGHT2\">");
client.println("</form>");
if(light_2)
client.println("Fertilizer system is activated");
else
client.println("Fertilizer system is deactivated");
client.println("<form action=\"http://117.207.111.111:80/c\">");
client.println("<input type=\"submit\" value=\"TEMPERATURE\">");
client.println("</form>");
client.println("NO TEMPERATURE DATA");
client.println("</div>");
client.println("</body>");
client.println("</html>");
}
else if(query == 'b')
{

digitalWrite(6, 0);
digitalWrite(8, 1);
light_1 = 0;
light_2 = 1;

client.println("<html>");
client.println("<head>");
client.println("<title>My Page</title>");
client.println("</head>");
client.println("<body bgcolor=\"#3fa9f5\">");
client.println("<div align=\"center\">");
client.println("<form action=\"http://117.207.111.111:80/a\">");
client.println("<input type=\"submit\" value=\"LIGHT1\">");
client.println("</form>");
if(light_1)
client.println("Irrigation system is activated");
else
client.println("Irrigation system is deactivated");
client.println("<form action=\"http://117.207.111.111:80/b\">");
client.println("<input type=\"submit\" value=\"LIGHT2\">");
client.println("</form>");
if(light_2)
client.println("Fertilizer system is activated");
else
client.println("Fertilizer system is deactivated");
client.println("<form action=\"http://117.207.111.111:80/c\">");

client.println("<input type=\"submit\" value=\"TEMPERATURE\">");


client.println("</form>");
client.println("NO TEMPERATURE DATA");
client.println("</div>");
client.println("</body>");
client.println("</html>");
client.println();
}
else if(query == 'c')
{
temperature = (5.0 * analogRead(A0) * 100.0) / 1024;
client.println("<html>");
client.println("<head>");
client.println("<title>My Page</title>");
client.println("</head>");
client.println("<body bgcolor=\"#3fa9f5\">");
client.println("<div align=\"center\">");
client.println("<form action=\"http://117.207.111.111:80/a\">");
client.println("<input type=\"submit\" value=\"LIGHT1\">");
client.println("</form>");
if(light_1)
client.println("Irrigation system is activated");
else
client.println("Irrigation system is deactivated");
client.println("<form action=\"http://117.207.111.111:80/b\">");
client.println("<input type=\"submit\" value=\"LIGHT2\">");

client.println("</form>");
if(light_2)
client.println("Fertilizer system is activated");
else
client.println("Fertilizer system is deactivated");
client.println("<form action=\"http://117.207.111.111:80/c\">");
client.println("<input type=\"submit\" value=\"TEMPERATURE\">");
client.println("</form>");
client.println("FIELD TEMPERATURE = ");
client.print(temperature);
client.print(" Degrees");
client.println("</div>");
client.println("</body>");
client.println("</html>");
client.println();
}
}

client.stop();
delay(500);
client = 0;
digitalWrite(PIN_LED1, 0);
}else;
}

// send FIN packet

You might also like