Where to position my sonar

I noticed during the last few flights, I noticed that the sonar altitude was not working adequatly.  I started doing research, and looking at the logs, it seems I have too much noise, and looking at the current position, it is obvious (I think) that the noise is coming from the ESC located one inch away from the current location (I read that the sonar should be at least 3 inches from the closest ESC).

Now, I do not have much room in the booms (between the legs and the pops), so I am thinking about moving the sonar to a leg.  Is this a wise option?  Are there better ones?

Here are the charts showing both the sonar and barometer readings...


You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –


  • Nope...
    • Could not get this to work.  I am considering installing AP and then back to AC to start from scratch, but first I am waiting on 3DR to deliver some new cables.  I want to re-solder everything to make sure the issue is not the cable I used.

  • Felipe, did you ever get this figured out? 

  • OK, I am now officially stumped...  Decided to go to an I2C sonar (Maxbotics I2CXL MB1242), and now I just get 0 on the sonarrange...  I double checked everything (connections show 5.08V for power, and 3.26V on the I2C Data port and 0V in the I2C CLK).

    According to the wiki, my settings should be:


    Here are my settings:


    Any ideas?  I really want to get this working...

  • Hello, this is Cody from MaxBotix Inc. I’m glad to support you.

    Traditionally, we do not recommend the MB1040 for use on UAVs. I have reviewed a number of your graphs, and it appears like you issues are more primarily caused by lack of detection rather than noise. 

    In your first graph, the sensor appeared to be outputting max range and when it jumped down it was much more accurate. As the jumps are leading down to the correct value and not just moving up and down around the correct value, it does appear like an issue of detection. However, in your second chart after about 2 minutes you do appear to have an issue with noise as we can see that there is a more random appearing set of readings. I do not, as of now, know what caused that. Please note the following for your issue on detection. Additionally, please let me know if issues like the noise you presented at the beginning, appear later after trying to fix your initial issue. 

    Traditionally, we recommend the MB1240 as it has much greater ability to reliably range in turbulent and noisy conditions surrounding UAVs. It should provide much better detection than the MB1040. If detection issues persist a more sensitive sensor from the same line may help such as the MB1230, which both have excellent noise rejection and better detection capacity. You can view both sensors at the following links: 

    MB1240 product page: http://maxbotix.com/Ultrasonic_Sensors/MB1240.htm 
    MB1230 product page: http://maxbotix.com/Ultrasonic_Sensors/MB1230.htm 

    As a last note feel free to contact us directly for more support.

    • Hi, Cody.   Thanks for your reply.  I think I will give the MB1240 a shot.  The odd thing is that I got this sensor from the same people that sold me the drone (3D Robotics).  How close can I install the sensor to an ESC considering the MB1240?  If I can install it close, I can probably use the original mounting place (I had 3D printed a mounting bracket on the rear leg, but the sensor ended up being 1.5" from an ESC), which, if possible, I would like to use because it means I can still fold the legs of the Y6...  If not, I would modify the current mounting for the MB1240 (it has that big thing sticking out the back which my sensor does not have)

    • 3702696038?profile=originalJust for reference, here is the takeoff part of my last flight...  I already ordered the MB1240, but I figured I'd give it another go just in case.  In any case, it seems that it does read altitude, but it gets some sort of spikes for some reason (notice that after take off, the minimum altitude reading is correct).

    • OK, I am officially stuck; I replaced the sonar with the Macbotix MB1240, and now all I get is a reading of 2.87 to 3.208V jumping all over the place randomly regardless of altitude.  This is without motors running, mind you.

      At first I thought it had to do with the resistor (the previous sonar did not require a resistor to have accurate readings with the motors off), so I soldered the resistor in the red line as statedhere, but even after doing so, I still get the same results.

      For reference, these are my settings in MP:

      3702789602?profile=originalAny ideas on how to get the sonar working properly?

    • I wish I did, but will at least keep the thread going because I'm interested in how you get things working.

  • Actually, I am using a shielded cable (from a USB cable I had laying around). I will give their cable a shot, though...
This reply was deleted.