Arduino Drone : MEGA2560 Aititude Hold + GPS Hold EP1

 

 

https://en.wikipedia.org/wiki/Quadcopter#Applications

Flight dynamics

Each rotor produces both a thrust and torque about its center of rotation, as well as a drag force opposite to the vehicle’s direction of flight. If all rotors are spinning at the same angular velocity, with rotors one and three rotating clockwise and rotors two and four counterclockwise, the net aerodynamic torque, and hence the angular acceleration about the yaw axis, is exactly zero, which means there is no need for a tail rotor as on conventional helicopters. Yaw is induced by mismatching the balance in aerodynamic torques (i.e., by offsetting the cumulative thrust commands between the counter-rotating blade pairs).[82][83]

 

 

Equipment

Arduino Mega 2560

MPU6050 Gyro

GY-63 (MS5611) Baro

Remote Flysky FS i6X

GPS/Compass

Motor 1000KV + Propeller . x 4

 

Arduino Mega 2560

Geekcreit® MEGA 2560 R3 ATmega2560 MEGA2560 Development Board With USB Cable For Arduino

 

https://www.banggood.com/custlink/3vvKIRyDGN

Arduino Mega 2560 manual : https://drive.google.com/file/d/13i09MBBWXAa5Uu954PXWiCqSSYdmQ2QQ/view?usp=sharing

 

MPU 6050

6DOF MPU-6050 3 Axis Gyro With Accelerometer Sensor Module For Arduino

https://www.banggood.com/custlink/3mvK5s3Gz8

https://drive.google.com/file/d/1BYW_bjD6cxUSvv3vItt9JMjjXNmjxblO/view?usp=sharing

 

GPS

APM2.6 2.8 GPS Module High Precision GPS With Electronic Compass PIXHAWK

https://www.banggood.com/custlink/vKv38YdDd9

 

MS5611 GY-63 Atmospheric Pressure Sensor Module IIC/SPI Communication

https://www.banggood.com/custlink/DK33iYR3y0

Baro meter :  https://drive.google.com/file/d/1e7zeBpGc95ciLv3jVrbm9lfs_Dmjgq2T/view?usp=sharing

FlySky FS-i6 2.4G 6CH AFHDS RC Radion Transmitter With FS-iA6B Receiver for RC FPV Drone

https://www.banggood.com/custlink/mGGKiEYKrz

https://drive.google.com/file/d/1pOiHj9m0HxIeDRs6IpjiTVY0ntMojYiw/view?usp=sharing

 

XXD 2212 Motor+ZTW Beatles AL30A Brushless ESC+Propellers Set

https://www.banggood.com/custlink/mK3G5ChiQz

 

………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………….

Wiring

 

 

Code : https://github.com/QuadTinnakon/QuadX_2560GY86_PIDAuto_V5

Next step is :

Print out value for adjust

Select baud rate 57600

Map column left to right with serial print

 

Adjust remote

Min :1050  Max : 1950 all channel.

 

Calibrate sensor.

Magneto

Turn Quad copter by hand find Magneto value

Xmin Xmax

Ymin,Ymax

Zmin,Zmax  lay down quad   +/- 90

 

Adjust in Config.h

 

 

Altitude using BMP180

This project make Altitude measuring using BMP180 pressure sensor convert pressure to be altitude.

GY-68 Module

GY-68 BMP180 Digital Barometric Pressure Sensor Board Module for for RC Drone FPV Racing Multi Rotor

Wiring

 

Hardware connections:

– (GND) to GND
+ (VDD) to 3.3V

(WARNING: do not connect + to 5V or the sensor will be damaged!)

You will also need to connect the I2C pins (SCL and SDA) to your
Arduino. The pins are different on different Arduinos:

Any Arduino pins labeled: SDA SCL
Uno, Redboard, Pro: A4 A5
Mega2560, Due: 20 21
Leonardo: 2 3

 

Code

 

Load SFE BMP180 Library  link  :  https://drive.google.com/file/d/1QoBl_1UGxN0x1gEmGAnUGPopdML4bjRN/view?usp=sharing

