Things used in this project

Schematics

Connection between Arduino and xbee
This is the connection between Arduino and xbee, same for the Arduino that connect to the computer and the Arduino on drone
Collegamento%20arduino%20xbee bb

Code

Master CodeC/C++
This code is loaded on arduino that is connects to the PC, to control the Arduino on drone
first you need to download library https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
#include <AltSoftSerial.h>

int verifica=0;
AltSoftSerial xBee;
char c;
char h;
char stop='s';
void setup() {
  Serial.begin(115200);
  Serial.println("Master OK");
  Serial.println();
  Serial.println("Digit for:");
  Serial.println("'o' orientation sensor value");
  Serial.println("'a' acceleration sensor value");
  Serial.println("'b' brightness sensor value");
  Serial.println("'g' GPS position");
  Serial.println("'m' microfone noise");
  Serial.println("'p' take a picture");
  xBee.begin(9600);
}
void loop() {

  Serial.flush();

  if (Serial.available()>0) {
    c = Serial.read();
    if(c=='o'||c=='a'||c=='m'||c=='g'||c=='b'||c=='p'){
      //----------Orientament-----------------------------------------
      if(c=='o'){
        Serial.println("Orientament");
        c='1';
        xBee.print(c);
        for(int i=0; i<10;i++){
          delay(20);
          c='o';
          xBee.print(c);

          do{
            h=0;
            h=xBee.read();
            Serial.print(h);
          }
          while(xBee.available()>0);
          delay(100);
          i=i-1;
          if(Serial.available()>0);
          if(stop==Serial.read()){
            Serial.println("Analysis Stopped");
            c='0';
            Serial.println();
            Serial.println("Digit for:");
            Serial.println("'o' orientation sensor value");
            Serial.println("'a' acceleration sensor value");
            Serial.println("'b' brightness sensor value");
            Serial.println("'g' GPS position");
            Serial.println("'m' microfone noise");
            Serial.println("'p' take a picture");
            xBee.print(c);
            i=11;
          }
        }
      }
      //----------Acceleration-----------------------------------------
      if(c=='a'){
        Serial.println("Acceleration");
        c='2';
        xBee.print(c);
        for(int i=0; i<10;i++){
          delay(20);
          c='a';
          xBee.print(c);
          do{
            h=0;
            h=xBee.read();
            Serial.print(h);
          }
          while(xBee.available()>0);
          delay(100);
          i=i-1;
          if(Serial.available()>0);
          if(stop==Serial.read()){
            Serial.println("Analysis Stopped");
            c='0';
            Serial.println();
            Serial.println("Digit for:");
            Serial.println("'o' orientation sensor value");
            Serial.println("'a' acceleration sensor value");
            Serial.println("'b' brightness sensor value");
            Serial.println("'g' GPS position");
            Serial.println("'m' microfone noise");
            Serial.println("'p' take a picture");
            xBee.print(c);
            i=11;
          }
        }
      }
      //----------Brightness----------------------------------------
      if(c=='b'){
        Serial.println("Brightness");
        c='3';
        xBee.print(c);
        for(int i=0; i<10;i++){
          delay(20);
          c='b';
          xBee.print(c);
          do{
            h=0;
            h=xBee.read();
            Serial.print(h);
          }
          while(xBee.available()>0);
          delay(50);
          i=i-1;
          if(Serial.available()>0);
          if(stop==Serial.read()){
            Serial.println("Analysis Stopped");
            c='0';
            Serial.println();
            Serial.println("Digit for:");
            Serial.println("'o' orientation sensor value");
            Serial.println("'a' acceleration sensor value");
            Serial.println("'b' brightness sensor value");
            Serial.println("'g' GPS position");
            Serial.println("'m' microfone noise");
            Serial.println("'p' take a picture");
            xBee.print(c);
            i=11;
          }
        }
      }
      //----------GPS-----------------------------------------
      if(c=='g'){
        Serial.println("Posizione GPS'");
        c='4';
        xBee.print(c);
        for(int i=0; i<10;i++){
          delay(20);
          c='g';
          xBee.print(c);
          do{
            h=0;
            h=xBee.read();
            Serial.print(h);
          }
          while(xBee.available()>0);
          delay(500);
          i=i-1;
          if(Serial.available()>0);
          if(stop==Serial.read()){
            Serial.println("Analysis Stopped");
            c='0';
            Serial.println();
            Serial.println("Digit for:");
            Serial.println("'o' orientation sensor value");
            Serial.println("'a' acceleration sensor value");
            Serial.println("'b' brightness sensor value");
            Serial.println("'g' GPS position");
            Serial.println("'m' microfone noise");
            Serial.println("'p' take a picture");
            xBee.print(c);
            i=11;
          }
        }
      }
      //----------MICROFONO-----------------------------------------
      if(c=='m'){
        Serial.println("Microphone");
        c='5';
        xBee.print(c);
        for(int i=0; i<10;i++){
          delay(20);
          c='m';
          xBee.print(c);
          do{
            h=0;
            h=xBee.read();
            Serial.print(h);
          }
          while(xBee.available()>0);
          delay(100);
          i=i-1;
          if(Serial.available()>0);
          if(stop==Serial.read()){
            Serial.println("Analysis Stopped");
            c='0';
            Serial.println();
            Serial.println("Digit for:");
            Serial.println("'o' orientation sensor value");
            Serial.println("'a' acceleration sensor value");
            Serial.println("'b' brightness sensor value");
            Serial.println("'g' GPS position");
            Serial.println("'m' microfone noise");
            Serial.println("'p' take a picture");
            xBee.print(c);
            i=11;
          }
        }
      }

      //----------PICTURES-----------------------------------------
      if(c=='p'){
        Serial.println("Take a pictures");
        c='6';
        xBee.print(c);
        delay(20);
        c='p';
        Serial.println();
        Serial.println("Digit for:");
        Serial.println("'o' orientation sensor value");
        Serial.println("'a' acceleration sensor value");
        Serial.println("'b' brightness sensor value");
        Serial.println("'g' GPS position");
        Serial.println("'m' microfone noise");
        Serial.println("'p' take a picture");
        xBee.print(c);      
      }

    }
  }
}
Slave C/C++
This code is loaded sull'arduino that mounts on the drone, which will provide the data to the drone to the ground
first you need to download library https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
and http://1sheeld.com/downloads/
#include <OneSheeld.h>
#include<AltSoftSerial.h>

