ANDROID BASED FARM AUTOMATION USING GR-SAKURA INTRODUCTION AND MOTIVATION With the world s 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 famer s 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> #include <string.h> #include <sdmmc.h> #include <servo.h> // To do serial communication via usb port // To do string manupulation // 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 // in steps of 1 degree myservo.write(pos1); delay(15); // 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;\"> 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>"); else home_page = 0;
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(); // send FIN packet delay(500); client = 0; digitalwrite(pin_led1, 0); else;