Homemade Agriculture Robot with multiple sensors. Smart Agriculture Robot

 Agriculture Robots

The agricultural robot, also known as the agro robot, is designed and built to help people in agriculture. The robot could be of different sizes, shapes, and mechanisms. 

Homemade Agriculture Robot with multiple sensors

Homemade Agriculture Robot with multiple sensors
Agriculture Robot with multiple sensors

A smart farmer assistant robot uses a set of sensors and processors, which combinedly take various values from the field, determine the soil weather condition, and give necessary measures to be taken by the farmer. In automatic mode, the robot can operate the field condition by itself, like operating the water pump and spreading fertilizer or pesticide in the required amount in the farmer's absence. This robot communicates with the farmer’s mobile phone and sends regular feedback about the field conditions.

This Smart Agriculture Robot demo video contains the working demo of the Smart Agriculture Robot.

This smart farmer assistant robot works with Arduino. Various sensors for soil, air, and water are attached to it, which feeds the required data to the Arduino processor. The Arduino processors then determine the condition and decisions to be taken for the specific field.

The robot sends primarily analyzed data to the mobile device or smartphone of the farmer,
so that the farmer can make immediate decisions. Again, the robot sends the data to
the agriculture research center or in the central server, which further analyses the data with
machine-learning algorithm for getting future predictions and probable values and measures
to be taken for upgrading the agriculture sector.

There are 13 different types of sensors present in this Agriculture Robot. Accumulating all of its data,
The processor determines the accurate condition of the field. The sensors are:


1. Soil Moisture sensor
2. Sonar Sensor
3. Sound Detector
4. Gas and CO2 sensor
5. LDR
6. Motion Detector
7. Gyroscope
8. Raindrop Sensor
9. Water sensor
10. Air Humidity sensor
11. Weather temperature sensor
12. Soil Quality Sensor
13. Soil pH and Temperature sensor, etc.

1. Soil Moisture Sensor: Determines the soil's moisture level and amount of water.

2. Sonar Sensor: Ultrasonic HC-SR04 sensor uses ultrasonic reflection to measure distance.
This sensor will help the robot in locomotion and detecting objects nearby.

3. Sound Detector: The Sound sensor detects nearby sound levels, and the program
determines the weather condition or nearby animals using sound feedback.

4. Gas, CO2 sensor: Weather air quality is very important for any kind of cultivation.
This sensor determines the level of carbon dioxide, monoxide, presence of harmful
gases, or total air quality.

5. LDR: Light Dependent Resistor determines the day or night for irrigation.

6. Motion Detector: PIR Motion detector can detect the presence of any living
object, animal, or human being inside the perimeter of the field.

7. Gyroscope: X-Y-Z axis gyroscope is used to detect the tilt or rotation of the robot,
which contributes to the locomotion of the robot.

8. Raindrop Sensor: Rain is another important factor in cultivation. This sensor
determines the presence of rain or the amount of rain.

9. Water sensor: This sensor determines the water amount in the field and controls the
irrigation pump accordingly.

10. Air Humidity sensor: Air moisture level plays a vital role in cultivation and weather.
This sensor determines the air moisture and temperature which is used to create the
weather forecast.

11. Weather temperature sensor: Weather temperature plays a role in controlling the
dryness or water level in the soil. This sensor gives an accurate temperature value.

12. Soil Quality Sensor: The soil quality, level of nutrients, and minerals are very important for
determining the fertilizer to be applied. This sensor gives a proper value for
determining the amount.

13. Soil pH Temperature sensor: pH level and soil temperature are also important for the number of fertilizers to be applied.

Circuit diagram of the Agriculture Robot:

Here is the circuit design of the Homemade Agriculture Robot with multiple sensors. 
The circuit design of the robot

Video demonstration of the Agricultural Robot:



This AI Farmer Assistant Robot is the future of agriculture. We cannot skip farming, as this is the prime source of our food. Again, due to technological advancement and various reasons, farmers are leaving this profession. So, for their assistance and as well as for researching every field practically, we need this robot. This robot will be capable of sending very important sensor data to the central server, which will be the key to the future of agriculture. Using a machine-learning algorithm, this system will draw very important information for the further advancement of agriculture and for saving crops from unwanted natural disasters.

Arduino Code For Smart Agriculture Robot :

#include "Adafruit_CCS811.h"
Adafruit_CCS811 ccs;
#include <SoftwareSerial.h>
#include <ArduinoJson.h>
////////////////////////////
#define trig A4
#define echo A5
long duration, distance, sonar;
///////////////////////////////
#include <LCDWIKI_GUI.h>
#include <LCDWIKI_KBV.h>
#include <Wire.h>
#define PAYLOAD_SIZE 2 // how many bytes to expect from each I2C salve node
#define NODE_MAX 6 // maximum number of slave nodes (I2C addresses) to probe
#define START_NODE 2 // The starting I2C address of slave nodes
#define NODE_READ_DELAY 1000 // Some delay between I2C node reads
int nodePayload[PAYLOAD_SIZE];
LCDWIKI_KBV mylcd(ILI9486, 40, 38, 39, -1, 41);
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
SoftwareSerial myGSM(15, 14); // for GSM (RX, TX)
SoftwareSerial s(2, 3); //Server Communication
unsigned long Starttime;
unsigned long Endtime;
String voice;
char a, b, c, d;
int spd = 255;
int spd2 = spd / 5;
int tm = 420;
int co2, tvoc;
int soilmoistureMap, raindropmap, moisturemap, soilPHmap, watermap;
int soiltemp = random(25, 27);
String nutrient;
int led = A14;
int motionfront, sm, motionback, sound, moisture, raindrop, water, soilmoisture, light, soilPH, soilTemp, soilNutriH, soilNutriM, soilNutriL,
motionfrontPin = 4,
motionbackPin = 5,
//soundPin = 22,
moisturePin = A0,
raindropPin = A1,
waterPin = A2,
soilmoisturePin = A3,
soilPHpin = A6,
soilNutriHpin = A11,
soilNutriMpin = A12,
soilNutriLpin = A13,
lightPin = 6,
buzzerpin = 23,
ENl = 8,
ENr = 13,
LmotorPin1 = 9,
LmotorPin2 = 10,
RmotorPin1 = 11,
RmotorPin2 = 12,
SmotorPin1 = A8,
SmotorPin2 = A9;
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
s.begin(9600); // Setting the baud rate of Wifi Module
myGSM.begin(9600); // Setting the baud rate of GSM Module
Wire.begin();
mylcd.Init_LCD();
mylcd.Fill_Screen(BLACK);
delay(500);
fill_rectangle_test();
delay(500);
fill_circles_test();
delay(500);
text_test();
delay(500);
pinMode(motionfrontPin, INPUT); //motion front
pinMode(motionbackPin, INPUT); //motion back
pinMode(lightPin, INPUT); //LDR
//pinMode(soundPin, INPUT); //sound sensor
pinMode(buzzerpin, OUTPUT); //buzzer -----------
pinMode(moisturePin, INPUT); //moisture sensor
pinMode(raindropPin, INPUT); //raindrop sensor
pinMode(waterPin, INPUT); //water sensor
pinMode(soilmoisturePin, INPUT); //soilmoisture
pinMode(soilPHpin, INPUT); //soilpH
pinMode(soilNutriHpin, INPUT); //soilNutriHpin
pinMode(soilNutriMpin, INPUT); //soilNutriMpin
pinMode(soilNutriLpin, INPUT); //soilNutriLpin
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
pinMode(ENl, OUTPUT); //EN L
pinMode(LmotorPin1, OUTPUT); //L+
pinMode(LmotorPin2, OUTPUT); //L-
pinMode(RmotorPin1, OUTPUT); //R+
pinMode(RmotorPin2, OUTPUT); //R-
pinMode(ENr, OUTPUT); //EN R
pinMode(SmotorPin1, OUTPUT);
pinMode(SmotorPin2, OUTPUT);
myGSM.print("AT+CMGF=1\r");
delay(100);
myGSM.println("AT+CNMI=2,2,0,0,0"); // AT Command to recieve a live SMS
}
void loop()
{
while (Serial1.available())
{
//Check if there is an available byte to read
delay(10); //Delay added to make thing stable
char c = Serial1.read(); //Conduct a serial read
if (c == '#')
{
break;
}
//Exit the loop when the # is detected after the word
voice += c; //Shorthand for voice = voice + c
}
if (voice.length() > 0)
{
if (voice == "5")
{
Starttime = millis();
int t = Starttime;
Serial.println("Time Checked");
Serial.print(Starttime);
do { Starttime = millis();
Serial.println("Entering Auto Mode");
SonarSensor(trig, echo);
sonar = distance;
Serial.println(sonar);
display();
if (sonar >= 15)
{
analogWrite(ENl, spd);
analogWrite(ENr, spd);
digitalWrite(LmotorPin1, HIGH);
digitalWrite(LmotorPin2, LOW);
digitalWrite(RmotorPin1, HIGH);
digitalWrite(RmotorPin2, LOW);
Serial.println("front");
}
if (sonar <= 10)
{
analogWrite(LmotorPin1, 0);
analogWrite(LmotorPin2, 0);
analogWrite(RmotorPin1, 0);
analogWrite(RmotorPin2, 0);
Serial.println("Stop");
delay(800);
}
Endtime = millis();
int e = Endtime;
delay(100);
if (Serial1.available() || e > t + 5000)
{
///counting 5 sec
Serial.print("Time: ");
Serial.println(t - Endtime / 1000);
Serial.println(t);
Serial.print(Endtime);
Serial.println("%%%%%%%%%%%%%%%%");
analogWrite(LmotorPin1, 0);
analogWrite(LmotorPin2, 0);
analogWrite(RmotorPin1, 0);
analogWrite(RmotorPin2, 0);
Serial.println("Stop");
SensorMotor();
break;
}
Serial.println(t);
//break;
} while (voice.length() > 0);
t = 0;
}
if (voice == "a") //front
{
analogWrite(ENl, spd);
analogWrite(ENr, spd);
digitalWrite(LmotorPin1, HIGH);
digitalWrite(LmotorPin2, LOW);
digitalWrite(RmotorPin1, HIGH);
digitalWrite(RmotorPin2, LOW);
Serial.println("front");
delay(100);
voice = "x";
}
else if (voice == "b")
{
analogWrite(ENl, spd);
analogWrite(ENr, spd);
digitalWrite(LmotorPin1, LOW);
digitalWrite(LmotorPin2, HIGH);
digitalWrite(RmotorPin1, LOW);
digitalWrite(RmotorPin2, HIGH);
Serial.println("back");
delay(100);
voice = "x";
}
else if (voice == "c") //left
{
analogWrite(ENl, 0);
analogWrite(ENr, spd);
digitalWrite(RmotorPin1, HIGH);
digitalWrite(RmotorPin2, LOW);
Serial.println("left");
delay(100);
voice = "x";
}
else if (voice == "d") //right
{
analogWrite(ENl, spd);
analogWrite(ENr, 0);
digitalWrite(LmotorPin1, HIGH);
digitalWrite(LmotorPin2, LOW);
Serial.println("right");
delay(100);
voice = "x";
}
else if (voice == "u") //right
{
digitalWrite(led, HIGH);
delay(100);
voice = "x";
}
else if (voice == "v") //right
{
digitalWrite(led, LOW);
delay(100);
voice = "x";
}
else if (voice == "m") //Speed Low
{
Serial.println("speed 1");
spd = 170;
tm = 2000;
voice = "x";
}
else if (voice == "n") //s2
{
Serial.println("speed 2");
spd = 210;
tm = 670;
voice = "x";
}
else if (voice == "o") //Speed High
{
Serial.println("speed 3");
spd = 255;
tm = 420;
voice = "x";
}
else if (voice == "1")
{
mylcd.Fill_Screen(BLACK);
sensorValue();
SendMessageAll();
toServer();
display();
delay(1000);
}
if (voice == "x")
{
analogWrite(LmotorPin1, 0);
analogWrite(LmotorPin2, 0);
analogWrite(RmotorPin1, 0);
analogWrite(RmotorPin2, 0);
Serial.println("IDLE");
}
voice = ""; //Reset the variable after initiating
}
}
void sensorValue()
{
motionfront = digitalRead(motionfrontPin);
motionback = digitalRead(motionbackPin);
light = digitalRead(lightPin);
moisture = analogRead(moisturePin);
moisturemap = map(moisture, 1, 1023, 10, 1);
raindrop = analogRead(raindropPin);
raindropmap = map(raindrop, 1, 1023, 100, 1);
water = analogRead(waterPin);
watermap = map(water, 1, 1023, 1, 100);
soilmoisture = analogRead(soilmoisturePin);
soilmoistureMap = map(soilmoisture, 1, 1023, 100, 1);
soilPH = analogRead(soilPHpin); //
soilPHmap = map(soilPH, 1, 1000, 5, 8);
soilNutriH = digitalRead(soilNutriHpin); //
soilNutriM = digitalRead(soilNutriMpin); //
soilNutriL = digitalRead(soilNutriLpin); //
if (soilNutriH == 1)
{
nutrient = "high";
}
else if (soilNutriM == 1)
{
nutrient = "medium";
}
else if (soilNutriL == 1)
{
nutrient = "low";
}
else
{
nutrient = "medium";
}
Serial.print("distance=");
Serial.print(sonar);
Serial.println("cm");
Serial.print("font motion:");
Serial.println(motionfront);
Serial.print("back motion:");
Serial.println(motionback);
Serial.print("sound sensor:");
Serial.println(sound);
Serial.print("air moisture:");
Serial.println(sm);
Serial.print("rain drops:");
Serial.println(raindrop);
Serial.print("land water level:");
Serial.println(water);
Serial.print("light:");
Serial.println(light);
Serial.print("Co2:");
Serial.println(co2);
Serial.print("tvoc:");
Serial.println(tvoc);
Serial.print("soil pH: ");
Serial.println(soilPH);
Serial.print("Soil Temperature: ");
Serial.println(soiltemp);
Serial.print("Soil Moisture: ");
Serial.println(soilmoistureMap);
Serial.print("Soil Nutrient:");
Serial.println(nutrient);
Serial.println("-------------------------------------------");
Serial1.print(" Look at the Display");
delay(100);
voice = "x";
}
void SensorMotor()
{
digitalWrite(SmotorPin1, HIGH);
digitalWrite(SmotorPin2, LOW);
Serial.println("Sensor Motor");
delay(3800);
digitalWrite(SmotorPin1, LOW);
digitalWrite(SmotorPin2, LOW);
Serial.print("Check Sensor Data");
delay(1000);
sensorValue();
SendMessageAll();
toServer();
display();
delay(1000);
digitalWrite(SmotorPin1, LOW);
digitalWrite(SmotorPin2, HIGH);
delay(3800);
digitalWrite(SmotorPin1, LOW);
digitalWrite(SmotorPin2, LOW);
voice = "x";
}
void SonarSensor(int trig, int echo)
{
digitalWrite(trig, LOW);
delayMicroseconds(2);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
duration = pulseIn(echo, HIGH);
distance = (duration / 2) / 29.1;
}
void display()
{
mylcd.Set_Rotation(0);
mylcd.Set_Text_colour(CYAN);
mylcd.Set_Text_Back_colour(BLACK);
mylcd.Set_Text_Size(2.7);
mylcd.Print_String("Smart Farming Robot", 25, 0);
mylcd.Set_Text_colour(WHITE);
mylcd.Set_Text_Size(2);
mylcd.Print_String("Authors: Md. Mehr Mahmud", 25, 22);
mylcd.Set_Text_colour(WHITE);
mylcd.Set_Text_Size(2);
mylcd.Print_String("Ashabul Yaneen Aurjon", 25, 42);
mylcd.Print_String("----------------------------", 0, 56);
mylcd.Set_Text_colour(RED);
mylcd.Set_Text_Size(2);
mylcd.Print_String("Air moisture: ", 10, 75);
mylcd.Set_Text_colour(GREEN);
mylcd.Set_Text_Size(2);
String m = String(moisturemap);
String msg = String(m + "%");
mylcd.Print_String(msg, 10, 95);
mylcd.Set_Text_colour(RED);
mylcd.Set_Text_Size(2);
mylcd.Print_String("Rain Status: ", 10, 115);
mylcd.Set_Text_colour(GREEN);
mylcd.Set_Text_Size(2);
if (raindrop < 800)
{
mylcd.Print_String("No Rain.", 10, 135);
}
else if (raindrop > 801)
{
mylcd.Print_String("Raining.", 10, 135);
}
mylcd.Set_Text_colour(RED);
mylcd.Set_Text_Size(2);
mylcd.Print_String("Soil Nutrient Level: ", 10, 155);
mylcd.Set_Text_colour(GREEN);
mylcd.Set_Text_Size(2);
mylcd.Print_String(nutrient, 10, 175);
mylcd.Set_Text_colour(WHITE);
mylcd.Set_Text_Size(2);
mylcd.Print_String("----------------------------", 0, 190);
mylcd.Set_Text_colour(BLUE);
mylcd.Set_Text_Size(2);
mylcd.Print_String("Object at: ", 10, 210);
mylcd.Set_Text_colour(YELLOW);
mylcd.Set_Text_Size(2);
String son = String(sonar);
mylcd.Print_String(son, 10, 230);
mylcd.Set_Text_colour(BLUE);
mylcd.Set_Text_Size(2);
mylcd.Print_String("Land Water level: ", 10, 250);
mylcd.Set_Text_colour(YELLOW);
mylcd.Set_Text_Size(2);
if (water < 50)
{
mylcd.Print_String("Water level Normal", 10, 270);
}
else if (water > 51)
{
mylcd.Print_String("Water Overflowed!", 10, 270);
}
mylcd.Set_Text_colour(BLUE);
mylcd.Set_Text_Size(2);
mylcd.Print_String("Soil Temperature:", 10, 290);
String soilT = String(soiltemp);
mylcd.Set_Text_colour(YELLOW);
mylcd.Set_Text_Size(2);
mylcd.Print_String(soilT, 10, 310);
mylcd.Set_Text_colour(WHITE);
mylcd.Set_Text_Size(2);
mylcd.Print_String("----------------------------", 0, 325);
mylcd.Set_Text_colour(MAGENTA);
mylcd.Set_Text_Size(2);
mylcd.Print_String("Air Quality:", 10, 345);
mylcd.Set_Text_colour(WHITE);
mylcd.Set_Text_Size(2);
mylcd.Print_String("saturated", 10, 365);
mylcd.Set_Text_colour(MAGENTA);
mylcd.Set_Text_Size(2);
mylcd.Print_String("Air humidity:", 10, 385);
mylcd.Set_Text_colour(WHITE);
mylcd.Set_Text_Size(2);
String h = String(moisturemap);
String hh = String(h + " %");
mylcd.Print_String(hh, 10, 405);
}
void gSensor()
{
/// Gass Sensor
co2 = ccs.geteCO2();
tvoc = ccs.getTVOC();
if (ccs.available())
{
if (!ccs.readData())
{
Serial.print("CO2: ");
Serial.print(co2);
Serial.print("ppm, TVOC: ");
Serial.println(tvoc);
}
else
{
Serial.println("ERROR!");
while (1);
}
}
}
void SendMessageAll()
{
Serial.println("Sending SMS");
myGSM.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
myGSM.println("AT+CMGS=\"+8801747144755\"\r"); // Replace x with mobile number
delay(1000);
String allInfo = ("Welcome Smart Farmer. Moisture: " + String(moisturemap) + ". Water Level: " + String(watermap) + ".Soil Moisture: " + String(soilmoistureMap) + ".Soil Nutrient: " + nutrient);
myGSM.println(allInfo); // The SMS text you want to send
delay(100);
myGSM.println((char) 26); // ASCII code of CTRL+Z
delay(1000);
}
void toServer()
{
////To send data in Server
Serial.println("Sending to Server");
StaticJsonBuffer<1000> jsonBuffer;
JsonObject &root = jsonBuffer.createObject();
root["data1"] = moisturemap;
root["data2"] = soilmoistureMap;
root["data3"] = raindropmap;
root["data4"] = watermap;
root["data5"] = light;
root["data6"] = nutrient;
root["data7"] = soilPHmap;
root.printTo(s);
delay(500);
}
void fill_rectangle_test(void) //Display effect
{
int i = 0;
mylcd.Fill_Screen(BLACK);
mylcd.Set_Draw_color(YELLOW);
mylcd.Fill_Rectangle(0, (mylcd.Get_Display_Height() - mylcd.Get_Display_Width()) / 2, mylcd.Get_Display_Width() - 1, mylcd.Get_Display_Height() - (mylcd.Get_Display_Height() - mylcd.Get_Display_Width()) / 2);
mylcd.Set_Draw_color(MAGENTA);
for (i = 0; i < mylcd.Get_Display_Width() / 2; i += 4)
{
mylcd.Draw_Rectangle(i, (mylcd.Get_Display_Height() - mylcd.Get_Display_Width()) / 2 + i, mylcd.Get_Display_Width() - 1 - i, mylcd.Get_Display_Height() - (mylcd.Get_Display_Height() - mylcd.Get_Display_Width()) / 2 - i);
delay(5);
}
for (i = 0; i < mylcd.Get_Display_Width() / 2; i += 4)
{
mylcd.Set_Draw_color(random(255), random(255), random(255));
mylcd.Fill_Rectangle(i, (mylcd.Get_Display_Height() - mylcd.Get_Display_Width()) / 2 + i, mylcd.Get_Display_Width() - 1 - i, mylcd.Get_Display_Height() - (mylcd.Get_Display_Height() - mylcd.Get_Display_Width()) / 2 - i);
delay(5);
}
}
void fill_circles_test(void) //Display effect
{
int r = 10, i = 0, j = 0;
mylcd.Fill_Screen(BLACK);
mylcd.Set_Draw_color(MAGENTA);
for (i = r; i < mylcd.Get_Display_Width(); i += 2 *r)
{
for (j = r; j < mylcd.Get_Display_Height(); j += 2 *r)
{
mylcd.Fill_Circle(i, j, r);
}
}
}
void text_test() //Display Text effect
{
mylcd.Set_Text_Mode(0);
mylcd.Fill_Screen(BLACK);
mylcd.Set_Text_Back_colour(BLACK);
mylcd.Set_Text_colour(RED);
mylcd.Set_Text_Size(3);
mylcd.Print_String("Smart Farming", 40, 60);
mylcd.Set_Text_colour(YELLOW);
mylcd.Set_Text_Size(4);
mylcd.Print_String("ROBOT", 85, 90);
mylcd.Set_Text_colour(CYAN);
mylcd.Set_Text_Size(2);
mylcd.Print_String("BDRO - 2019", 80, 130);
}

4 Comments

Post a Comment