Bar High-Resolution Depth/Pressure Sensors Guide
The Bar High-Resolution Depth/Pressure Sensors measure pressure, depth, and temperature for underwater applications. The Bar02 is designed for shallow water with very high resolution, while the Bar30 is suited for deeper use up to about 300 meters. Both connect over I²C and are mounted through a watertight enclosure, so the sensing face is exposed to the water.
This guide will walk through installation, wiring, and setup.
Installing the Bar Sensor
The Bar sensor should not be fully submerged on its own. It is designed to be installed through a flat mounting surface, such as an enclosure or case. A rubber O-ring sits in a groove on the underside of the sensor bulkhead. When the bulkhead is installed and tightened, the O-ring is compressed against the surface, creating a watertight seal.

Bar sensor installed through an enclosure end cap.
The Bar sensors use the M10 bulkhead penetrator form factor and can be installed in any M10-size hole in a Blue Robotics Watertight Enclosure, Watertight Box, or other device.
Installation Procedure
1. Inspect the included O-ring; it should be clean and free of dents, cuts, or damage.
2. Apply a thin layer of silicone grease (such as Molykote 111) to the O-ring and place it in the groove on the underside of the bulkhead.

3. Check the installation port hole; the area around the hole should be clean and free of dust, dirt, hair, scratches, or debris.
4. Follow the steps for the type of hole you’re working with:
For unthreaded holes:
- Insert the bulkhead into the hole and secure it with the included nut on the opposite side.
- Tighten by hand until finger-tight, then use an M10 bulkhead wrench (or 16 mm wrench) to fully tighten.
- When properly installed, the bulkhead should not rotate, and you should not be able to loosen it by hand
For threaded holes:
- Thread the bulkhead directly into the hole until finger-tight.
- Do not use the included nut.
- Use an M10 bulkhead wrench (or 16 mm wrench) to fully tighten.
- When properly installed, the bulkhead should not rotate, and you should not be able to loosen it by hand.
Making an Installation Hole
You can also create your own hole to install the Bar sensor. The mounting surface must be:
- Flat: so the O-ring can seat properly. A curved or uneven surface will not seal.
- Smooth: rough or textured surfaces will not seal.
When making a hole, you can choose either an unthreaded clearance hole or a threaded hole:
- Unthreaded Hole: Drill a hole 10.0–10.2 mm in diameter.
- Threaded Hole: Drill an 8.5 mm pilot hole, then tap it with an M10x1.5 thread tap.
Wire Connections
The Bar sensors communicate via I²C, making them compatible with many devices. General wiring instructions as well as device-specific instructions for Arduino, Raspberry Pi, Navigator, and Pixhawk are provided in the following sections.
General Connections
The Bar sensor wires terminate in a 4-position JST GH connector. The pinout is shown below.

Connecting Power:
- Connect the red (Vin) wire to 2.5–5.5 V.
- Connect the black (GND) wire to ground.
Connecting SDA and SCL:
Connect the sensor to your device’s I²C bus:
- Connect the white SDA wire to the device’s SDA pin.
- Connect the green SCL wire to the device’s SCL pin.
These lines use 3.3 V logic:
- If your device also uses 3.3 V logic, you can connect the lines directly.
- If your device uses 5 V logic (like some Arduinos), you must use a logic level shifter to translate the data signals from one voltage to the other. ⚠️ Do not try to connect the sensor’s SDA and SCL lines directly to a 5 V device; this will damage the sensor.
Arduino Uno
The Arduino Uno (and many other Arduino boards) uses 5 V logic levels, so you’ll need a logic level converter to communicate with a 3.3 V device like the Bar sensor.
You’ll also need four male-to-female jumper wires.
1. Connect the Bar sensor to the level converter using the JST GH connector on the 3.3V side.

2. Connect the level converter pins on the 5V side to the Arduino using the jumper wires (the pin labels are on the back of the board):
- +5V → Arduino Uno 5 V power output
- SDA → Arduino Uno SDA pin (A4)
- SCL → Arduino Uno SCL pin (A5)
- GND → Arduino Uno GND pin

Jumper wire connections on the Level Converter board.

Jumper wire connections on an Arduino
Raspberry Pi
Raspberry Pi computers use 3.3 V logic, so the Bar sensors can connect to it directly without a logic level converter. The Raspberry Pi GPIO header pinout is provided below, sourced from raspberrypi.com

1. Connect the red Vin wire to the Raspberry Pi 3V3 or 5V power pin.
2. Connect the black GND wire to a Raspberry Pi ground pin.
3. Connect the white SDA wire to the Raspberry Pi SDA pin (board pin 3).
4. Connect the green SCL wire to the Raspberry Pi SCL pin (board pin 5).
Navigator Flight Controller
Connect the Bar sensor to either one of the two I²C ports on the Navigator.

Pixhawk Autopilot
Most current Pixhawks use JST GH connectors, and the Bar sensor can connect directly to the I²C port. Some older Pixhawk models use DF-13 connectors instead of JST GH. In this case, use the JST GH to DF13 Adapter to connect the sensor to the Pixhawk.

Software Setup
ArduSub Vehicles
The Bar02 and Bar30 use the MS5837 pressure sensor. In ArduSub, this requires the MS5837 bit to be enabled in the BARO_PROBE_EXT parameter so the sensor can be detected correctly.
- Pixhawk-based systems require this bit to be enabled for the sensor to be detected.
- Navigator systems may detect the sensor without this parameter enabled, but confirming the setting ensures consistent behavior across platforms and future firmware updates.
To enable the MS5837 driver:
1. Open BlueOS and navigate to Autopilot Parameters.
2. Use the search bar to locate the BARO_PROBE_EXT parameter.

