Table of Contents

Play Video

AGRITECH

The Agritech project uses an Arduino, motor driver, GPS module, soil moisture sensor, ultrasonic sensor, and servo motor to automate agricultural tasks. It maps fields, monitors soil moisture, plants seeds, and avoids obstacles, enhancing farming efficiency and productivity.

The Agritech Car project is an innovative agricultural automation solution designed to enhance farming efficiency and productivity. This project leverages an Arduino microcontroller to integrate various sensors and actuators, enabling the car to perform essential agricultural tasks autonomously. Key components include a motor driver, motors, GPS module, soil moisture sensor, ultrasonic sensor, and a servo motor.

Components List:

  1. Arduino Uno: The central microcontroller that coordinates the operation of all sensors and motors.
  2. Motor Driver (e.g., L298N): Controls the motors, allowing the car to move forward, backward, and turn.
  3. DC Motors: Provide the necessary propulsion for the car.
  4. GPS Module: Provides real-time location data, allowing for precise navigation and mapping of fields.
  5. Soil Moisture Sensor: Measures soil moisture levels to help in irrigation management.
  6. Ultrasonic Sensor: Detects obstacles in the car’s path to prevent collisions.
  7. Servo Motor: Used for steering or to control mechanisms for tasks like planting seeds.
  8. Power Supply: Provides necessary power to all components.
  9. Breadboard and Connecting Wires: For prototyping and connecting components.

Applications:

The Agritech Car can be employed in various agricultural scenarios, such as:

  • Field Mapping: Using GPS to create accurate maps of farmland.
  • Soil Monitoring: Measuring soil moisture levels to optimize irrigation schedules.
  • Planting Seeds: Automating the process of planting seeds at precise locations.
  • Obstacle Avoidance: Using ultrasonic sensors to navigate around obstacles in the field.

Examples of Use:

  1. Precision Agriculture: The car can traverse fields, mapping soil moisture levels to provide data for variable rate irrigation, ensuring optimal water use and improving crop yields.
  2. Automated Planting: By programming the car to plant seeds at specific intervals and depths, farmers can achieve uniform seed distribution, enhancing growth conditions and yield.
  3. Weed Detection and Removal: Equipped with additional sensors and actuators, the car can identify and mechanically remove weeds, reducing the need for herbicides.

Description:

The Agritech Car operates by processing data from its various sensors using the Arduino Uno. The soil moisture sensor provides real-time feedback on soil conditions, which can be used to activate irrigation systems only when necessary, thus conserving water. The GPS module ensures the car can navigate accurately across the fields, while the ultrasonic sensor prevents collisions by detecting and avoiding obstacles. The servo motor can be used to control tools or mechanisms for specific tasks, such as steering or planting seeds. This automated system simplifies and enhances agricultural tasks, leading to more efficient and productive farming practices. Through its multifunctional capabilities, the Agritech Car represents a significant step forward in the application of technology to modern agriculture.

 

// Include Libraries 

#include "Arduino.h" 

#include "DCMDriverL298.h" 

#include "NewPing.h" 

#include "Servo.h" 

#include "SoilMoisture.h" 

  

  

// Pin Definitions 

#define DCMOTORDRIVERL298_PIN_INT1	2 

#define DCMOTORDRIVERL298_PIN_ENB	6 

#define DCMOTORDRIVERL298_PIN_INT2	3 

#define DCMOTORDRIVERL298_PIN_ENA	5 

#define DCMOTORDRIVERL298_PIN_INT3	4 

#define DCMOTORDRIVERL298_PIN_INT4	7 

#define GPS_PIN_TX	11 

#define GPS_PIN_RX	10 

#define HCSR04_PIN_TRIG	9 

#define HCSR04_PIN_ECHO	8 

#define SERVO9G_PIN_SIG	12 

#define SOILMOISTURE_5V_PIN_SIG	A3 

  

  

  

// Global variables and defines 

const int servo9gRestPosition   = 20;  //Starting position 

const int servo9gTargetPosition = 150; //Position when event is detected 

// object initialization 

DCMDriverL298 dcMotorDriverL298(DCMOTORDRIVERL298_PIN_ENA,DCMOTORDRIVERL298_PIN_INT1,DCMOTORDRIVERL298_PIN_INT2,DCMOTORDRIVERL298_PIN_ENB,DCMOTORDRIVERL298_PIN_INT3,DCMOTORDRIVERL298_PIN_INT4); 

NewPing hcsr04(HCSR04_PIN_TRIG,HCSR04_PIN_ECHO); 

Servo servo9g; 

SoilMoisture soilMoisture_5v(SOILMOISTURE_5V_PIN_SIG); 

  

  

// define vars for testing menu 

const int timeout = 10000;       //define timeout of 10 sec 

char menuOption = 0; 

long time0; 

  

// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity. 

void setup()  

{ 

    // Setup Serial which is useful for debugging 

    // Use the Serial Monitor to view printed messages 

    Serial.begin(9600); 

    while (!Serial) ; // wait for serial port to connect. Needed for native USB 

    Serial.println("start"); 

     

    servo9g.attach(SERVO9G_PIN_SIG); 

    servo9g.write(servo9gRestPosition); 

    delay(100); 

    servo9g.detach(); 

    menuOption = menu(); 

     

} 

  

// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop. 

void loop()  

{ 

     

     

    if(menuOption == '1') { 

    // L298N Motor Driver with Dual Micro DC Motors (Geared) - Test Code 

    //Start both motors. note that rotation direction is determined by the motors connection to the driver. 

    //You can change the speed by setting a value between 0-255, and set the direction by changing between 1 and 0. 

    dcMotorDriverL298.setMotorA(200,1); 

    dcMotorDriverL298.setMotorB(200,0); 

    delay(2000); 

    //Stop both motors 

    dcMotorDriverL298.stopMotors(); 

    delay(2000); 

  

    } 

    else if(menuOption == '2') 

    { 

    // Disclaimer: The Ublox NEO-6M GPS Module is in testing and/or doesn't have code, therefore it may be buggy. Please be kind and report any bugs you may find. 

    } 

    else if(menuOption == '3') { 

    // Ultrasonic Sensor - HC-SR04 - Test Code 

    // Read distance measurment from UltraSonic sensor            

    int hcsr04Dist = hcsr04.ping_cm(); 

    delay(10); 

    Serial.print(F("Distance: ")); Serial.print(hcsr04Dist); Serial.println(F("[cm]")); 

  

    } 

    else if(menuOption == '4') { 

    // 9G Micro Servo - Test Code 

    // The servo will rotate to target position and back to resting position with an interval of 500 milliseconds (0.5 seconds)  

    servo9g.attach(SERVO9G_PIN_SIG);         // 1. attach the servo to correct pin to control it. 

    servo9g.write(servo9gTargetPosition);  // 2. turns servo to target position. Modify target position by modifying the 'ServoTargetPosition' definition above. 

    delay(500);                              // 3. waits 500 milliseconds (0.5 sec). change the value in the brackets (500) for a longer or shorter delay in milliseconds. 

    servo9g.write(servo9gRestPosition);    // 4. turns servo back to rest position. Modify initial position by modifying the 'ServoRestPosition' definition above. 

    delay(500);                              // 5. waits 500 milliseconds (0.5 sec). change the value in the brackets (500) for a longer or shorter delay in milliseconds. 

    servo9g.detach();                    // 6. release the servo to conserve power. When detached the servo will NOT hold it's position under stress. 

    } 

    else if(menuOption == '5') { 

    // Soil Moisture Sensor - Test Code 

    int soilMoisture_5vVal = soilMoisture_5v.read(); 

    Serial.print(F("Val: ")); Serial.println(soilMoisture_5vVal); 

  

    } 

     

    if (millis() - time0 > timeout) 

    { 

        menuOption = menu(); 

    } 

     

} 

  

  

  

// Menu function for selecting the components to be tested 

// Follow serial monitor for instrcutions 

char menu() 

{ 

  

    Serial.println(F("\nWhich component would you like to test?")); 

    Serial.println(F("(1) L298N Motor Driver with Dual Micro DC Motors (Geared)")); 

    Serial.println(F("(2) Ublox NEO-6M GPS Module")); 

    Serial.println(F("(3) Ultrasonic Sensor - HC-SR04")); 

    Serial.println(F("(4) 9G Micro Servo")); 

    Serial.println(F("(5) Soil Moisture Sensor")); 

    Serial.println(F("(menu) send anything else or press on board reset button\n")); 

    while (!Serial.available()); 

  

    // Read data from serial monitor if received 

    while (Serial.available())  

    { 

        char c = Serial.read(); 

        if (isAlphaNumeric(c))  

        {    

             

            if(c == '1')  

    			Serial.println(F("Now Testing L298N Motor Driver with Dual Micro DC Motors (Geared)")); 

    		else if(c == '2')  

    			Serial.println(F("Now Testing Ublox NEO-6M GPS Module - note that this component doesn't have a test code")); 

    		else if(c == '3')  

    			Serial.println(F("Now Testing Ultrasonic Sensor - HC-SR04")); 

    		else if(c == '4')  

    			Serial.println(F("Now Testing 9G Micro Servo")); 

    		else if(c == '5')  

    			Serial.println(F("Now Testing Soil Moisture Sensor")); 

            else 

            { 

                Serial.println(F("illegal input!")); 

                return 0; 

            } 

            time0 = millis(); 

            return c; 

        } 

    } 

} 

 
Scroll to Top