Introduction: Easy Android Controllable, PC Interfaceable Relatively Cheap Mini Quadcopter (or Octocopter!) Drone...

Or how to become a drone developer without mortgaging your house.

Here is how to make a small, indoor/outdoor quadcopter that you can
fly with either:
* an android phone or tablet
* a legitimate remote
* via your own processing (http://processing.org) sketches on a PC
  (or Android device)

There are lots of optional steps in this project - for example, you
can skip building the quadcopter, and buy one instead - you will still
be to use the Arduino based radio to control it from your
phone/laptop/tablet.  However if you go this route you will miss the
satisfaction of combining the ancient chinese arts of bamboo lashing
and cheap mass manufactured electronic toys...

However you go about it, this is a reasonably cheap project, the most
expensive part other than my laptop and tablet is an Arduino DUE and a
cheaper device could be used if desired.

The ability to write your own code to fly the copter make this more of
a drone than many remote control projects, but you will need to
develop your own code to actually decide what throttle, rudder,
aileron and elevator commands to send it when - a work in progress
based upon a 'Ground station' camera tracking the copter from
underneath is included, but it doesn't fly it yet!

As a simpler exercise for the reader, you can also look into adding
forward/backward/left/right FLIP buttons to the android remote.

Taster video 1: Drone controlled by tablet:
https://www.dropbox.com/s/fesrc4n9tjhul1p/2013-06-27%2022.01.41.mp4

Taster video 2: Onboard footage from flipping (and crashing)
octo-droner:
https://www.dropbox.com/s/cy0xmmbytiqymw7/copter-fpv-flip-flipped.mp4

This work was inspired by the 18$ quadcopter thread on rcgroups
(http://www.rcgroups.com/forums/showthread.php?t=1710948) - take a
look at rcgroups for plenty more inspiration.

It also makes use of plenty of other people's work, but most
immediately the processing-serial-android library
(https://github.com/inventit/processing-android-serial/) and the
hubsan X4 and A7105 code from the deviation project
(http://www.deviationtx.com/)

Step 1: Approach, Materials and Safety.

This project leaves all the hardwork of copter flight control, radio
receivers, Electronic Speed Controllers, IMU's and so on to a single
part from a commercial RC copter, the Hubsan X4.  This, and other
parts are all availble as spares, itemised below, however these
little hubsan copters are fun toys in their own rate, and are probably
worth the relatively cheap (~£35) asking price just to get the practice
flying, and they come complete with one battery, spare propellers,
charger & remote.  You should still order spares to build your own
though!

This assembly approach means you get to the stage of flying, and
coding flying routines much quicker than most and is argubly
cheaper as well.  It also means you have to know less about the
fascinating arena of remote control aircraft in general and
quadcopters in particular - so you can and should rectify this by
taking a look at some of the great Instructables on the subject!

The same thing can be done with other brands' parts - in particular
anything that Deviation supports would probably be an easy enough port
to Arduino.  In general, everything here can be done much better -
plenty of room for the reader ;)

A word about safety- big quadcopters are very dangerous.  If you've
got the stomach for zombie movies then you'll find plenty of evidence
for this on the web.  Anything under the control of a collection of
home brew electronics can go haywire.  Flying is tricky for everything
that isn't born to it (let me tell you about the birds and the
bees...) - that includes you and your code - you will crash your
copter!

Fortunately these little copters are unlikely to give you anything
worse than a paper cut, but still please do keep the safety and sanity
of yourself and yours in mind when flying - kids, pets and
unenthusiastic partners all deserve to relax without a careening
copter in the face every few minutes.

Also - soldering irons are hot, batteries can explode, kebab skewers
and couches should be kept separate at all times and your neighbours
might punch you if you fly a camera into their backyard.  Which is
both fair and reasonable - if you like people watching find a street
corner cafe and develop a taste for strong espresso and croissants -
sometimes the traditional forms are the best!


Prerequisites
* Laptop with Processing and Arduino environments - the instructions are
   Linux specific, but should all work on other platforms with the minimum
   of faffing. 
* Android device that supports USB host mode.  Tested on Motorola Xoom.
* Soldering iron and related gubbins - solder, helping hands etc.
* Scissors

Step 2: Shopping

Here are the things you will need to buy or borrow to build all of the parts of this project.  I've split it up by part of the build so you can choose to skip elements you don't want.

Shopping list - Quadcopter Frame

This is the structure that your quad's electronics, battery & motor
will be attached to.  You will need:

* Bamboo kebab sticks - used for the copter frame
* Cocktail sticks - used for attaching motors to frame
* Electricians tape - used for taping receiver board and motors to frame
* Sewing Thread - lashing parts together before glueing
* Superglue - or any other cyanoacrylate style glue
* Elastic band - used to attach battery to frame

Shopping list - Quad power & electronics

Everything in this list can get damaged in crashes, so if ordering
long distance consider doubling up.  Additionally, the links are just
for reference - I've bought successfully from these suppliers, but
there's many more fish in the sea so shop around...

* 4 x 7mm Brushed Motors - when sold for micro quad's these come with
   different colour wires to signify clockwise or counterclockwise.
   Get 2 of each colour.  Sold in pairs here:
http://www.banggood.com/Wholesale-2-X-7mm-Hollow-Cup-Motor-For-Hubsan-X4-Walkera-Ladybird-Or-Ladybird-V2-Quadcopter-p-63727.html  

* 4 x propellers.  Like the motors some spin clockwise, others
   counterclockwise.  These match the motor shafts above, and can be
   bought in sets of 4
   http://www.banggood.com/Hubsan-H107-X4-RC-Quadcopter-Spare-Parts-Propeller-Blade-Set-p-72513.html

* 1 x Hubsan X4 Spare Receiver Board - this is the flight controller,
   containing all the clever Accelerometers, Gyroscopes, 'ESC's for
   controlling the motors, radio receiver and the CPU tying together
   all the cleverness that makes it fly.  Not bad for something that
   you can lose in your back pocket.
http://www.banggood.com/Wholesale-Hubsan-H107-X4-RC-Quadcopter-Spare-Parts-Receiver-H107-A04-p-63729.html

* 1 x 240mah 1S 'LiPo' battery.  Many different batteries can be used
   for this, lighter, heavier, lower capicity, heavier capacity,
   different discharge speeds ('C' ratings) but one like this will get
   you started.  '1S' is important, it means there will be one sell in
   series, giving a nominal voltage of 3.7V. More than one is better
   as it takes a lot longer to recharge than discharge!  If you want
   to build an Octo, then a larger battery will get you more airtime.
http://www.banggood.com/Wholesale-UDI-U816-U816A-Hubsan-X4-RC-Quadcopter-Spare-Parts-3_7V-240mAh-Li-Po-Battery-p-48851.html

* 1S LiPo charger.  Ok, this shouldn't get damaged in crashes...  The
   hubsan one is listed here, but anything that charges 1S LiPo's is
   good.  I actually use one that will charge 6 at once.  Be careful
   that whatever you get actually has the correct plug though, and
   when you get it make sure the charger and plugs are wired the same
   way, i.e. red wire to red wire, black to black.  Not all are, and I
   have a melted charger to prove it!
http://www.banggood.com/Wholesale-Hubsan-H107-X4-RC-Quadcopter-Spare-Parts-USB-Charging-Cable-H107-A06-p-63731.html


Shopping list - Quadcopter control hardware

These are the items that are used to actually talk to the copter over
the airwaves. 

* A7105 radio module - this is the radio module that we will use as a
   transmitter to control the copter.  The module basically gives the
   Arduino the ability to talk a digital serial protocol over the
   airwaves.  Note, that despite what ebay sellers may suggest this is
   NOT the same thing as a NRF24L01 or similar module.
http://www.ebay.com/itm/5pcs-A7105-2-4G-Wireless-Module-CC2500-NRF24L01-Transceiver-/181081186070?ssPageName=ADME:L:OC:GB:3160


* Arduino Due.  This is used to interface your android device or PC
   with the A7105 radio.  I used this board for two reasons, the first
   being that it was new and shiny, the second being that it uses 3.3V
   logic levels rather than 5V.  This removes an area of complexity
   when interfacing with the 3.3V A7105 radio module.  A different
   Arduino or other microprocessor can be used, so long as it supports
   USB over Serial and can handle talking 3.3V logic - a level
   converter could be used.
http://store.arduino.cc/eu/index.php?main_page=product_info&cPath=11_12&products_id=243

* Breadboard.  A small one is fine, I got mine from Maplins.  This is where you will assemble the radio module.

* Resistor.  I'm using a 22Kohm resistor - I found this value by
   trial and error, so don't fret if you've got something close but
   not exact!

* Breadboard wires.  You won't need many, but if you have none you
   may as well get a bundle.  Either lengths of solid cored wire, or
   the official ones that come with kits and a spiky bit on each end
   are good.

* USB 'On The Go' (OTG) cable.  This is a cable which allows you to
   plug things like full sized PC keyboards into your Android device.
   Something like the below will be fine.
http://www.amazon.co.uk/Micro-B-Cable-Samsung-Galaxy-I9100/dp/B004TJC1IM/ref=sr_1_2?ie=UTF8&qid=1372676160&sr=8-2&keywords=otg+cable

* Hubsan remote.  This is optional, but handy and fun.
http://www.banggood.com/Wholesale-Hubsan-H107-X4-RC-Quadcopter-Spare-Parts-Transmitter-H203-16-p-63733.html

* Webcam.  This is optional, but if you want to play with a computer
   vision equipped ground station it will be handy...

Step 3: Building the Frame

The frame is made of 2 kebab sticks lashed together together into an X
with cocktail sticks attached to the arms as motor posts.  All
lashings are glued with super glue which makes for a quick setting
joint which is considerably stronger than the wood its gluing.

1: Print off the template svg below.  This is more complicated
than it needs to be, but I use it for making octo frames as well.  You
don't need the template, but it does make keeping everything square a
little bit easier.

2: Cut a length of thread about the length of your forearm and
drape it over a kebab stick so half is on each side.

3: Take two cocktail sticks (or two cocktail stick lengths of
kebab skewer) in on hand and hold so that one is on each side of the
kebab skewer - the photo should make more sense here....

4: Start wrapping thread around sticks first in one diagonal for
abour 4 wraps, then the other diagonal for about 4 wraps.  Repeat
until your out of thread.  Don't worry about keeping things straight
yet, or the positioning - moving things will be easy until we apply
the superglue.  Also don't worry about tidying up the loopse ends
just yet.  Once fixed in place these will act as 1 motor fixing post
and set of legs for the copter.

5: Take another two cocktail sticks, and repeat the above step about
4 fingers width away from the motor post you have just completed.  At
this time the exact spacing is not vital, we will fix this in the
next step.

6: Lay the template out on a flat surface - I actually use a sheet of
glass for such things as its very flat and relatively easy to get
glue off, but any flat surface should do.  If its your dinning room
table I'd put some newspaper or similar underneath just in case...

7: Lay out your loosely lashed stick on the template as shown, and
shuffle the legs along the stick until they are in position.  Use
bluetack to hold things in place.  At this stage it is important to
make everything as square as possible - these copters are not
particularly sensitive to weight distribution, but if the motors are
not pointing straight up they do not fly well, so double check
everything is lieing square with the lines, and that the motor posts
are flush against your template.

8: Once your happy apply superglue to the lashings.  Be quite liberal
- you are aiming to soak the thread enough that the inaccessible side
gets some glue as well as the side you can reach.

9: Wait 2 minutes then lift your construction off the template, and
apply a drop of superglue to the lashings on the other side.  2
minutes later your first quad arm should be complete.

10: Repeat the above process to make your second arm.

11: Next lash use the above technique to lash and glue your two arms
together, making sure again that all motor posts are vertical, and
that they cross at the exact centre.

12: Trim one side of the cocktail sticks so that legs about 2 cm long
are on one side, and motor posts about the same on the other.  Note
that due to the height difference of the arms (as they cross in the
middle) the arm which is underneath will have shorter legs and longer
motor posts and vice versa.

13: Cut four short (about 1.5 cm) pieces of kebab stick and glue
these to the arms as shown.  Glue these in place - no thread is
required as these are not structural, they are merely to provide a
flat surface for the control board and battery.

14: Step back and admire your tiny quad frame.  Make another while
you wait for the other bits to turn up, you'll probably end up using
it at some point!

Variations are up to you, and there are many possible.  The octocopter
is obvious enough from the photos, but you can also create a quad with
longer arms and further between the motors, or keep the motors where
they are and have longer arms anyway - this configuration gives you
a bit of propellor protection as the arms will tend to bump into
things before the propellor does...

Step 4: Completing the Quad.

Apologies for the lack of photos in this stage, I will add them soon!

This stage consists of soldering 4 motors to your X4 Receiver board,
and as such you will need to brush up on your soldering skills before
beginning.  Its pretty straightforward though, so if you don't have
any soldering skills, get on google and spend a couple of hours
reading and practicing.  I've got a temperature controlled iron, but I
guarantee for this job a 5 pound one from the local hardware store
will work.

First identification - the red and black wire with a little plug on
the end is where the battery is connected too, and marks the back and
top of the board.  The solder pads are on the bottom of the board, so
the first thing to do is to flip the board over (battery wire down),
and hold it in place while you work - I use bluetack but a 'helping
hand' would result in less bluetack stuck to your board.

We will refer to all connections with reference to this orientation
(the board lieing on its back).

1: Identify motor pads.  The new hubsan X4 boards have pads for
LED connections on them as well as for motors.  These are marked 'LED'
- these are the ones you do NOT want to attach motors too.  The motor
pads are in the four corners of the board, and in pairs, one for the
+ve wire, the other for the -ve wire.

2: Take one of your motors with black and white wires, and solder
both its wires to the BOTTOM LEFT pads with the white wire going to
the LEFT pad in the pair.

3: Take a motor with blue and red wires and solder it to the TOP LEFT
pads with the red wire going to the LEFT pad in the pair.

4: White and black motor, TOP RIGHT, with the black wire going to the
LEFT pad in the pair.

5: Red and blue motor, BOTTOM RIGHT with the blue wire going to the LEFT
pad in the pair.

Note that in the diagram I've used a dotted line for white.

Now you will likely have a ball of motors (yup they're magnetic...)
wired to the board.  The board and wires don't like too much
wiggling, so you may want to apply some flexible glue ('Fantastic
Elastic' worked well for me) to the connection points as strain
relief.

The next stage is to attach all this to the frame - for this we will
be using the slightly stretchy 'electricians tape' much loved by
bodgers everywhere.  The orientation of the board on the frame  is the
same as shown in the wiring picture.  It is important to get this as
centred as possible, the processing that keeps the copter aloft is
very clever, but it does assume it is located in the centre of its craft. 
A single piece of electricians tape will surfice to hold it in place.

The motors should be attached by half width (~5mm) pieces of tape
attaching the motors to the side of the posts furthest from the centre
of the copter.  Don't worry too much about the height, make an attempt
to keep them even, but don't fret about it.  If you twist the motors a few
times before fixing them to wrap the wires against each other it will
help keep things neat and reduce electrucal noise in the wires.

Once the motors are attached you can push propellors onto the props.
Use white propellors for the 'front' (opposite end from the battery
wires) and black for the back.  Unfortunately its not quite that
simple, as some of the propellors are designed to spin clockwise, and
the others counter clockwise.  Which is which is determined by a
small, difficult to read 'A' or 'B' on the top side of the props.

Use 'A' propellors for the top left and bottom right motors, 'B'
propellors for the rest.

That's it, now you can attach a battery to the underside of the frame
(I use a rubber band), and if you happen to have the official hubsan
controller you can see how she flies!

Trouble shooting for those with copters:

* Copter shakes in the air: Your motors probably are not pointing
   vertically - check, and if not see if you can twist, tape or shim
   (with small pieces of card) things into shape.

* Copter drifts quickly in one direction: Put your copter down on a
   flat, level surface and hold your left stick as far down and right
   as it goes.  While holding this, wiggle your right stick left and
   right until the copters 'eyes' flash.  This means the accelerometer
   has accepted a new definition of 'down'.

* You keep on flying the copter into walls: Take it easy, slow down
   and use very very small movements until you get used to things.

Step 5: Building the Arduino Driven Radio.

This element of the project allows anything that will talk 'serial'
over an Arduino's USB port to control your copter.  This includes many
android devices and your computer.  I wanted to include a 'Fritzing'
diagram of this, but the library doesn't have the SPI pins of a DUE
marked as connection points, and I don't know how to work around that,
which combined with the lack of A7105 module in Fritzing meant we're
making do with photo's and descriptions :(

1: Identify the 6 pins on your A7105 board that we need, on the
following diagram these are:
  Left hand side:  GND
  Right hand side: SDIO, SCK, SCS, GND, VCC


2: Solder 2 cm lengths of solid core wire too each of these pins.
Once soldered on I pull the insulation off the wires giving me six
legs that I can press into a breadboard.

3: Insert A7105 board into breadboard with the left hand pin on one
side of the central channel, and the right hand pins on the other
side.

4: Attach the 'ground' of your Due to the 'ground' (black) rail on
your breadboard.

5: Attach the '3.3v' of your Due to the 'live' (red) rail on your
breadboard.

6: Wire jumper wires from your live rail to the 'VDD' pin of your a7105

7: Wire 2 jumper wires from your ground rail to the TWO 'GND' pins of
your a7105.

8: Wire the MOSI pin of your Due's SPI header to one end of the
resistor.  See
http://21stdigitalhome.blogspot.co.uk/2013/02/arduino-due-hardware-spi.html
for a diagram of where MOSI is.

9: Wire the other end of your resister to the 'SDIO' pin of the A7105

10: Put an additional wire from the 'SDIO' pin of the A7105 to the
'MISO' pin of the due.

11: Wire 'SCK' on the Due to 'SCK' on the A7105

12: Wire pin 10 on the Due to 'SCS' on the A7105

Note: Please disregard the blue resister in the photos - its left over
from when I was trying out resister values and is not part of the
circuit!

Step 6: Arduino Software

The following sketch makes use of a hacked version of PhracturedBlue's 
hubsan X4 and A7105 code.  Plug your Due into your computer via the
'Programming Port' - its the one closet to the DC power socket. Download
the zip, load the sketch into Arduino, and upload it to your Due.  The sketch
will handle listening for commands on its serial port, and turning those into
radio signals for the quad control board.

See http://deviationtx.com for the original code.

The sketch will connect ('bind' in RC speak) to the hubsan control board
without a serial connection, so you can test if the radio is working simply
by powering on your quad, and then powering on your arduino.  If the quad's
lights stop flashing, your in business! 

Step 7: Android Software

The android software gives you a simple controller for flying your
copter via your android devices accelerometer and touch screen.  Your
device will be communicating with your arduino radio via a USB
connection. 

1: Install the software:

This software is built in processing.  You will need to allow USB
debugging on your android device, as well as allowing the installation
of apps from outwith google play.  A ready to run APK is is available
here: https://www.dropbox.com/s/5pmqfuhy1g4vplw/CopterController-debug.apk

The source code is available in the zip below.

You will need to setup your processing environment for android
development to use the source - see:
http://processing.org/tutorials/android/

2: Plug your device into your radio.  You will need to use the 'OTG
Cable' for this - its basically an adapter that allows full sized USB
plugs such as those found on keyboards to be plugged into your android
device.  Additionally somewhere inside the adapter there's a crossed
wire that informs your device that its the host - i.e. 'da boss'.
This means it is important that it the android device NOT the Due
board that the OTG adapter is plugged into.

The 'boss' behaviour means that your android device will be powering
your arduino and radio - so make sure your fully charged, or better
still provide external power to your arduino board.

If you've installed the controller app then when you plug the board in
it should ask if you want to start the app.  Say 'yes'.

3: Plug the battery into your copter, and put it down on a flat
surface.  If everything is good the lights should stop flashing and turn steady.

4: Pretend to be a sniper, sit very still, hyperventilate to oxygenate
your blood, take a final deep breath and slowly slide your left thumb
up the screen of your device.  The propellors should start turning.
Take your finger off and they should stop again.

5: Repeat the above, but also place your right thumb on the screen.
This will enable the accelerometer for forward/back/left/right control
- throttle up until your flying, and see how long you can keep it in
the air!  Moving your right thumb left and right will spin the copter
on the spot left and right.  Taking your right thumb off should return
your copter to level regardless of how your tilting your android
device, and taking both thumbs off will bring the throttle to zero
instantly - this is a good move if - and this is obviously a random
example - your copter is eating its way through your prized
houseplants...

This takes practice so don't be put off early...

Step 8: PC Software

By talking the same simple serial protocol you can also fly your copter from
the computer.

Here is a zip of a basic ground control system that attempts to spot
the copter above a web cam, and keep it centred.  It can also be flown
with the cursor keys (for elevator/aileron) and 'a' and 'z' (for throttle)

The bad news is 'autonomy' doesn't work yet, but it will keep the copter
centred above the camera for about 10 seconds if I control the throttle ('A' for
throttle up, 'z' for throttle down).  The visual tracking currently
relies on red and green coloured LED's at the end of one arm to make things
easier.  These are connected to the copter's battery via the LED solder pads
mentioned in step 4.

Originally I was going to use a WIIMOTE for this, but the advantage of being able
to use colour to tag each end of the copter seemed to great to pass up.

I will continue adding updates - hopefully I'll be able to get this
working with a phone's camera strapped inside  my top hat, and I'll have a
copter that takes off from inside my hat then faithfully follows me down the street!  
Hmmm, I wonder if voice control will be possible via the google APIs :D

If you make this work before I do please do share - the code that is , I'll get my
own top hat ;) 

Step 9: Building the Octocopter

The octocopter shown in the pictures is built in exactly the same way, with one exception:

Two identical motors are identically wired to each corner of the control board.

The octocopter uses more power, but can lift more weight - with a 750mah 1S battery it
can fly with a 'stripped' mini '808' spy camera for around 8 minutes.   It is also small enough
and quiet enough that it can happily sit in a crowd of flying seagulls watching them swirl around:
https://www.dropbox.com/s/pngla54apudsh60/copter-seagulls-flipped-stabilized.mp4

The stripped camera has its case removed and a little 90mah battery in place of the original.

Excuse the video - its unedited, but I ran it through 'transcode's deshaker with the borders
switched on so it looks a little odd.  And I crash a lot...

Step 10: More Ideas and to Sum Up...

These little quads and octos are cheap, light, relatively difficult to break, and can give
you an extremely rapid entrance in programming flying drones.

The simple quick to build frames encourage you to experiment and innovate.  The one in
the photo's took 20 minutes and was done on a moving train...  Form factors I've not tried
but will are totally enclosed (protection for house plants) and octo's with downward facing
motors below the upward facing motors - quad size wtih octo power?

They will never be truly autonomous, but with a phone having the potential to act as a
complete intelligent ground station it is entirely plausible you could have a couple following
you on a down hill bike ride acting as chase cam - or any other idea you can come up with! 

Drones Contest

Participated in the
Drones Contest

Arduino Contest

Participated in the
Arduino Contest

Remote Control Contest

Participated in the
Remote Control Contest