The Guide I Wished I Had on Building an Arduino Drone

This is document is a sort of “How to guide” slash documentation that goes through process it took me to understand the concepts to achieve my goal of building a simple quadcopter that I could control from my mobile phone.

To do this project I wanted to get an idea of what a drone actually is, in my case a quadcopter, so I started doing some research. I watched a lot of YouTube videos, read a bunch of articles and Insructible pages and this is what I got.

Essentially you can split a drone into two parts. I called it the “Physical” and the “Controller”. The Physical is essentially everything that has to do with the mechanics that makes the drone fly. These are things like the motor, the frame, the battery, propellers and every other thing that physically gives the drone the ability to fly.

The Controller is essentially the flight controller. What controls the physical so that the drone can fly as a whole unit without falling. Essentially the microcontroller, the software on it and the sensors that help it triangulate it's bearings. So in all to have a drone, I needed a Controller, and a bunch of physical parts for the controller to ‘control’.

Supplies:

Budget for project: $250

Time Frame: 2 weeks

Things to Buy:

  • Physical Frame $20
  • Blades $0 (Comes with frame)
  • Battery Pack $25
  • ESC (Electronic speed controllers) $0 (Comes with motors)
  • Motors $70


Flight Controller

  • Arduino nano $20
  • Arduino USB Cable $2
  • Bluetooth Module (HC-05) $8
  • 3mm LED and 330 Ohm resistors and wires $13
  • GY-87 (Accelerometer, Gyroscope) $5
  • Prototype Board $10
  • Male and Female headers $5

Other

  • Soldering kit $10
  • Multimeter $20

I wanted to enjoy building this project as an Engineer, so I bought some other stuff that I didn't have to.

Total: $208

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: My Initial Experience

After buying all my components, I put it all together and then tried to launch the drone, using Multiwii (the go to software that a lot of the DIY drone community use), however I quickly realized that I did't full understand what I was doing because there were a lot of errors and I had no idea how to fix them.

After that I decided to take the drone apart and understand each component piece by piece and rebuild it in a way that I would completely understand everything that was going on.

In the following sections I will go through the process of piecing the puzzle together. Before that let's get a quick overview.

Physical

For the physical, we should have: the frame, the propellers, the battery and the escs. These would be fairly easy to piece together. To understand these parts and which ones you should get you can visit this link. He explains what you need to know about buying each of the parts that I have listed. Also watch this Youtube video. It will help you if you are stuck piecing the parts together.

Step 2: Tips on Piecing and Debugging the Physical Parts

Propellers and Motors

  • To check if your propellers are in the right orientation(Flipped or not), when you spin them in the direction indicated by the motors(most motors have arrows showing how they should spin), you should feel a breeze under the propellers and not above.
  • The screws on opposite propellers should be the same color.
  • The color of adjacent propellers should be the same.
  • Also make sure that you have arranged the motors in a way that they spin just like in the image above.
  • If you are trying to flip the direction of a motor just swap wires at opposite ends. This will reverse the direction of the motor.

Battery and Power

  • If for any reason things are sparking and you can't figure out why, it's most likely because you have positive and negatives swapped.
  • If you are not sure when to charge your batteries, you can use a voltmeter to check the voltage. If it's lower than the specs on the battery say, then it needs to be charged. Check out this link on charging your batteries.
  • Most LIPO batteries don't come with battery chargers. You buy them separately.

Step 3: The Arduino Controller

This is no doubt the most difficult part of this whole project. It's very easy to blow up components and debugging could be extremely frustrating if you don't know what you are doing. Also in this project I controlled my drone using bluetooth and an app that I will show you how to build. This made the project particularly more difficult because 99% of the tutorials out there use radio controllers(this is not a fact lol), but don't worry I've gone through the frustration for you.

Tips before you embark on this journey

  • Use a breadboard before you finalize your device on a PCB. This lets you make changes easily.
  • If you've tested a component extensively and it's not working, it's probably not working!
  • Look at the voltages a device can handle before you plug it in!
    • Arduino can handle 6 to 20V, but try to cap it at 12V so you don't blow it up. You can read more about it's specs here.
    • The HC-05 can handle up to 5V but some pins work at 3.3V so watch out for that. We'll talk about it later.
    • The IMU(GY-521, MPU-6050) also works at 5V.
  • We will be using RemoteXY to build our app. If you want to build it on an iOS device you need to use a different bluetooth module(The HM-10). You can learn more about this on the RemoteXY website.

