Professional Documents
Culture Documents
Arduino Drone With GPS
Arduino Drone With GPS
by elementguy
We have also included all the steps we took on the Steps only required for the in-progress autonomous
way to a more autonomous quadcopter. If you feel quadcopter have "(Mega)" after the title.
comfortable digging deep into Arduino or already
have a lot of Arduino experience and would like to To build the Uno-based quad, follow steps in order,
take our stopping point as a jumping-off point for your skipping any steps with "(Mega)" after the title.
own exploration, then this Instructable is also for you.
To work on the Mega-based quad, follow steps in
This a great project to learn something about building order, skipping any steps with "(Uno)" after the title.
and coding for Arduino no matter how much
experience you have. Also, you will hopefully walk
1) One quadcopter frame (the exact frame likely 11) Two HC-12 wireless transceivers (2x$5 = $10)
doesn't matter) ($15)
12) One MPU- 6050, 6DOF (degree of freedom)
2) Four 2830, 900kV brushless motors (or similar), gyro/accelerometer ($5)
and four mounting accessory packs (4x$6 + 4x$4 =
$40 total) 13) One Turnigy 9x 2.4GHz, 9 channel
transmitter/receiver pair ($70)
3) Four 20A UBEC ESCs (4x$10 = $40 total)
14) Arduino female (stackable) headers ($20)
4) One power distribution board (with XT-60
connection) ($20) 15) LiPo Battery Balance charger (and 12V DC
adapter, not, included) ($20)
5) One 3s, 3000-5000mAh LiPo battery with XT-60
connection (3000mAh corresponds with approx. 20 17) USB A to B male to male adapter cord ($5)
min of flight time) ($25)
17) Duct tape
6) Lots of propellors (these break a lot) ($10)
18) Shrink tubing
7) One Arduino Mega 2560* ($40)
Equipment:
8) One Arduino Uno R3 ($20)
1) A soldering iron
9) A second Arduino Uno R3** ($20)
2) Solder
10) One Arduino Ultimate GPS Shield (you don't
need the shield, but using a different GPS will require 3) Plastic Epoxy
Optional components for real-time FPV (first person Cost of FPV system: $80
view) video transmission:
Costs:
This step is fairly straightforward, especially if using picture), so that the drone has a clear front and back.
the same pre-made frame we used. Simply use the Further, make sure that the long part of the bottom
included screws and put the frame together as plate sticks out in between opposite-colored arms.
shown, using an appropriate allen wrench or This becomes important later.
screwdriver for your frame. Make sure that arms of
the same color are adjacent to each other (as in this
Now that the frame is assembled, take out the four You should also have four propeller cones with
motors and four mounting accessories. You can use female threads. Set these aside for now.
either screws included in the mounting sets, or
screws left over from the quadcopter frame to screw Now take out your ESCs. One side will have two
the motors and mounts in place. If you buy the wires coming out of it, one red and one black. For
mounts we've linked to, you will receive two extra each of the four ESCs, insert the red wire into the
components, pictured above. We have had good positive connector on the PDB and the black into the
motor performance without these parts, so we left negative. Note that if you use a different PDB, this
them off to reduce weight. step may require soldering. Now connect each of the
three wires coming out of each motor. At this point, it
Once the motors are screwed in place, epoxy the doesn't matter which ESC wire you connect with
power distribution board (PDB) in place on top of the which motor wire (as long as you are connecting all
top plate of the quadcopter frame. Make sure that you the wires of one ESC with the same motor!) You will
orient it such that the battery connector points out in correct any backwards polarity later on. It is not
between differently-colored arms (parallel with one of dangerous if wires are reversed; it only results in the
the long portions of the bottom plate), as in the picture motor spinning backwards.
above.
2
1
1. Extra components 1. Power distribution boar mounted with the connector between different
colored bars so that it is easy to connect to the battery.
A note before you begin pin row labeled 3V, CD, ... RX. Use a wire cutter to
clip off excess length on the pins sticking out the
First, you may choose to solder all the wires together bottom. Place male headers with bent tops in all of
directly. However, we found it invaluable to use pin these stackable headers. These are what you will
headers because they provide a lot of flexibility for solder wires to for the rest of the components.
troubleshooting and adapting the project. What
follows is a description of what we did (and Attach the GPS shield to the top, making sure that
recommend others do). the pins match up with those on the Arduino (Mega or
Uno). Note that if using the Mega, plenty of the
Prepare Arduino and shield Arduino will still be exposed after you put the shield in
place.
Take out your Arduino Mega (or an Uno if doing the
non-autonomous quad), GPS shield, and stackable Place electrical tape on the bottom of the Arduino,
headers. Solder the male end of the stackable covering all of the exposed pin solders, to prevent
headers in place on the GPS shield, in the rows of any short circuit as the Arduino rests on the PDB.
pins parallel to the pre-soldered pins, as shown in the
above image. Also solder in stackable headers on the
1
2
1. These female headers are the parts you will need to solder. Basically, 1. Long ends of the headers are cut
you want the GPS shield to have all of the same input options as an UNO 2. These are also cut.
does. This makes troubleshooting and prototyping so much easier.
The schematic above is almost identical to that made using heat-shrink tubing around the solder. You may
by Joop Brooking as we heavily based our design off choose to do either for any of the components,
his. however soldering directly to the gyro is
recommended as it saves space which makes the
*Note that this schematic is assuming a properly small part easier to mount. Using headers is a small
mounted GPS shield, and thus the GPS does not amount more work up front, but provides more
appear in this schematic. flexibility. Soldering wires directly is a more secure
connection long-term, yet means that using that
The schematic above was prepared using Fritzing component on another project is harder. Note that if
software, which is highly recommended especially for you've used headers on the GPS shield, you still
schematics involving Arduino. We mostly made use have a decent amount of flexibility regardless of what
of generic parts which can be edited flexibly, as our you do. Crucially, make sure that the GPS data
parts generally weren't in Fritzing's included part wires in pins 0 and 1 on the GPS are easy to
library. remove and replace.
-Make sure that the switch on the GPS shield is At the end of our project, we were unable to design a
switched to "Direct Write." good method for attaching all of our components to
the frame. Due to the time pressure of our class, our
-Now wire up all the components according to the solutions generally revolved around double sided
above schematic (except for the battery!) (Important foam tape, duct tape, electrical tape, and zip ties. We
note on GPS data wires below). highly recommend that you spend more time
designing stable mounting structures if you plan this
-Note that you've already wired up the ESCs to the to be a longer-term project. With all that said, if you
motors and PDB, so this part of the schematic is just want to make a quick prototype, then feel free to
done. follow in our process. However, make sure that the
gyro is mounted securely. This is the only way the
-Further, note that GPS data (yellow wires) comes out Arduino knows what the quadcopter is doing, so if it
of pins 0 and 1 on the Arduino (not the separate Tx moves in flight you will have issues.
and Rx pins on the GPS). That is because configured
to "Direct Write" (see below), the GPS outputs With everything wired up and in place, take your LiPo
directly to the hardware serial ports on the uno (pins 0 battery and slide it in between the top and bottom
and 1). This is most clearly shown on the second plates of the frame. Make sure that its connector is
picture above of the complete wiring. pointing the same direction as the PDB's connector,
and that they can in fact connect. We used duct tape
-When wiring the RC receiver, refer to the picture to hold the battery in place (velcro tape also works,
above. Observe that the data wires go into the top but is more annoying than duct tape). Duct tape
row, while the Vin and Gnd are on the second and works well because one can easily replace the
third rows, respectively (and on the second-to-farthest battery or remove it for charging. However, you must
column of pins). be sure you tape the battery down TIGHTLY, as if the
battery moves around during flight this could seriously
-To do the wiring for the HC-12 transceiver, RC upset the balance of the drone. Do NOT connect the
receiver, and 5Vout from the PDB to Vin of the battery to the PDB yet.
Arduino we used stackable headers, whereas for the
gyro we soldered the wires directly to the board and
1
1
The schematic above was prepared using Fritzing do either for any of the components. Using headers is
software, which is highly recommended especially for a small amount more work up front, but provides
schematics involving arduino. We mostly made use of more flexibility. Soldering wires directly is a more
generic parts, as our parts generally weren't in secure connection long-term, yet means that using
Fritzing's included part library. that component on another project is harder. Note
that if you've used headers on the GPS shield, you
-Note that this schematic is assuming a properly still have a decent amount of flexibility regardless of
mounted GPS shield, and thus the GPS does not what you do.
appear in this schematic.
At the end of our project, we were unable to design a
-Flip the switch on your Mega 2560 to "Soft Serial." good method for attaching all of our components to
the frame. Due to the time pressure of our class, our
-Now wire up all the components according to the solutions generally revolved around double sided
above schematic (except for the battery!) foam tape, duct tape, electrical tape, and zip ties. We
highly recommend that you spend more time
-Note that you've already wired up the ESCs to the designing stable mounting structures if you plan this
motors and PDB, so this part of the schematic is to be a longer-term project. With all that said, if you
done. just want to make a quick prototype, the feel free to
follow in our process. However, make sure that the
-The jumper cables from Pin 8 to Rx and Pin 7 to Tx gyro is mounted securely. This is the only way the
are there because (unlike the Uno, for which this Arduino knows what the quadcopter is doing, so if it
shield was made), the mega lacks a universal moves in flight you will have issues.
asynchronous receiver-transmitter (UART) on pins 7
and 8, and thus we have to use hardware serial pins. With everything wired up and in place, take your LiPo
There are more reasons we need hardware serial battery and slide it in between the top and bottom
pins, discussed later on. plates of the frame. Make sure that its connector is
pointing the same direction as the PDB's connector,
-When wiring the RC receiver, refer to the picture and that they can in fact connect. We used duct tape
above. Observe that the data wires go into the top to hold the battery in place (velcro tape also works,
row, while the Vin and Gnd are on the second and but is more annoying than duct tape). Duct tape
third rows, respectively (and on the second-to-farthest works well because one can easily replace the
column of pins). battery or remove it for charging. However, you must
be sure you tape the battery down TIGHTLY, as if the
-To do the wiring for the HC-12 transceiver, RC battery moves around during flight this could seriously
receiver, and 5Vout from the PDB to Vin of the upset the balance of the drone. Do NOT connect the
Arduino we used stackable headers, whereas for the battery to the PDB yet.
gyro we soldered the wires directly and using heat-
shrink tubing around the solder. You may choose to
Take the RC receiver and temporarily connect it to a controller and press the button on the back while it is
5V power supply (either by powering up the Arduino off, as shown above. With the button pressed, turn on
with USB or 9V power, or with a separate power the controller. Now the blinking light on the receiver
supply. Do not connect the LiPo to the Arduino yet). should turn solid. The receiver is bound. Remove the
Take the binding pin that came with the RC receiver binding cable. If you were using a different power
and place it to the BIND pins on the receiver. supply, reconnect the receiver to the 5V out of the
Alternately, short the top and bottom pins in the BIND Arduino.
column as shown in the photo above. A red light
should blink rapidly on the receiver. Now take the
2
1
1. This olive colored wire is shorting the top and bottom pins of the BIND
column.
2. This olive colored wire is shorting the top and bottom pins of the BIND
column.
First, solder together the XT-60 adapter with the Finally, wire up your other 1000mAh battery with the
power and ground wires on the monitor. These may DC out wire that came with your receiver, and in turn
vary from monitor to monitor, but the power will plug that into the DC in port on your receiver. Finally,
almost always be red, the ground almost always connect the black end of the AVin cable that came
black. Now insert the adapter with soldered wires into with your receiver to the AVin port on your receiver,
your 1000mAh LiPo with the XT-60 plug. The monitor and the other (yellow, female) end to the yellow male
should turn on with (usually) blue background. That's end of the AVin cable of your monitor.
the hardest step!
At this point, you should be able to see a camera
Now screw on the antennas on your receiver and view on the monitor. If you cannot, make sure that the
transmitter. receiver and transmitter are both on (you should see
numbers on their small screens) and that they are on
Connect up your small 500mAh Lipo to the the same channel (we used channel 11 for both and
transmitter. The rightmost pin (right below the had good success). Further, you may need to change
antenna) is ground (V_) of the battery, the next pin to the channel on the monitor.
the left is V+. They come the three wires that go to
the camera. Your camera should come with a three-in Mount the components on the frame.
one plug that fits into the transmitter. Make sure you
have the yellow data wire in the middle. If you used Once you have the setup working, unplug the
the batteries we linked to with plugs meant for this, batteries until you are ready to fly.
this step shouldn't require any soldering.
Wire up your second Arduino with your second HC- receiving GPS sentences if your GPS shield is
12 transceiver as show in the above schematic, powered and properly wired to the other HC-12
keeping in mind that the setup will only be powered transceiver (and if the switch on the shield is on
as displayed if plugged into a computer. Download "Direct Write").
the provided transceiver code, open your serial
monitor to 9600 baud. With the Mega, make sure the switch is on "Soft
Serial."
If using the more basic setup, you should begin
This code is identical to that used by Joop Brokking in same hardware port that the device uses to
his Arduino quadcopter tutorial, and he deserves all communicate with the computer, so it must be free.
the credit for its writing.
If the code skips through a bunch of steps all at once,
With the battery disconnected, use the USB cord to check that your GPS switch is on "Direct Write."
connect your computer to the Arduino, and upload the
attached Setup Code. Turn on your RC transmitter. If no receiver is detected, make sure that there is a
Open your serial monitor to 57600 baud and follow solid (but dim) red light on your receiver when the
the prompts. transmitter is on. If so, check the wiring.
This code is identical to that used by Joop Brokking in With the battery disconnected, use the USB cord to
his Arduino quadcopter tutorial, and he deserves all connect your computer to the Arduino, and upload the
the credit for its writing. We simply adapted the wiring attached Setup Code. Open your serial monitor to
for the Mega so that the receiver inputs corresponded 57600 baud and follow the prompts.
to the correct Pin Change Interrupt pins.
Download
http://www.instructables.com/ORIG/FCY/3FL1/JGGTGOJ5/FCY3FL1JGGTGOJ5.ino
…
Once again, this code is identical to Joop Brokking's its firmware). Push the throttle all the way down. The
code. All the modifications were made in an effort to ESCs should emit lower beeps, then fall silent.
integrate the GPS and Arduino and can be found later Unplug the battery.
on, in the description of construction of the more
advanced quadcopter. Optionally, you can at this point use the cones that
came with your motor mounting accessory packs to
Upload the attached ESC calibration code. On the tightly screw on propellors. Then enter the numbers 1
serial monitor, write the letter 'r' and hit return. You - 4 on the serial monitor to power up motors 1 - 4
should begin to see realtime RC controller values respectively, at the lowest power. The program will
listed. Verify that they vary from 1000 to 2000 on the register the amount of shaking due to imbalance of
extremes of throttle, roll, pitch, and yaw. Then write 'a' the props. You can try to remedy this by adding small
and hit return. Let the gyro calibration go, and then amounts of scotch tape to one side or the other of the
verify that the gyro registers motion of the quad. Now props. We found we could get fine flight without this
uplug the arduino from the computer, push the throttle step, but perhaps slightly less efficiently and more
all the way up on the controller, and connect the loudly than had we balanced the props.
battery. The ESCs should cycle different beep tons
(but this may be different depending on the ESC and
Download
http://www.instructables.com/ORIG/FDC/ZXW3/JGCJ14EM/FDCZXW3JGCJ14EM.ino
…
This code is very similar to Brokking's code, however The changes that we made to this code were to
we adapted it (and corresponding wiring) to work with switch from using PORTD for the ESC pins to using
the Mega. PORTA and then changing the bytes written to these
ports so that we activate the proper pins as shown in
Upload the attached ESC calibration code. On the the wiring schematic. This change is because the
serial monitor, write the letter 'r' and hit return. You PORTD register pins aren't in the same location on
should begin to see realtime RC controller values the Mega as they are in the Uno. We haven't been
listed. Verify that they vary from 1000 to 2000 on the able to fully test this code as we were working with an
extremes of throttle, roll, pitch, and yaw. old off-brand Mega that our school's shop had. This
meant that for some reason not all of the PORTA
Then write 'a' and hit return. Let the gyro calibration register pins were able to activate the ESCs properly.
go, and then verify that the gyro registers motion of We also had trouble with using the or equals operator
the quad. (|=) in some of our test code. We are unsure as to
why this was causing problems when writing the
Now uplug the arduino from the computer, push the bytes to set the ESC pin voltages, so we modified
throttle all the way up on the controller, and connect Brooking's code as little as possible. We think that
the battery. The ESCs should emit three low beeps this code is very close to functional, but your mileage
followed by a high beep (but this may be different may vary.
depending on the ESC and its firmware). Push the
throttle all the way down. Unplug the battery.
Download
http://www.instructables.com/ORIG/FZJ/V618/JGGTGPOH/FZJV618JGGTGPOH.ino
…
And again, this third bit of genius code is the work of transceiver code onto your terrestrial Arduino, open
Joop Brokking. Alterations to all these three pieces of your serial monitor to 9600 baud and watch the GPS
code are present only in our attempted integration of data roll in.
the GPS data into the Arduino.
Now you are ready to fly. Push throttle down and yaw
With your propellors firmly mounted onto the frame left to arm the quadcopter, then gently bring up the
and all components strapped, taped, or otherwise throttle to hover. Begin by flying low to the ground
mounted on, load on the flight controller code to your and over soft surfaces like grass until you become
Arduino, then unplug the Arduino from your computer. comfortable.
Take your quadcopter outside, plug in the battery and See the imbedded video of us excitedly flying the
turn on your transmitter. Optionally, bring along a drone the first time we were able to get the drone and
laptop connected to your GPS receiving setup as well GPS working simultaneously.
as your video receiving setup and monitor. Load the
https://youtu.be/QvsWxHCsN3M
Due to our hangup with the ESC calibration code for this step. You will first need to go through and replace
the Mega, we were never able to create flight all instances of PORTD with PORTA. Also, don't
controller code for this board. If you have gotten to forget to change DDRD to DDRA. Then, you will
this point, then I imagine that you have at least fiddled need to change all of the bytes being written to the
with the ESC calibration code to make it work for the PORTA register so that they activate the proper pins.
Mega. Therefore, you will likely have to make similar To do this, use the byte B11000011 to set the pins to
modifications to the flight controller code as you made high and B00111100 to set the pins to low. Good
in the last step. If our ESC calibration code for the Luck, and please let us know if you successfully fly
Mega magically works without any other using a Mega!
modifications, then there are only a few things you
will have to do to the stock code to make it work for
Step 16: How We Got to Where We Currently Are With the Mega Design
Thanks! I just added a video of us the first time we got the drone and GPS working simultaneously.
It is in the step "Get Airborne! (Uno)" if you care to view it.