Feb 142013
 February 14, 2013  Posted by  Add comments

HefnyCopter has brought altitude hold capabilities to the KK2.0 flight controller using an HC-SR04 Sonar! As you can see from the video above, it appears to do an amazing job. There are limitations to using a sonar for altitude hold. It only works up to 4 meters and it maintains altitude with the terrain. It is more common to use a barometer for altitude hold. It looks like it will be fun to experiment with this firmware realizing it is still in the process of being developed.

HefnyCopter Firmware

HefnyCopter is firmware written for the KK2.0 by MHefny as an alternative to the standard firmware that comes loaded on the board. It can be easily loaded using the LazyZero KKMulticopter Flashtool and a USBasp AVR Programming Device for ATMEL proccessors. Here are the pins to connect the USBasp to the KK2.0.

I have yet to try this firmware, but ordered an HC-SR04 Sonar off ebay that ships from the USA. It was under five bucks and should be here in a few days. I am planning on giving it a try and doing a post on the detailed steps I follow in my attempt to implement altitude hold.

HefnyCopter has lots of other cool features and I am really excited about giving it a try. Here is a list of features that are also listed on the HefnyCopter website:

  • Sonar altitude hold
  • Buddy mode allows two tx/rx for training a friend on a quadcopter(click here to see a video)
  • Switch quadcopter mode from +Quad to X-Quad without changing board orientation
  • Fewer wires
  • New stabilization system
  • Auto disarming feature
  • Buzzer to find a lost quadcopter
  • Transmitter sticks can be used to control lcd buttons

Here is an RCGroups thread where MHefny discusses the his firmware and a link to the HefnyCopter manual.


  12 Responses to “HefnyCopter brings Altitude Hold to the KK2.0 Flight Controller”

  1. how i connect the motors for a tricopter please ? thanks

  2. Really a nice job!

    Could you specified connections between sonar and KK2, please?


  3. http://www.youtube.com/watch?v=p72Twm4JVpU

    This is my latest version and ultrsonic is finally works well … especially on hard surface :)

    • Hi Mohammad,
      Your videos are quite impressive. I wanted to give a go with it, but I have not been very succesfull.
      I upgraded the KK2.0 with the latest firmware from you as listed on the Lazytool application on the nigth of april 2.
      the upgrade went fineand could see the menu, however, when I made the connections and powered it from the battery all I got was an (illuminated) blank screen.
      I removed all connection but motor 1 ESC (the only one with a BEC) and stilll a blank screen.
      When powered form the USBasp AVR it boots just fine, so I guess it has a problem with the Turnigy Multistar ESCs.
      One more question.
      From the connection diagram (http://www.hefnycopter.net/index.php?option=com_content&view=article&id=24:connecting-sonar-altitudehold&catid=13&Itemid=135) it is not very clear where I should connect the Sonar
      I suppose Sonar In goes to xBee In signal pole, Sonar Out to xBee Out Signal Pole, Sonar GND to xBee In Negative Pole (in pink in the picture) and 5v to Xbee In Positive Pole (in yellow in the picture).
      Or should the Sonar In be connected to theTrig Signal Pole, the Sonar Out to the Echo signal pole and GND to any negative pole and +5v to any Positive pole of that rail?

      Many Thanks in advance,


  4. Dear OddCopter,

    Here is a new demo link http://www.youtube.com/watch?v=p72Twm4JVpU
    for version 0.9.7 …. it has better sonar handling logic.

    Best Regards,
    M. Hefny

    • Hello

      Trully apreciate your job and admires you.
      Is there any possibility for a firmware that can have function to avoid collision in proximity flight ?
      Mean to be able to choose…ALT hold or obstacle avoidance setup for proximity flight.


  5. Very nice article … I hope you like the firmware.

    Best Regards,
    M. Hefny

    • I too ordered the HC-SR04 for my yet to be installed KK2.0. I’m having too much fun with my tricopter and the old kk board w/lazy zero acro firmware. I look fwd to setting up a quad with sonar alt hold. Thanks for sharing Britt and Hefny. I don’t log in that often but always check oddcopter for developing subjects. I’ve yet to be disappointed.

      • Hey, thanks madgadget, for the nice compliment. All the credit goes to MHefny. I received my sonar today, so I am hoping I can get something together with it soon!

        • I released a new version yesterday 0.9.5
          I added ALTHLD mode that register absolute altitude….
          pls check this video

          I used I & D and left P as ZERO … however I encourage trying other values and share results… I am still working on it to mix ACC-Z with SONAR for better results.

          Thanks for being interested in HefnyCopter firmware.
          M. Hefny

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>