3. BARO_PROBE_EXT is presented as a list of driver options, making it easy to see which barometer drivers are enabled (multiple can be enabled at once). Enable MS5837.

4. Apply changes and reboot if prompted.
View Depth in Cockpit
1. Open Cockpit. The depth value is usually displayed as a mini widget in the bottom bar.

2. If depth is not displayed, expand the sidebar menu on the left side of the screen and choose Edit Interface.

3. In the editing view, choose Mini for the widget type. Scroll through the mini widgets until you find Depth Indicator. Drag it onto the bottom bar to add it.

View Depth in QGround Control
1. Open QGroundControl. The depth value is usually displayed in the Telemetry Panel.

2. If the depth is not visible, hover over the Telemetry panel and select the pencil icon. Select an existing telemetry parameter to replace, or select the + button on the right or bottom of the panel to add a new row or column.


3. Select the parameter you want to change. A Value Display box appears, where you will select AltitudeRelative under the Vehicle category.

4. When finished, click Close, then click the padlock icon to lock your changes.
Code Examples
Example code for Arduino and Raspberry Pi are shown below.
Arduino
1. Install the BlueRobotics MS5837 Arduino Library:
- Open Library Manager in the Arduino IDE, search for “BlueRobotics MS5837,” and click Install
- Or download the ZIP from GitHub, unzip it, and place the folder in your Arduino/libraries folder
2. Open an example sketch from the library or use this example:
#include <Wire.h>
#include "MS5837.h"
MS5837 sensor;
void setup() {
Serial.begin(9600);
Wire.begin();
sensor.setModel(MS5837::MS5837_30BA); # Change to MS5837::MS5837_02BA if using Bar02
sensor.init();
sensor.setFluidDensity(997); // kg/m^3 (997 freshwater, 1029 seawater)
Serial.println("Starting");
}
void loop() {
sensor.read();
Serial.print("Pressure: ");
Serial.print(sensor.pressure());
Serial.println(" mbar");
Serial.print("Temperature: ");
Serial.print(sensor.temperature());
Serial.println(" deg C");
Serial.print("Depth: ");
Serial.print(sensor.depth());
Serial.println(" m");
Serial.print("Altitude: ");
Serial.print(sensor.altitude());
Serial.println(" m above mean sea level");
delay(1000);
}
3. Upload the sketch to the Arduino.
4. Open the Serial Monitor at 9600 baud to view live pressure, depth, and temperature readings.
Raspberry Pi
This example uses the BlueRobotics MS5837 Python Library. Please check out the repository page for full instructions.
import ms5837
import time
sensor = ms5837.MS5837_30BA() # Change to MS5837_02BA if using Bar02
if not sensor.init():
print("Sensor could not be initialized")
exit(1)
while True:
if sensor.read():
print(("P: %0.1f mbar %0.3f psi\tT: %0.2f C %0.2f F") % (
sensor.pressure(),
sensor.pressure(ms5837.UNITS_psi),
sensor.temperature(),
sensor.temperature(ms5837.UNITS_Farenheit)))
else:
print("Sensor read failed!")
exit(1)
Troubleshooting
| Issue | Possible causes | Steps to troubleshoot |
|---|---|---|
| Depth sensor not recognized, no readings, or error reported in BlueOS or QGroundControl | • The sensor is not being detected • Loose or damaged wiring • Faulty sensor or connector • Software not picking up the sensor | 1. Check the connection: Make sure the sensor is fully seated in the correct port on the Navigator and that the connector clicks in cleanly. 2. Inspect the cable: Make sure the sensor is fully seated in the correct port on the Navigator and that the connector clicks in cleanly. 3. Inspect the cable: Look for bent pins, corrosion, or any damage on the cable or housing. A bad pin will prevent the sensor from showing up. 4. Restart BlueOS and power cycle the system: Sometimes the sensor is not detected at boot. A full restart can bring it back. 5. Confirm software versions: Make sure BlueOS, ArduSub, and QGroundControl are up to date. Older versions may not consistently detect newer hardware. 6. Test another port: Move the sensor to a different port. If it shows up on another port, the original port may have an issue. 7. Swap in another sensor if available: If a second sensor works and the original does not, that points to a faulty sensor or cable. 8. If nothing shows up on any port: At this point, the sensor is most likely bad, or the cable is damaged. Reach out to Support with photos and a description of what you have tested. |
| Initialization error or connection problem when used with a microcontroller | • SDA and SCL lines are swapped • Bad or inconsistent jumper wires • Wires are too long, causing a signal drop • Wrong logic level voltage • Logic level converter not powered correctly | 1. Check SDA and SCL wiring: Make sure SDA goes to SDA, and SCL goes to SCL. If you are unsure, swap them. It will not damage the sensor. 2. Test or replace jumper wires: Bad quality jumpers have terrible electrical connections. Check them for continuity, or swap in known-good ones. 3. Shorten the wiring: Long I2C runs can cause the sensor to fail initialization. Keep the wires as short as possible. 4. Confirm logic voltage: Use a 3.3V logic level converter for SDA and SCL connections. If it were connected directly to 5V, it may already be damaged. 5. Check the level converter: If you are using an I2C level shifter, make sure the 5V rail on the converter is actually powered. 6. Contact support if the issue persists: Reach out to Support with photos and a description of what you have tested. |
Help and Feedback
- If you need help using the Bar sensor, reach out to our support team using our help center.
- We’re always working to make our guides, software, and user experience even better. If you have any ideas on how we can improve this guide, feel free to let us know here.

