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

Picture of 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:

Taster video 2: Onboard footage from flipping (and crashing)

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
Remove these adsRemove these ads by Signing Up
1-40 of 89Next »
JoséM3415 days ago

I have some questions about this project.

1. Does hubsan receiver have any sensor like gps, radio, acceleration, etc.?

2. Can I control flight with arduino, and If I can, How I can do it? I want to try autonomous flight, programming with c++

shinyshez (author)  JoséM3415 days ago
I'd advise reading the instructable, which will give you a good intro and answer most of these questions, any further questions you have afterwards, ask away!

MichaelD321 month ago
So, I've put a lot of it together, but I'm having an unbelievably hard time soldering the wires onto the radio signal thing. Not the one that goes on the drone, but the one attached to the arduino. Why they didnt just put holes where the wires should go instead of those stupid indents is completely beyond me.

Do you have any advice with this? I've been trying to get it for the past few days but they just aren't staying. Or maybe a different way to attach it to a breadboard.
shinyshez (author)  MichaelD3223 days ago
Heya, I think I soldered on little breadboard compatible headers rather than wires, something like these: http://oliversmith.io/wordpress/wp-content/uploads/2011/09/DSC04685.jpg

Whether that's easier or not I don't know!
JamesF331 month ago

Hey so I am working on writing my own code to communicate to the arduino in c++. What kind of commands do I need to send to the arduino?

shinyshez (author)  JamesF3329 days ago

Can't really say without a lot more info about your set up and what you are trying to achieve - however the processing code should be an easy place for you to get inspiration as if you know c++ reading it should be a doddle.


Okay so I actually looked through the arduino code and it looks like it gets values for rudder, throttle, aileron, and elevator. I guess my questions is what are the physical quantities these values represent?

shinyshez (author)  JamesF3325 days ago


Most of my answers to this sound a bit smart assed, but fundamentally:

- The same things as they do when flying with the normal controller

