Guide to Using the Bar30 with a Raspberry Pi

By Rusty


The Bar30 pressure sensor is a pressure sensor designed to be used underwater at pressures up to 30 bar, or around 300 meters depth in water. It communicates via I2C and comes with a 4-pin DF-13 connector that is compatible with the Pixhawk autopilot, the Level Converter and other microcontrollers.

Example Code

This example uses the BlueRobotics MS5837 Python Library with the sensor connected to a Raspberry Pi. The Raspberry Pi uses 3.3V logic levels on the I2C pins, so a logic level shifter is not required.

import ms5837
import time

sensor = ms5837.MS5837_30BA() # Default I2C bus is 1 (Raspberry Pi 3)

# We must initialize the sensor before reading it
if not sensor.init():
        print "Sensor could not be initialized"

# Print readings
while True:
                print("P: %0.1f mbar  %0.3f psi\tT: %0.2f C  %0.2f F") % (
                sensor.pressure(), # Default is mbar (no arguments)
                sensor.pressure(ms5837.UNITS_psi), # Request psi
                sensor.temperature(), # Default is degrees C (no arguments)
                sensor.temperature(ms5837.UNITS_Farenheit)) # Request Farenheit
                print "Sensor read failed!"


Rusty is the founder and CEO of Blue Robotics. His background is in engineering but he likes to be involved in everything at Blue Robotics!