/* SFE_BMP180 altitude example sketch

This sketch shows how to use the Bosch BMP180 pressure sensor
as an altimiter.
https://www.sparkfun.com/products/11824

Like most pressure sensors, the BMP180 measures absolute pressure.
Since absolute pressure varies with altitude, you can use the pressure
to determine your altitude.

Because pressure also varies with weather, you must first take a pressure
reading at a known baseline altitude. Then you can measure variations
from that pressure





Hardware connections:

- (GND) to GND
+ (VDD) to 3.3V

(WARNING: do not connect + to 5V or the sensor will be damaged!)

You will also need to connect the I2C pins (SCL and SDA) to your
Arduino. The pins are different on different Arduinos:

Any Arduino pins labeled: SDA SCL
Uno, Redboard, Pro: A4 A5
Mega2560, Due: 20 21
Leonardo: 2 3

Leave the IO (VDDIO) pin unconnected. This pin is for connecting
the BMP180 to systems with lower logic levels such as 1.8V

Have fun! -Your friends at SparkFun.

The SFE_BMP180 library uses floating-point equations developed by the
Weather Station Data Logger project: http://wmrx00.sourceforge.net/

Our example code uses the "beerware" license. You can do anything
you like with this code. No really, anything. If you find it useful,
buy me a beer someday.

V10 Mike Grusin, SparkFun Electronics 10/24/2013
V1.1.2 Updates for Arduino 1.6.4 5/2015
*/

// Your sketch must #include this library, and the Wire library.
// (Wire is a standard library included with Arduino.):

#include <SFE_BMP180.h>
#include <Wire.h>

// You will need to create an SFE_BMP180 object, here called "pressure":

SFE_BMP180 pressure;

double baseline; // baseline pressure

void setup()
{
Serial.begin(9600);
Serial.println("REBOOT");

// Initialize the sensor (it is important to get calibration values stored on the device).

if (pressure.begin())
Serial.println("BMP180 init success");
else
{
// Oops, something went wrong, this is usually a connection problem,
// see the comments at the top of this sketch for the proper connections.

Serial.println("BMP180 init fail (disconnected?)\n\n");
while(1); // Pause forever.
}

// Get the baseline pressure:

baseline = getPressure();

Serial.print("baseline pressure: ");
Serial.print(baseline);
Serial.println(" mb");
}

void loop()
{
double a,P;

// Get a new pressure reading:

P = getPressure();

// Show the relative altitude difference between
// the new reading and the baseline reading:

a = pressure.altitude(P,baseline);

Serial.print("relative altitude: ");
if (a >= 0.0) Serial.print(" "); // add a space for positive numbers
Serial.print(a,1);
Serial.print(" meters, ");
if (a >= 0.0) Serial.print(" "); // add a space for positive numbers
Serial.print(a*3.28084,0);
Serial.println(" feet");

delay(500);
}

double getPressure()
{
char status;
double T,P,p0,a;

// You must first get a temperature measurement to perform a pressure reading.

// Start a temperature measurement:
// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.

status = pressure.startTemperature();
if (status != 0)
{
// Wait for the measurement to complete:

delay(status);

// Retrieve the completed temperature measurement:
// Note that the measurement is stored in the variable T.
// Use '&T' to provide the address of T to the function.
// Function returns 1 if successful, 0 if failure.

status = pressure.getTemperature(T);
if (status != 0)
{
// Start a pressure measurement:
// The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait).
// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.

status = pressure.startPressure(3);
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);

// Retrieve the completed pressure measurement:
// Note that the measurement is stored in the variable P.
// Use '&P' to provide the address of P.
// Note also that the function requires the previous temperature measurement (T).
// (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.)
// Function returns 1 if successful, 0 if failure.

status = pressure.getPressure(P,T);
if (status != 0)
{
return(P);
}
else Serial.println("error retrieving pressure measurement\n");
}
else Serial.println("error starting pressure measurement\n");
}
else Serial.println("error retrieving temperature measurement\n");
}
else Serial.println("error starting temperature measurement\n");
}