ArduCopter supports the MaxSonar line of sonar sensors for “Terrain Following” while in Loiter or Alt Hold modes. In these modes, the copter will attempt to maintain a constant distance from the ground. The sonar is also used during LAND mode. The copter will slow it’s descent to 50cm/s (configurable with LAND_SPEED parameter) when the sonar detects something below the vehicle.


The recommended sonar is the MaxBotix XL-EZ4 (aka MB1240) which has a 7m range and a narrow beam which helps reduce the chance of interference from other sources of sound at the same frequency.

These other sonar are also supported:

XL-EZL0 (10m range but lower resolution)

HRLV-EZ4 (5m range but higher resolution)

LV-EZ4 (6.5m range, cheaper but less resitant to noise)

We do not yet support I2C based MaxBotix sonars.

Building a cable to reduce sonar noise

As described in this Maxbotix article, you will need to make a special cable which requires:


100uF capacitor

10ohm resistor

3-wire shielded cable

0.1″ crimp connector housing and crimp pins



提示:要进一步了解声纳,可参阅此说明:Sonar Operation on a Multi-Copter–Max Botix

由于多旋翼噪声和振动很大,所以推荐使用此型号声纳: MaxSonar MB1240和 MaxSonar MB1340 (Here!)

噪声和振动较小的飞行器除了上述两种型号外,还可选择XL-MaxSonar EZ0LV-EZ0XL-EZL0(高性能声纳)。


如下图所示:声纳的GND、V+ 、AN(标有数字3的管脚)管脚对应连接到APM2电路板A0端口。



用Mission Planner为PX4指定端口,以接收声纳传感器的信号:依次打开Mission Planner – Configuration – Advanced Params – Adv Parameter List,修改其中的SONAR_PIN参数。


PIN = 11

The “airspeed” pin. Located on a 3 pin DF13 connector on the PX4IO

board, but directly visible to the ADC on the PX4FMU. This pin can

take voltages up to 6.6V (it has an internal voltage divider).

PIN = 12

A general analog input pin. Located on pin 3 of the “FMUSPI” port on the

PX4IO board, this pin is directly visible to the PX4FMU analog input

code. This can take voltages up to 3.3V.

PIN = 13

A general analog input pin. Located on pin 4 of the “FMUSPI” port on the

PX4IO board, this pin is directly visible to the PX4FMU analog input

code. This can take voltages up to 3.3V. It is being worked on and will be included in this section when it is available.




It’s important that the sonar sensor be mounted at least three inches (10cm) away from sources of electrical noise including the ESCs and other interference. One good way is to use a 3DR Sonar mount for quad or hexacopter (the quad version is larger).




2、把连接声纳的3根线(GND、V+ 、AN)缠绕一个磁环后连接主板,或者使用屏蔽线连接声纳和主板。

通过Mission Planner启用声纳

启用声呐需要先把你的APM/PX4连接到Mission Planner,然后:

  • 进入Initial Setup > Optional Hardware > Sonar
  • 勾选“Enable”复选框
  • 从下拉菜单中选择声呐型号



You can test the sonar basically works by connecting your APM/PX4 to the mission planner and then:

  • Go to the Terminal window and press “Connect to APM” or “Connect to PX4″
  • when the prompt appears type test
  • type sonar

The current distanced sensed by the sonar should be displayed. Aim the sonar at targets of different distances (i.e. ceiling, wall, etc) and ensure the numbers change. If they do not then there may be a hardware issue with the sonar or cabling.

You should also hear the sonar clicking very rapidly (10hz) whenever power is applied if you do not hear this then it’s possible that the sonar is defective or is not being powered for some reason.


If when flying you find that your copter bobs up and down it is possible that the default SONAR_GAIN is too high for your copter. Go to the mission planner’s Config/Tuning > Full Parameter List and reduce the SONAR_GAIN parameter from it’s default of 0.2 to 0.1 or even 0.05 and press “Write Params”.
SONAR_GAIN是关于声纳的一个参数,打开地面站,点击Configuration,点选 Advanced Parameter List就能找到它。该值默认为0.2,若你的飞行器较重,或者动力不太足,可以把该值改为0.1。定高模式中,开启声纳且在10米以下高度时,若飞行器上下跳动,把该值减小一些。



对于上述问题,Geir Engebakken的给出了一个解决办法:在声纳的基座上环绕4个10欧姆的电阻,然后用5V电源给这4个电阻供电。原文地址:电阻发热防温差

此篇帖子的一个参与者(Geir Engebakken)给出了解决方法(最初由开发者Olivier ADLER提议),在传感器基座上安装4个10欧姆的电阻,然后用5V电源给这4个电阻供电。


If you are having problems with excessive noise on your sonar as shown in the dataflash log below (sonar is in red, baro is in green)


There are a number of possible causes which should be investigated:

  • 来自电调、舵机、BEC(开关电源式)的电子噪声
  • 电机、电机电源线、电调、Xbee模块的电磁辐射
  • 螺旋桨的机械噪声
  • 电机、螺旋桨的振动等。

NOTE: Please read this tutorial for a comprehensive review Sonar Operation on a Multi-Copter–Max Botix

Questions about this page? Comments? Suggestions? Post to APM Forum! Use the platform specific to your query, and make sure to include the name of the page you are referring to.