gowthamkishoreindukuri
Published © MIT

Earth_Analyzer

GUYS TELL YOUR SUPPORT TO ME.This project one of way of smart farming which can be used for analysis of soil.

AdvancedFull instructions provided6 hours7,185
Earth_Analyzer

Things used in this project

Story

Read more

Schematics

THE NRF

Code

FINAL RECEIVER

Arduino
#include <SPI.h>
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#include <Servo.h>
Servo servo;

RF24 radio(7, 8); // CSN, CE
const byte address[6] = "00001";
int servo_pin = 9;
int sensor_pin=A0;
int output_value;

void setup() {
  Serial.begin(9600);
  radio.begin();
  servo.attach (servo_pin ) ;
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.setChannel(87);
  radio.setDataRate(RF24_250KBPS);
  radio.startListening();
}
int pos;
void loop() {
  if (radio.available()) {
    radio.read(&pos, sizeof(pos));
    Serial.println(pos);
    if(pos==100)
    {
    digitalWrite(6,LOW);
    digitalWrite(5,LOW);
    digitalWrite(4,LOW);
    digitalWrite(3,LOW);
  //   Serial.println("gk0");
    }
    else if (pos==200){
    digitalWrite(6,HIGH);
    digitalWrite(5,LOW);
    digitalWrite(4,HIGH);
    digitalWrite(3,LOW);
    delay(10);
    // Serial.println("gk1");
    }
     else if (pos==300){
    digitalWrite(6,LOW);
    digitalWrite(5,HIGH );
    digitalWrite(4,LOW);
    digitalWrite(3,HIGH);
     delay(10);
   // Serial.println("gk2");
    }
    else if (pos==400){
    digitalWrite(6,LOW);
    digitalWrite(5,HIGH );
    digitalWrite(4,HIGH);
    digitalWrite(3,LOW);
    delay(10);
   //  Serial.println("gk3");
    }
     else if (pos== 500){
    digitalWrite(6,HIGH);
    digitalWrite(5,LOW );
    digitalWrite(4,LOW);
    digitalWrite(3,HIGH);
     delay(10);
    //  Serial.println("gk5");
    }
    else if (pos== 600){
     servo.write(90);
     delay(10);    
    //  Serial.println("gk6");
    }
     else if (pos== 700){
     servo.write(180);
     delay(10);
    //  Serial.println("gk7");
    }
  }
  else
  {
    Serial.println("connection lost");  
  }
 
}

FINAL TRANSMITER

Arduino
#include <SPI.h>
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>

RF24 radio(7, 8); // CSN, CE
const byte address[6] = "00001";

int x_key = A1;                                              
int y_key = A0;                                              
int p_key = A3;                                              
int q_key = A2;                                              
int x_pos;
int y_pos;
int p_pos;
int q_pos;

void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.setChannel(87);
  radio.setDataRate(RF24_250KBPS);
  radio.stopListening();
 
  Serial.begin(9600);
  pinMode (x_key, INPUT) ;                    
  pinMode (y_key, INPUT) ;
  pinMode (p_key, INPUT) ;                    
  pinMode (q_key, INPUT) ;        
}
int pos;
void loop() {
  x_pos = analogRead (x_key) ;  
  y_pos = analogRead (y_key) ;  
  p_pos = analogRead (p_key) ;  
  q_pos = analogRead (q_key) ;  
  Serial.println(x_pos);
  Serial.println(y_pos);
  Serial.println(p_pos);
  Serial.println(q_pos);
  if (p_pos>400 && p_pos<600 && q_pos>400 && q_pos<600)
  {
  if(x_pos>400 && x_pos<600 && y_pos>400 && y_pos<600)
  {
    pos=100;
    radio.write(&pos, sizeof(pos));
  }
  if(x_pos>400 && x_pos<600 && y_pos<400)
  {
    pos=200;
    radio.write(&pos, sizeof(pos));
  }
  if(x_pos>400 && x_pos<600 && y_pos>600)
  {
    pos=300;
    radio.write(&pos, sizeof(pos));
  }
  if(y_pos>400 && y_pos<600 && x_pos<400)
  {
    pos=400;
    radio.write(&pos, sizeof(pos));
  }
  if(y_pos>400 && y_pos<600 && x_pos>600)
  {
    pos=500;
    radio.write(&pos, sizeof(pos));
  }
  Serial.println(pos);
  delay(100);
}
else if(p_pos<400 || p_pos>600)
{
  if(p_pos<400)
  {
    pos=600;
    radio.write(&pos, sizeof(pos));
  }
  if(p_pos>600)
  {
    pos=700;
    radio.write(&pos, sizeof(pos));
  }
  delay(100);
}
}

Credits

gowthamkishoreindukuri

gowthamkishoreindukuri

16 projects • 10 followers

Comments