Introduction: ArDrone 2.0 Quadcopter Control Unit on MPU6050 and ESP8266 Module

About: Developer and teacher.

The size, price and availability of Wi-Fi allow you to make a budget control unit for the ArDrone 2.0 quadrocopter on the ESP8266 module (prices on AliExpress, Gearbest). For control, we will use the Gy-521 Module on the MPU6050 chip (gyroscope, accelerometer).

The Parrot AR. Drone is a radio-controlled quadrocopter, that is, a helicopter with four main rotors placed on remote diagonal beams. The AR. Drone itself runs on the Linux operating system, and almost any Android or iOS touch-screen smartphone or tablet can act as a remote control for the quadcopter. The distance of stable control over Wi-Fi is from 25 to 100 meters and depends on the room and weather conditions, if flights take place on the street.

Step 1: Connecting the ESP8266 to the Ar Drone 2.0 Access Point

When enabled, AR. Drone creates an SSIS access point "ardrone_XX_XX". Connecting without a password.

Let's try connecting to the Ar.Dron access point using AT commands Connect the ESP8266 card to the computer's com port via the UART --> USB adapter power supply 3.3 V.

Open the Arduino IDE, the serial port monitor, and send AT commands to the ESP Board (the quadcopter must be enabled)

Step 2: Communication With AR. Drone Is Performed Using AT Commands.

Commands are sent to AR. Drone as UDP or TCP packets;

A single UDP packet must contain at least one complete command or more; If the package contains more than one command, the character 0x0A is used to separate the commands.

Strings are encoded as 8-bit ASCII characters;

The maximum command length is 1024 characters;

There is a 30 MS delay between commands.

The command consists of

AT * [command name] = [command sequence number as a string] [, argument 1, argument 2 ...]

List of main AT commands for controlling AR. Drone:

AT * REF-used for takeoff, landing, reset, and emergency stop;

AT*PCMD-this command is used to control AR. Drone movement;

AT*FTRIM — on the horizontal plane;

AT*CONFIG-configuring AR. Drone parameters;

AT*LED-sets LED animations on AR. Drone;

AT*ANIM-installing flight animation on AR. Drone.

AT * COMWDG-watchdog reset command-we send it constantly to the quadcopter.

The following ports are used for communication:

Port 5556-UDP-sending commands to AR. Drone;

Port 5554-UDP-receiving data packets from AR. Drone;

Port 5555-Reply stream video packets from AR. Drone;

Port 5559-TCP packets for critical data that cannot be lost, usually for configuration.

The client disconnects from the UDP port after a delay of 2 seconds after sending the last command!!! — therefore, you must constantly send commands, if necessary-AT*COMWDG.

Consider getting navigation data from ARDrone (Port 5554-UDP). The navigation data packet in demo mode is 500 bytes long. If something goes wrong, the drone can send a 32-and 24-byte packet. If the packet is 24 bytes long this means that port 5554 is in BOOTSTRAP mode and you need to reconnect to the port to switch it to Demo mode ARDrone can transmit navigation data to the client in two forms:

abbreviated (or demo), 500 bytes in size. complete.

To get demo data, first send four bytes 0x01, 0x00, 0x00, 0x00 to port 5554, and then send a command to port 5556

AT*CONFIG="+(seq++)+", \"general:navdata_demo\",\ " TRUE\" where seq is the sequential number of the command.

Structure of the navigation data package. There are 4 named values at the beginning of the package:

32-bit packet header: helicopter status flags 32 bits;

the sequence number of the last command sent to the helicopter by the client 32 bits;

vision flag 32 bits. Next-the navdata option Header: 20-23.

The navdata option has the following fields:

BATTERY = 24; battery charge as a percentage;

PITCH = 28; angle of inclination along the longitudinal axis;

ROLL = 32; angle of inclination relative to the transverse axis;

YAW = 36; angle of rotation relative to the vertical axis;

ALTITUDE = 40; height;

VX = 44; x-axis speed;

VY = 48; y-axis speed;

VZ = 52; speed on the z axis.

Step 3: Connecting the Nokia 5110 Display to the ESP8266 Board

Connect the Nokia 5110 display to the ESP8266 module and output some navigation data to it and to the serial port monitor

Step 4: Getting Navigation Data and Displaying It on the Nokia5110 Display

Download (sketch ardrone_esp8266_01. ino), and observe the output of navigation data to the serial port and the display screen.

Step 5: Sending Takeoff and Landing Commands

Now we will add to our project the takeoff and landing of the quadcopter with commands from the remote control. To take off, you need to send a command

AT*REF=[Sequence number ], 290718208

For landing

AT*REF=[Sequence number ], 290717696

Before takeoff, you must send a command for horizontal calibration, otherwise the Ar Drone will not be able to stabilize during flight.

AT * F TRIM=[Sequence number ]

Upload the sketch ardrone_esp8266_02.ino () to the ESP8266 Board, turn on the Ar Drone 2.0 quadcopter and check the button operation. When you click-takeoff, the next time you click – landing, etc.

Step 6: Connecting MPU6050 to Control the Ardrone 2.0

Sensors for determining the position in space are used for controlling quadrocopters. The MPU6050 chip contains both an accelerometer and a gyroscope on Board, as well as a temperature sensor. the MPU6050 is the main element of the Gy-531 module (Fig. 15.44). In addition to this chip, the module Board contains the necessary MPU6050 binding, including pull-up resistors of the I2C interface, as well as a 3.3-volt voltage stabilizer with a small voltage drop (when powered at 3.3 volts, the output of the stabilizer will be 3 exactly volts) with filter capacitors.

Connecting to the microcontroller using the I2C Protocol.

Step 7: Controlling the Quadcopter Using MPU6050

Using the accelerometer and gyroscope allows you to determine the deviation on the x and y axes, and the deviation "turn" into commands for moving the quadcopter along the corresponding axes. Translation of the readings received from the sensor to the deflection angle.

the Command to send to the Ar Drone for flight control

AT*REF=[Sequence number ], [Flag bit-field], [Roll],[Pitch], [Gaz],[Yaw]

The values of Roll and Pitch in the range -1 to 1 are taken from the table const int float [], the index corresponds to the angle of deviation calculated from the mu6050 sensor data.

Upload the sketch ardrone_esp8266_03.ino it to the ESP8266 Board, turn on the ar Drone 2.0 quadrocopter and check the operation of the remote.

Make It Fly Speed Challenge

Participated in the
Make It Fly Speed Challenge