Sunday, 31 March 2013

Using a Raspberry PI + Wifi as transmission for a tricopter

I finally completed my little challenge of replacing the standard 2.4Ghz RC transmission system of my tricopter with a home-made wifi-based system. This is completely overkill and useless but it was pretty amusing to put in place! By the way, that's the exact opposite of what some people have done to their parrot drone transmission!

Here are a few diagrams to illustrate what I've done (I like diagrams!). The following is a block diagram of the "standard" tricopter:

And here is the same thing with the new "transmission" block:

Concretely, I've basically replaced these simple and effective pieces of equipment:

With this (on the transmitting end):

And this (on the receiving end):

Funnily enough, it's possible to connect an RC-transmitter to the laptop via USB. It will be perceived as a gaming device... Yes I realize how silly it all is :) !

Strapping all this on the tricopter was a bit lousy (the USB cable takes so much space and weight!)

But here's a successful 5-second test flight :)

The overall control felt a bit sluggish... It might be the extra weight or more likely the whole system introduces latency. Anyway I need to make some more tests!


  1. Hi! I'm trying to make a raspberry pi controlled hexacopter.
    I'm particulary interested in how you let the raspi control the ESCs. I see you are using a Polulu Maestro to control the KK2.0. I assume the KK2.0 still does all the calculation work to keep flying? Also, is there any other way to connect the raspi with the polulu, as USB seems a bit overkill. (I will be using a model A, so the USB port will be occupied by a wifi adapter) How does all of it work? I'm very interested, it would be very kind if you would provide some detail �� .

    I made a forum topic at the raspberry pi forums as well, you might want to check that out as well:

    Thanks in advance!

  2. Hi Evert,

    Thanks for the message. I read your topic and it looks like we share the same goal :)

    In my case, you're right the KK board still does all the calculation (I'm planning to have the Pi take care of that in the long run). As I tried to illustrate on the diagrams, instead of taking inputs from a RC receiver, the KK board takes them
    from the Pololu Maestro driven by the Raspberry Pi (which itself receives them over Wifi).

    The USB connection between the Pololu Maestro and the PI isn't great I agree, not so much because it's overkill but more because the connectors and cables weigh a ton! (I'm planning to make my own cable and maybe use lighter connectors) and as you say: USB ports are precious too!

    To answer your question: the Maestro can be controlled by USB or by TTL serial. See here: and

    Maybe the Raspberry Pi can produce these TTL signals on the GPIO bus, but I don't know much about electronics (yet!). It would certainly be cool to free one USB port...

    I might be possible to completely get rid of the Pololu module by having the Raspberry Pi talk directly to the ESCs (i.e. generate PWM signals). Have a look here:

    For you project though, you'd need 6 PWM outputs... Not sure if that's feasible.

    Another option might be to connect a PWM generator (something like the Pololu) but on IC2 bus of the Raspberry. But again I haven't looked at that yet. I'm first trying to get things working quickly with all this ugly/heavy USB mess and then I'll look more closely at the GPIO if need be.

    If you manage to get interesting stuff let me know :)

    By the way, have a look at Matthew's Picopter... He's done all that already with his own extension board for the Pi :)

    He's the man!

    1. Thanks a lot for your reply!
      I've searched a bit, and it doesn't seem to be that difficult to let the raspi control the pololu. I do have a question, would it be possible to read the sensor data? It won't be such a problem if it isn't possible, but on the long term I would like to add a GPS module. Some boards (multiwii etc) have it preinstalled, so it would be cool if the raspi could use that GPS module rather then having to add another piece of hardware.

      And it's interesting to see Matthew's Picopter, but I'll be using a separate board anyway, as stated in the topic.

      Thanks a lot again, and if I make progress, you'll probably see it in the topic :)

    2. I don't see how you could get sensor data (gyros) from a KK board to the raspberry.
      I don't know the multiwii at all. I suspect it'd be the same, even with an optional/pluggable GPS. But I might be wrong

  3. hi.. i am a newbie in quadrocopter stuff.While googling i came across your blog. Your project is good.Even i want to do something like yours - controlling a quadcopter with raspberry along with kk board. But the problem i came across is "what type of signals need to be sent to kkboard from raspberry to control ?" can u help me ?

    1. Hi,

      The KK board (as most RC flight controller board) takes 4 PWM signals as inputs (throttle, ailerons, rudder and elevators commands).

      A PWM signal is what get generated by an RC receiver. And this is also what an ESC/servo takes as input (so you can basically plug a servo directly to a receiver if you want).

      In this project I use a Pololu Maestro module connected via USB to the Raspberry Pi to generate these PWM signals. These are sent to the KK board.

      Have a look here:

      And also on the Pololu blog:

      If you're new to quadricopters, I'd suggest building one based on standard components before trying to introduce a Raspberry Pi. Personally I started with the excellent RC Explorer's Tricopter 2.5:

      Hope that helps!

  4. Thank You :) Jacques for explaining to me in simple words. Your links are also very useful to me . I have one more doubt.

    After going through the second link and maestro module's manual i understood that we either send a high voltage (say 5volts) or a lowvoltage (0 volts) to maestro and it generates the PWM signal. This pwm signal goes to kkboard. my doubt is " if we want increase throttle what voltage should be given to meastro and if we want to decrease throttle what voltage should be given to maestro" .

  5. Sorry if that wasn't clear: the second link is only general information about servos and PWM signals (it happens to be provided by the Pololu folks).

    The Maestro Module takes care of generating the electrical PWM signal for you. You simply drive it in high-level way via USB (from a PC or Raspberry Pi for example). For example: "set the PWM signal width to 5500 ┬Ás for channel 2". You surely have to understand what PWM is though.

    Have a look at the actual Maestro module documentation, it's pretty clear:

  6. hey can u tell the procedure and code you used to control polulu maestro ?. i tried out many ways but couldnt figure out how .

  7. Hi,
    You can find the code I've developped to control the Pololu Maestro here:
    It's a C++ lib that comes with a test program. Have a look at the main page for info.

  8. This comment has been removed by the author.

  9. Hi Jacques,

    Very good project! I was watching some videos from your later posts and was impressed with the range of your pi quadcopter!

    Is the link being established over a wifi network as its a big range?

    Also have you come across any information about doing this sort of thing over a 3g connection. I've looked at the port tunnelling options and so on but they seem extremely complicated!


    1. Hi Sean,

      Some recent videos (with the Rift for eg) are taken from my tricopter which still uses the regular RC transmitter.

      I haven't measured precisely the range of the WiFi-quadcopter. So far, I've tried not to fly too far away (I'd say about 50m max) because I haven't properly tested what happens when the WiFi drops completely :) (the quad is supposed to stop and fall!).

      I need to put in place a link-quality metric so the user gets some feedback.

      As for the 3g connection I thought of it too. The range/coverage would be amazing! I did some tests, but the latency seems too high for realtime flying. It can certainly be used to give high-level orders like go there, or stay put at such altitude... That'd be the way to go I think

      As far as I can tell, using 3g with UDP is problematic. Not sure whether it's caused by restrictions from the phone companies or some internet equipment messing things up. Anyhow, I managed to send UDP packets from my phone to my home PC via 3g, but not the other way round. I think TCP would be OK though.

      Anyway thanks for the feedback!


  10. Thanks for your reply Jacques!

    OVer 3g I am looking for automous control, where I tell pi copter to fly to certain coordinates and altitude and await next orders.

    Juat wondering if you know any good resouces where I can find more information on doing this as Im finding it tough to research!


  11. No problem!
    OK so 3g would work fine in your case.

    For the resources, if you want to write your own flight controller from scratch (that's my next goal!) then it's quite some work. I've found an excellent tutorial here:
    That's a good starting point. Altitude and GPS are left aside though.

    If you want to use an existing flight controller (like ArduPilot, etc...) and tell it where to fly (control it from a Raspberry Pi for eg), this should be easier but I don't know much about how to do this. I've done that using a KK board controller which is the most basic one you can find (it doesn't do altitude stabilisation nor has a GPS)

    Hope this helps


  12. Thanks again, just one last question!

    I have a polulu micro meastro and a hobby king 2.1 flight control board which is similar to your set up I think. My question is in regard to power supply. The usb itself powers the polulu meastro but Im wondering is there an external power supply required for the servo leads going from the polulu meastro to the hobby king flight control inputs if that makes sense?

    Thanks very much all that!

  13. Your flight controller board is already powered by the ESCs you've already connected to it (well I guess). That means you shouldn't have to provide power on the leads that go from the Pololu Maestro to the HK board (unless you're doing tests without powering the ESCs)

  14. Thank you for all that Jacques! Keep up your blog post too, very interesting!

    1. One last thing: if you ever control your HK board from a Maestro (controlled by a Raspberry Pi for eg), don't forget to set the timeout value of the Maestro to something like 1 second and the "home" value for the throttle channel to the min.
      So if you're code crashes, the Pololu watchdog will trigger after 1 sec and cut the power...
      If you don't do that, a bug/crash in your code can cause the quadcopter to stay stuck with power and fly away...
      It happened to me and it's pretty terrifying!
      Good luck!

  15. hi, your project is nice.. i'm also trying to implement something like this where control is by arduino. but i would like to know the time period and duty cycle of the pwm signal to kk controller.

  16. hi, thanks for your comment. A controller (whether KK or other) usually take a 50Hz PWM signal. That's a period of 20ms. The high value is typically between 1 and 2 ms. More information can be found on the Pololu website:
    Lots of useful resources there.

  17. Hy Jacques!

    Im looking for the part of the wifi communication, could you maybe share some codes or referencies that you used to do your own code ?