- The same as they do for any quadcopter (google those terms you'll get better pictures than I can draw )

- If you really mean 'physical quantities' then they affect the rate at which the propellers are spun - after all a fixed pitch, unarticulated quadcopter doesn't have anything else to vary. The relationship between the commands and the spinning is more complex than we have to worry about thanks to all the gyro's, accelerometers and computing power hidden in the little toys.

Hope that helps somewhat!


Thanks! No worries about sounding smart assed. I expected as much for asking questions that seemed obvious.


MichaelD322 months ago

I have an Arduino Duemilanove. Is this good enough or do I have to also buy the DUE?

shinyshez (author)  MichaelD322 months ago

the radio chip operates on 3.3v logic, whereas the Arduino Duemilanove operates on 5v.

If you are comfortable (or don't mind becoming comfortable!) with converting the logic levels, or converting the Arduino Duemilanove to 3.3v I think it should work....


Thank you! Do you know how I would go about doing this? I'm sure it says somewhere online

shinyshez (author)  MichaelD322 months ago

Google 'logic level converter', 'voltage divider' and have a look at NicholasH1's post below. It may also be possible to take your microprocessors life in your hands and rejig it to run at 3.3v - there may be instructions on the arduino.cc site.

I've not done any of the above, so that is about the limit of my helpfulness, sorry!

compufreek3 months ago

Tried with arduino nano and no luck ... i used the pins but they dont connect ... should arduino nano had different codes ?

joln3 months ago

could it work with this a7105 ?



joln4 months ago
great project! thanks :)

is there a way to control the hubsan with python language ?

joln joln3 months ago

yay I have found one ! will try


NathanG46 months ago

Is there any way, if possible, to send a gyro reset code via the Arduino. I don't own the remote for the H4, I'm only using a phone. My octocopter is drifting diagonally and I'm pretty sure it's the gyro which is set incorrectly. The copter also spins around and around.

Thanks for this AWESOME tutorial!


I would have to recommend trying to balance it properly first, ie be sure your battery isn't throwing it off, doesn't take much with such little birds. Then bind up and set throttle=0 yaw=0, elevator =7F, aileron=0
delay maybe 20us

repeat that about 5x in a row, if you don't get the blinky lights, try setting yaw to FF in the first line...

odair.bonin5 months ago


If there are two receiver in the same room and only one transmitter, the two receivers will receive a communication ?

How does it work?


odair.bonin5 months ago

Incredible project.

If there are two copters in the same room and only one transmitter, the two copters will be controlled?

How does it work?

Venman_5510 months ago

When buying the motors do they have to be clockwise/counter-clockwise or is there a way to wire it that makes it rotate a certain direction?

ivver Venman_558 months ago

Changing direction on:

DC-motor: switching polarity (+ on - and vice versa)

Three-phaze motor: switch places of two wires

NicholasH1 made it!11 months ago

This is cool! I haven't built a custom quadcopter yet, but I have been using these Arduino instructions to control an Estes Syncro / Proto X.

I went ahead and set this up slightly differently--I got it working using 4-wire SPI, rather than 3-wire. This made it a lot easier to interface with the 5v arduinos, and also removed the guesswork from the resistor values. For a Due (or other 3.3v arduinos), 4-wire SPI doesn't require any resistors at all; for an Uno (or other 5v arduinos), a simple voltage divider (11k from MOSI to SPIO, 22k from SPIO to ground) handles writing, and reading (from GPIO1 on the left side of the radio board) doesn't require any resistors.

Three aspects of this took me a while to work out. First, there's commented-out code in the A7105_Setup function that claims to set it into 4-wire mode, but there's an error in it. It writes the value 0b0110 to register 0x0b. This is the correct register, but the wrong bit pattern--the bit pattern should be 0b011001, where the final two bits are 0 for non-inverted output and 1 for enable output. In hex, this value is 0x19. I probably would have caught this sooner, but the error codes in the Hubsan initialization routine all check for specific error flags set to 1...so if all your "read" calls are returning 0, the system thinks initialization has passed.

I added this routine to read the chip's "ID" register. This value is 32 bits long, so I write it into an array of uint8_t variables:

void A7105_ReadChipID(uint8_t chipID[]) {
SPI.transfer(0x46); // 0x40 | 0x06
for (int i = 0; i < 4; ++i) {
chipID[i] = SPI.transfer(0);

You call it like this:

uint8_t chipID[4];
If all four blocks of that are zero, there's something definitely wrong with the connection to the chip. I think this is akin to the MAC address for the chip--it should be constant for any specific a7105 chip, but it should be different for any two a7105s.
Third, and perhaps most importantly, you can't rely on Serial.print in this sketch. Other people have pointed this out as well. Any Serial.print instructions in the sketch will make it unstable. You should comment out any Serial.print instructions before testing the sketch. When the sketch was half-working--talking to the radio correctly, but getting interference from the Serial.print commends--the front two lights on the Estes Syncro would blink in sync with each other, rather than the alternating flash they do when the craft can't find any radio. If you get to this point, persist! You've almost got it working.
I'm planning to use this to build a more useful controller for the Syncro. In particular, I'm going to separate the throttle control from the yaw controls, because on the stock controller it's hard to turn without also bumping the throttle; I'm going to make the throttle control relative rather than absolute, but add a "panic" button to set the throttle to zero; and I'm going to add buttons for extra features, like buttons to adjust rate settings, buttons for flips, and so on. The Hubsan controller offers most of these features, but I'm confident I can produce something superior now that I have the freedom to tweak it to my heart's content.
Here's a photo of my setup. (The thing under the radio is just a little board I etched to make the radio breadboard-friendly, as mine's pin connections were spaced wrong for my breadboards, and the thing in the corner is a pot I wired up to act as a throttle input for testing.)

so i'm working with the Proto X. i'm able to get the lights to stop blinking, that all,

i am geting a ChipID.

There are a couple of things I forgot to mention in my comment. I thought I'd posted an additional note to cover that stuff, but apparently I forgot. First, there are a lot of calls to A7105_Reset in the code. That in itself isn't a problem, but I think the radio forgets about 4-wire SPI after a reset. I fixed this by adding an A7105_Setup call after each call to A7105_Reset, but it probably makes more sense to chain a call to A7105_Setup at the end of A7105_Reset, which would guarantee it always resets to the known-good state. Otherwise Read calls will go back to getting zero at all times if you're using 4-wire. In particular, there's a call to A7105_Reset in initialize() in hubsan.ino. This could be the problem, because initialize() will still complete if the Reads are all zero--it only looks for zero values as an "okay" state--and will probably finish binding the copter, so the lights will stop blinking. But since the code will never detect error states from the radio, it's unlikely to keep communicating properly with the copter after this. (I'm not certain if hubsan_cb() requires any nonzero values, but if it does, this would also prevent it from communicating with the copter if the wire mode was reset.)

The second thing is that the configuration of the sketch in main.ino seemed weird to me too, so I rearranged that--I moved the setup and initialization to a setup() function, and made the while(1) loop body into the entire loop() function. That made more sense to me.  Finally, I didn't use the Serial.read value settings that the original author did--I was having enough trouble with Serial changing the timing of things that I decided to just hook up a potentiometer to analog zero and use that for the throttle setting as a proof of concept. That's what worked for me. I haven't used the original author's Processing sketches with the code or with the proto-X.

The entirety of my altered "main.ino" code, then:

void setup() {
  delay(2000);  // gives two seconds to open serial monitor to see chip id
  uint8_t chipID[4];
  Serial.print("Chip ID: ");
  for (int i = 0; i < 4; ++i) {

void loop() {
    int throttlereading = analogRead(0);

    // set global control variables for the quadcopter
    throttle = throttlereading / 4;  // Scale 0-1023 down to 0-255
    rudder = 0x7f;      // Midpoint setting
    aileron = 0x7f;     // Midpoint setting
    elevator = 0x7f;    // Midpoint setting
    int hubsanWait = hubsan_cb();

Once again, note that I altered "initialize" so that it would call A7105_Setup after A7105_Reset, so that the code would read error states correctly.

Hope this helps.

Hey Nick,

Thanks for the help! so for no go :(

One thing I tried printing the id be for and after paring, is this normal?

Id be for paring is all was,

ID: :85:32:16:65

if after paring is,

ID: :0:0:65:167


I was ablet to get woking, using a teensy 3.1 https://www.pjrc.com/teensy/teensy31.html

my testing loop

void loop() {

startTime = micros();

boundcnt = Get_state() >= 8 ? boundcnt + 1 : 0;

hubsanWait = hubsan_cb();


finishTime = micros();

waitTime = hubsanWait - (finishTime - startTime);


startTime = micros();


i allso in hubsan_build_packet() i set,

packet[10] = 0x19; vs 0x64

used this to test the lights and throttle

if( cnt < 100 )


packet[9] = 0x0e; // LEDs on, flip on for the 100 first frames




packet[9] = 0x02; // LEDs off, flips off

packet[2] = 0xaa;


and i have lift off,!!

shinyshez (author)  NicholasH111 months ago
Hey that's great work and will really help others who try and reproduce, thanks for contributing!
VladB11 year ago

Thanks for DYI it is great,

i just don't understand why you need the resistor for 20K?

and can you please explain how to connect it to arduino nano/leonardo?

Thanks for the awesome project. I've managed to build it. I am interested in the android processing serial library you've used. I've tweaked your processing code to reverse the controls as they were backwards when using it on a Nook HD. I can't seem to get the app to connect to the Due. Having gone to inventit processing android serial github, i noticed you had had the same issue as well, but have hacked the library to get it working. I was wondered if you might be willing to share your hacked library. Thanks!

allowishus1 year ago

For those interested, i've just flown my Hubsan x4 with my laptop using this tutorial. But instead of the DUE i tried to make it work with the Sparkfun Arduino Micro Pro 3.3v which by comparison to the DUE is amazingly tiny, about the double the size of the A7105 radio,

And it seems to work, further testing is of course requiered and i will return with my finding. Now to wait 'till after exam to dig into the coding :P

Thanks for a great guide!

Isigo made it!1 year ago

Hi everyone !

Thanks to the awesome work of shinyshez, andy_m and drdanny, i've been able to control my hubsan x4 fpv version with my leap motion controller. Here's the link for the github repository : https://github.com/Isigo/LeapCopter

Bug report and pull request are of course welcome. Soft still buggy, and harsh to read ( have to improve this as well ), and remember that it's a work in progress ;)

shinyshez (author)  Isigo1 year ago

That's awesome! Do you have any video of it in action?



For sure ! Got this one (throttle control is still buggy ^^) :


vahokif made it!1 year ago

Hi everyone. I've been working with andy_m but I've taken a different approach and used an MPSSE cable to interface directly with the A7105. I've got binding and control working quite reliably. You can find the code here: https://github.com/vahokif/hubsan Also included is an example script that uses an Xbox 360 controller to control the quadcopter. Bug reports/pull requests are welcome.

andy_m1 year ago

My previous comment was a bit premature - I have encountered a
number of issues with this method, both with the wiring and the code.

I cannot get 3 wire SPI to work. When there are no resistors, the MOSI
holds the SDIO pin high, so that the MISO channel can't seize it to
transmit the contents of the register back - this is why we have been
reading 0s off the registers, they are just the 0 we are transmitting as
the second part of a read transaction. When I make the line high
impedance, however, the signal is getting garbled, and it is not being
parsed as a command, and this is resulting in garbage output - the 128s
and the 196s.

Then, with 4-wire SPI, it took a bit of
troubleshooting - in shez's code there is a commented out line saying to
write 0x06 to register 0x0b - this is incorrect, due to an unclear
piece of phrasing in the chip spec. In fact, we need to write 0x19 to
register 0x0b.

My current issue is that I am having problems getting the binding to work. I shall be putting some hours into that over the weekend and early next week.

I am currently refactoring the code and adding a
number of diagnostic functions, including a sniffer and a shouter for
testing packet transmission (I have two of these rigs, and am using each of them
to debug the other). I will let you know as and when I get somewhere. I
am developing this as part of an academic research project and we are against a deadline, so it would
be reasonable to expect some progress in the next two weeks. It is my intent to pull all this together into an arduino library, to make it easy for people who want to hack about with these chips to do so without having to mess about with raw opcodes and things.

Shez- if you are reading this, ignore my earlier messages, and thank you for all your hard work!

drdanny andy_m1 year ago

Hi Andy & Shez,

First off, thanks for the excellent instructable. I think you saved me many days of trial & error.

I am using a Due & XL7105 module with an off-the-shelf Estes Dart (aka Hubsan X4) device. I succeeded in getting the 3-wire SPI interface working with more or less the A7105 code from Shez. However I did figure out how to overcome a few problems on the way. Here are some notes on what I did:

  • you do need to experiment, perhaps radically, with the resistor. I was able to make 2.2K (Red-Red-Red) and 4.7K work, but not 10K or 22K.
  • timing is quite critical I think, so adding Serial.println debug statements was interfering with the binding. I tried using a circular buffer and delaying output for a while, but even the character processing to stuff the buffer could cause binding to fail. Often the quad would think it was bound (lights solid) but the code would not recognize this and would fall back to a lower state. Perhaps a LED tied to a Due pin that switches on when state is 8 or above would be a good idea? In the end I found the binding part was working anyway and my problems were elsewhere.
  • throttle values below 10 (YMMV) will not make the motors spin
  • there is a safety feature in the Quad software: nothing will happen unless the throttle is brought down to zero and held there for a bit (say 80 times round the loop) before raising it

Here is some code to insert before the "hubsanWait = hubsan_cb();" line in the loop to test:

rudder = aileron = elevator = 0x7F; // midpoints?
if (boundcnt >= 80 && throttle < 12) throttle += 1;
if (loopcnt > 280) throttle = 0; // end test
loopcnt += 1;
boundcnt = state >= 8 ? boundcnt + 1 : 0;

and, of course, declare loopcnt and boundcnt as "int"s and init to 0 before the while loop. You may need to play with the constants to get this to work. Remember to tie the beast down before you start testing!

I had quite a time trying to solder the tiny castellated connectors. After I wrecked my first module I upgraded my soldering skills using youtube, learned how to do reflow soldering by hand, and got myself some finer solder & wire (22 AVG). How did you manage to get such beautiful neat connections?

Raspberry Pi's also have 3.3V SPI, I think, and they cost about the same as a Due, so I may rewrite the code to work with one of those later on. Will post if I do.

Now to start in on the camera business!

andy_m drdanny1 year ago

Oh, thank you!

Now you have said that, it makes complete intuitive sense. I have liftoff now, revisions pushed to my git.

I was lucky with the soldering - one of the people on my team is an ex R&D bod, so we left it all to him. I do not envy you.

Hey Andy, any chance of open source? Github?

1-40 of 89Next »