Hopefully you've read the tips. Now let's test each component that will be part of the controller separately.

Step 4: The MPU-6050

This device has a gyroscope and an accelerometer, so essentially it tells you the acceleration in a direction(X, Y, Z) and the angular acceleration along those directions.

To test this, we can use the tutorial on this we can use this tutorial on the Arduino website. If it works, you should get a stream of accelerometer and gyroscope values that change as you tilt, rotate and accelerate the setup. Also, try to tweak and manipulate the code so that you know what's going on.

Step 5: The HC-05 Bluetooth Module

You don't have to do this part but it's important to be able to go to AT mode(settings mode) as you will most likely have to change one of the settings of the module. This was one of the most frustrating parts about this project. I did so much research to figure out how to get my module into AT mode, because my device was not responding to my commands. It took me 2 days to conclude that my module was broken. I ordered for another one and it worked. Check out this tutorial on getting into AT mode.

The HC-05 comes in different kinds, there are some with buttons and some without and all sorts of design variables. One this that is constant though is that they all have a "Pin 34". Check out this tutorial.

Things you should know

  • To go into AT mode, just hold 5V to pin 34 of the bluetooth module before you connect power to it.
  • Connect a potential divider to the RX pin of the module as it works on 3.3V. You could still use it at 5V but it might fry that pin if something goes wrong.
  • If you use Pin 34 (instead of the button or some other way you found online), the module will set the bluetooth's baud rate to 38400. That's why in the link for the tutorial above there's a line in the code that says:
BTSerial.begin(38400);  // HC-05 default speed in AT command more
  • If the module is still not responding with "OK", try switching the tx and rx pins. It should be:

Bluetooth =>Arduino

RXD =>TX1

TDX =>RX0

  • If that still doesn't work, chose change the pins in the code to other Arduino pins. Test, if it doesn't work swap the tx and rx pins, then test again.
SoftwareSerial BTSerial(10, 11); // RX | TX
Change the line above. You could try RX = 2, TX = 3 or any other valid combinations.
You can look at the Arduino pin numbers in the image above.

Step 6: Connecting the Parts

Now that we are sure that everything works, it's time to start putting them together. You can connect the parts just like shown in the circuit. I got that from Electronoobs. He really helped me with this project. Check out his version of the project here. If you are following this tutorial, you don't have to worry about the receiver connections: input_Yaw, input_Pitch, etc. All that will be handled with bluetooth. Also, connect the bluetooth the way we did in the previous section. My tx and rx pins were giving me a bit of trouble, so I used Arduino's :

RX as 2, and TX as 3, instead of the normal pins. Next, we'll to write a simple app that we will continue to improve until we have the final product.

Step 7: The Beauty of RemoteXY

For the longest time I was thinking of an easy way to build a usable Remote app that would let me control the drone. Most people use MIT App Inventor, but the UI is not as pretty as I would like and I'm also not a fan of pictorial programming. I could have designed it using Android Studio but that would just be too much work. I was extremely thrilled when I found a tutorial using RemoteXY. Here's the link to the website. It's extremely easy to use and the documentation is very good. We will create a simple UI for our drone. You can customize yours the way you like. Just make sure you know what you are doing. Follow the instructions here.

Once you've done that we will edit the code so that we can change the throttle on our copter. Add the lines that have the /**** Stuff you should do and why ***/ to your code.

If it's not compiling make sure you have the library downloaded. Also open up an example sketch and compare what it has that yours doesn't.

//////////////////////////////////////////////
//RemoteXY include library // /////////////////////////////////////////////

// RemoteXY select connection mode and include library #define REMOTEXY_MODE__HC05_SOFTSERIAL

#include <SoftwareSerial.h>
#include <RemoteXY.h> #include <Servo.h>