char             variabile;
AltSoftSerial    xBee;
char             master;
int              voce=0;
void setup(){
  Serial.begin(115200);
  Serial.println("Slave ok");
  OneSheeld.begin();
  xBee.begin(9600);
}

void loop(){
  receiveEvent();
  requestEvent();
}


void receiveEvent(){
  while(xBee.available()>0){
    master=xBee.read();
    variabile=master;
  }
}


void requestEvent(){

  if(variabile=='o'){
    xBee.print("Asse x: ");                         
    xBee.print(OrientationSensor.getX());             
    xBee.print(" Asse y: ");                           
    xBee.print(OrientationSensor.getY());             
    xBee.print(" Asse z: ");                           
    xBee.println(OrientationSensor.getZ());
    variabile=0;
  }
  if(variabile=='a'){
    xBee.print("Asse x: ");
    xBee.print(AccelerometerSensor.getX());    
    xBee.print(" Asse y: ");
    xBee.print(AccelerometerSensor.getX());
    xBee.print(" Asse z: ");
    xBee.println(AccelerometerSensor.getX());
    variabile=0;
  }
  if(variabile=='g'){
    xBee.print("Longitudine: ");
    xBee.print(GPS.getLongitude());    
    xBee.print(" Latitudine;: ");
    xBee.println(GPS.getLatitude());
    variabile=0;
  }
  if(variabile=='m'){
    xBee.print("db: ");
    xBee.println(Mic.getValue());
    variabile=0;
  }
  if(variabile=='b'){
    xBee.print("Lumen:  ");
    xBee.println(LightSensor.getValue());  
    variabile=0;
  }
  if(variabile=='p'){
    Camera.setFlash(ON);  
    Camera.rearCapture();
    xBee.println("Pictures taken");
    variabile=0;
  }
  if(variabile=='1'){
    TextToSpeech.say("analysis orientation");
    variabile=0;
  }
  if(variabile=='2'){
    TextToSpeech.say("analysis acceleration ");
    variabile=0;
  }
  if(variabile=='3'){
    TextToSpeech.say("analysis  brightness intensity");
    variabile=0;
  }
  if(variabile=='4'){
    TextToSpeech.say("analysis GPS position");
    variabile=0;
  }
  if(variabile=='5'){
    TextToSpeech.say("analysis decibel noise");
    variabile=0;
  }
  if(variabile=='6'){
    TextToSpeech.say("Taking a picture");
    variabile=0;
  }
  if(variabile=='0'){
    TextToSpeech.say("analysis stopped");
    variabile=0;
  }
}

Credits

Img 8770
Andrea Bertorelli

student high school, telecommunication.

Replications

Did you replicate this project? Share it!

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Voice Controled Click Lamps
Intermediate
  • 33
  • 2

Work in progress

We have a couple of floor lamps from Ikea. They have two lights in each, and a switch for each light. Let's control them remotely.

Smart Garden
Intermediate
  • 1,839
  • 17

Smart Garden is a plant environmental monitoring system.

Both Physical & Cloud Cayenne Lights Switch
Intermediate
  • 108
  • 2

The cloud switches are well known, but what happens when the local internet fails and the switch cannot connect to the internet?

IoT Thermometer Using Python
Intermediate
  • 700
  • 8

Full instructions

How to develop a simple, but powerful, IoT thermometer using a Zerynth-powered single-board MCU and the Zerynth App.

WiDC: Wi-Fi-Controlled FPV Robot
Intermediate
  • 5,897
  • 39

Full instructions

What about using a Wi-Fi remote-controlled robot for exploring your surroundings, reaching inaccessible places, spying and take pictures?

Sienci Mill One - Simple and Affordable Desktop CNC
Intermediate
  • 8,568
  • 37

Full instructions

The Sienci Mill One is a powerful, open source desktop CNC machine to turn your digital 3D designs into real physical objects.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Feedback