Waterproofed MaxBotix Sonar w/ Arduino

In order to get a better picture of the environment the submersible is working in we will be adding sonar sensors to different parts of the submersible. These sonars will not only be able to sense the submersible's altitude from the sea floor, but also any unidentified objects in its blind spots. After doing some research on different sensors we settled on using the XL-Series MaxBotix sonar with a 10 meter range. A picture of the sonar is below:

Before we setup the Sonar, there are a few things we should cover:

  1. You should first read the data sheet to get acquainted with the sensor. 
  2. From the data-sheet find the specific mV/cm or µS/cm (for analog and digital readings)
  3. Realize that this sonar will NOT detect objects closer than 20 cm. With the sealant we used this was altered to 31 cm≈1 foot (µS/cm constant changed respectively).
  4. Using the Analog option on this sensor will only give a max of 700 cm
  5. For waterproofing (rather than just water resistance) the transducer needs to be sealed. To do this we used a silicone sealant. This allows the transducer to work while still giving accurate readings. 
  6. In water sound will travel approximately 4 times faster (will be different in salt water!). This means that we will get 4 times the max distance, but also 4 times the min distance. Unfortunately this does not give us the close quarters detection we were hoping for, but will work fine for a shallow-water altimeter.   
    • Max: ≈ 40 meters         Min: ≈ .8 meters

To seal the sonar spread the silicone sealant (clear silicon caulking or RTV derivative) around the edge of the transducer to make sure no water can enter the PVC housing. We did not seal the pin-outs as the threaded PVC housing will allow us to easily make this sensor module, thus no need for waterproofing. Our sealed transducer is pictured below:

Next is the code. We used an Arduino to read the pulses coming from the sensor. Using the information we found on the datasheet above each pulse read by the Arduino will be divided by 58uS giving a specific distance in cm (changed for sealed sensor). We then multiplied this by 4 (which is roughly the amount of times faster sound travels through water than air) to get our distance in an underwater environment.

MaxBotix also recommends using a median or mode test to ensure accurate readings. To use the mode test store an odd number of values into an array (we used 9). Then use the Bubble Sort algorithm to sort values from least to greatest. Pull out he 5th value (arr[4]) and you have your median! An image of the code printing to the Arduino's serial console is below:

The code can be found here in the MaxBotix_Sonar folder.

Unfortunately this sensor did not have the short-range capabilities we were hoping for (our fault for not reading the data sheet more closely...), but will, as we said above, work perfectly for a 40-meter altimeter.

Although the sealant skewed our values we were able to account for that by adding our own constant. Similarly we accounted for the speed of sound by using the density of different liquids.


  1. I am in group trying to do a similar thing, and I am curious as to how you found your constant that you added to account for the silicone sealant?

  2. Hello, this is Cody from MaxBotix. While underwater ranging is not one of our supported applications, please feel free to reach out to us directly if you have any questions about our sensors.

    Ultrasonic Sensor Selection Guide: http://www.maxbotix.com/SelectionGuide/Selection-Guide.htm