Arduino MEGA 2560 Multiwii Drone :Bluetooth Telemetry

HC-05 โมดูลบลูทู ธ ไร้สายแบบอนุกรมรับส่งสัญญาณทาสและปริญญาโท

https://sea.banggood.com/custlink/mD33qYPZPb

FT232RL FTDI USB เป็น TTL โมดูลอะแดปเตอร์แปลงอนุกรม Geekcreit สำหรับ Arduino - ผลิตภัณฑ์ที่ทำงานร่วมกับบอร์ด Arduino อย่

https://sea.banggood.com/custlink/3K3v2h59Hw

 

Connect

FTDI                   Bluetooth

RX     >>>>        TX

TX     >>>>         RX

Open IDE Sketch the

Tool >  port > Com? (Select com port)

Type

AT enter for test OK mean good communication

 

 

 

 

 

 

 

Change Bluetooth Baud rate

Type

AT+BAUD8(change baud rate 115200)

 

Connect Bluetooth  to Mega2560

VDO

Arduino MEGA 2560 Multiwii Drone :Test GPS

Test VDO

All component

  1. Gyroscope + Accelerometer  (MPU6050)

https://sea.banggood.com/custlink/m3Gm23fm02

  • UBlox GPS + Magnetometer (HMC5883)
  • Magnetometer (HMC5883)

https://sea.banggood.com/custlink/GDKKkmuGgC

G-Model GPS/Compass

Compass

Orange =  SCL

White = SDA

 

GPS

Green = TX

Yellow = RX

 

https://sea.banggood.com/custlink/GmvKU31KSq

 

Code program

https://code.google.com/p/multiwii/

 

How to configuration

 

 

 

 

 

 

 

 

 

 

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

 

 

NANO DRONE EP1 : Hook up Flysky to Arduino NANO

 

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

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

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

Wiring

Bind Remote ( Connect Transmitter and receiver )

 

 

Code for read data from Flysky receiver
int channel1 = 2; //   Pitch
int channel2 = 3;//    
int channel3 = 4; //  Throttle
int channel4 = 5;//    YAW
int SWA = 6;// SWA

int Channel1 = 0 ; // Used later to 
int Channel2 = 0 ; // store values
int Channel3 = 0 ; // Used later to 
int Channel4 = 0 ; // store values
int SWAstate = 0 ; // store values


void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
   pinMode (channel1, INPUT);// initialises the channels
   pinMode (channel2, INPUT);// as inputs
   pinMode (channel3, INPUT);// initialises the channels
   pinMode (channel4, INPUT);// as inputs
   pinMode (SWA,INPUT);// Switch A 


}

void loop() {
  // put your main code here, to run repeatedly:

   
  Channel1 = (pulseIn (channel1, HIGH)); // Checks the value of channel1
  Serial.print ("Channel1 :");
  Serial.println (Channel1); //Prints the channels value on the serial monitor

Channel2 = (pulseIn (channel2, HIGH)); // Checks the value of channel1
  Serial.print ("Channel2 :");
  Serial.println (Channel2); //Prints the channels value value on the serial monitor

Channel3 = (pulseIn (channel3, HIGH)); // Checks the value of channel1
    Serial.print ("Channel3 :");
  Serial.println (Channel3); //Prints the channels value value on the serial monitor

Channel4 = (pulseIn (channel4, HIGH)); // Checks the value of channel1
    Serial.print ("Channel4 :");
  Serial.println (Channel4); //Prints the channels value value on the serial monitor
int SWAState = (pulseIn (SWA,HIGH)); // Checks the value of channel1
    Serial.print ("SWAState :   ");
  Serial.println (SWAState); //Prints the channels value value on the serial monitor

delay(2000);
}

Quad copter Arduino NANO : Test and Calibration ESC

https://en.wikipedia.org/wiki/Aircraft_principal_axes

 

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

 

Remote control FlySky   FS-I6C  TX , FS-IA6B RX

 

500px-FlySky_IA6B_pinout-f89eed4f

https://www.dronetrest.com/t/connecting-a-matek-f405-ctr-to-fs-ia6b-receiver/7081

Flysky FS-I6 TX   remote control manual

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

 

reference

http://www.electronoobs.com/eng_robotica_tut5_3.php

 

 

Test ESC and MOTOR and Direction

 

 

 

/*
        Arduino Brushless Motor Control
     by Dejan, https://howtomechatronics.com

and Modify by A-Arduino  :    www.a-arduino.com

*/
#include <Servo.h>
Servo ESC1;     // create servo object to control the 4 ESC
Servo ESC2;
Servo ESC3;
Servo ESC4;
int potValue;  // value from the analog pin
void setup() {
  // Attach the ESC on pin 9
  ESC1.attach(A1,1000,2000); // (pin A1, min pulse width, max pulse width in microseconds) 
  ESC2.attach(A2,1000,2000); // (pin A2, min pulse width, max pulse width in microseconds) 
  ESC3.attach(A3,1000,2000); // (pin A3, min pulse width, max pulse width in microseconds) 
  ESC4.attach(A4,1000,2000); // (pin A4, min pulse width, max pulse width in microseconds) 
}
void loop() {
  potValue = analogRead(A0);   // reads the value of the potentiometer (value between 0 and 1023)
  potValue = map(potValue, 0, 1023, 0, 180);   // scale it to use it with the servo library (value between 0 and 180)
  ESC1.write(potValue);    // Send the signal to the ESC
  ESC2.write(potValue);    // Send the signal to the ESC
  ESC3.write(potValue);    // Send the signal to the ESC
  ESC4.write(potValue);    // Send the signal to the ESC
}

 

How to connect I2C 2 device +BMP180 show Altitude on SSD1306 OLED dispaly

Need add 2 library

OLED display : 

 https://drive.google.com/open?id=1rUimqKF_9CBCUilNDYi2cbV2ajJBQ3Zv

BMP180 :

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

Add library

Select zip file from download then check result you will see in example file.

or Sketch > include

 

OLED I2C address : 0x3C

BMP180 (GY-68) I2C address :  0x77

VDO

code

 

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

//Oled

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

// 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");

display.begin(SSD1306_SWITCHCAPVCC, 0x3c); //initialize I2C addr 0x3c
display.clearDisplay(); // clears the screen and buffer

// 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);

display.clearDisplay(); // clears the screen and buffer

Serial.print("relative altitude: ");
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("relative alt");
if (a >= 0.0) Serial.print(" "); // add a space for positive numbers
Serial.print(a,1);

display.setTextSize(2);
display.println(a,1);
display.setTextColor(BLACK, WHITE);
Serial.print(" meters, ");

display.setTextSize(1);
display.println("meters");
display.setTextColor(BLACK, WHITE);
display.display();
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");
}