// RemoteXY connection settings #define REMOTEXY_SERIAL_RX 2 #define REMOTEXY_SERIAL_TX 3 #define REMOTEXY_SERIAL_SPEED 9600

// Propellers Servo L_F_prop; Servo L_B_prop; Servo R_F_prop; Servo R_B_prop;

// RemoteXY configurate #pragma pack(push, 1) uint8_t RemoteXY_CONF[] = { 255,3,0,0,0,61,0,8,13,0, 5,0,49,15,43,43,2,26,31,4, 0,12,11,8,47,2,26,129,0,11, 8,11,3,17,84,104,114,111,116,116, 108,101,0,129,0,66,10,7,3,17, 80,105,116,99,104,0,129,0,41,34, 6,3,17,82,111,108,108,0 }; // this structure defines all the variables of your control interface struct {

// input variable int8_t Joystick_x; // -100..100 x-coordinate joystick position int8_t Joystick_y; // -100..100 y-coordinate joystick position int8_t ThrottleSlider; // 0..100 slider position

// other variable uint8_t connect_flag; // =1 if wire connected, else =0

} RemoteXY; #pragma pack(pop)

///////////////////////////////////////////// // END RemoteXY include // ////////////////////////////////////////////

/**********Add this line to hold the throttle value**************/ int input_THROTTLE;

void setup() { RemoteXY_Init ();

/**********Attach the motors to Pins Change the values to fit yours **************/

L_F_prop.attach(4); //left front motor L_B_prop.attach(5); //left back motor R_F_prop.attach(7); //right front motor R_B_prop.attach(6); //right back motor

/*************Prevent esc from entering programming mode********************/ L_F_prop.writeMicroseconds(1000); L_B_prop.writeMicroseconds(1000); R_F_prop.writeMicroseconds(1000); R_B_prop.writeMicroseconds(1000); delay(1000);

}

void loop() { RemoteXY_Handler ();

/****** Map the throttle value you get from the app to 1000 and 2000 which are the values most ESCs operate at *********/

input_THROTTLE = map(RemoteXY.ThrottleSlider, 0, 100, 1000, 2000);

L_F_prop.writeMicroseconds(input_THROTTLE); L_B_prop.writeMicroseconds(input_THROTTLE); R_F_prop.writeMicroseconds(input_THROTTLE); R_B_prop.writeMicroseconds(input_THROTTLE); }

Step 8: Testing

If you've done everything right, you should be able to test your copter by sliding the throttle up and down. Make sure you do this outside. Also don't keep the propellers on because that will cause the copter to jump. We haven't yet written the code to balance it out, so it would be a BAD IDEA TO TEST THIS WITH THE PROPELLERS ON! I only did this because lmao.

The demonstration is just to show that we should be able to control the throttle from the app. You will notice that the motors are stuttering. This is because the ESCs have not been calibrated. In order to do this, take a look at the instructions on this Github page. Read the instructions, open up the ESC-Calibration.ino file and follow those instructions. If you want to understand what's going on, check out this tutorial by Electronoobs.

While you are running the program make sure you tie down the drone with strings as it will go at full throttle. Also make sure the propellers are not on. I only left mine on because I'm half crazy. DON'T LEAVE YOUR PROPELLERS ON!!! This demonstration is shown in the second video.

Step 9: I'm Working on the Code. Will Finish the Instructable in a Few Days.

Just wanted to add that if you are using this tutorial and waiting on me, I'm still working on it. It's just other things in my life have come up that I'm also working on, but don't worry I'll post it soon. Let's say latest by August 10th 2019.

August 10th Update: Didn't want to leave you hanging. Unfortunately I haven't had the time to work on the project in the past week. Have been very busy with other things. I don't want to lead you on. Hopefully I'll complete the instructable in the near future. If you have any questions or need any help you can add a comment below and I'll get back to you.

Be the First to Share

    Recommendations

    • CNC Contest

      CNC Contest
    • Make it Move

      Make it Move
    • Teacher Contest

      Teacher Contest

    Discussions

    0
    None
    Penolopy Bulnick

    7 weeks ago

    Looks like a handy guide! Thanks for sharing :)