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.

<br />
import ms5837<br />
import time</p>
<p>sensor = ms5837.MS5837_30BA() # Default I2C bus is 1 (Raspberry Pi 3)</p>
<p># We must initialize the sensor before reading it<br />
if not sensor.init():<br />
        print "Sensor could not be initialized"<br />
<p># Print readings<br />
while True:<br />
        if<br />
                print("P: %0.1f mbar  %0.3f psi\tT: %0.2f C  %0.2f F") % (<br />
                sensor.pressure(), # Default is mbar (no arguments)<br />
                sensor.pressure(ms5837.UNITS_psi), # Request psi<br />
                sensor.temperature(), # Default is degrees C (no arguments)<br />
                sensor.temperature(ms5837.UNITS_Farenheit)) # Request Farenheit<br />
        else:<br />
                print "Sensor read failed!"<br />
                exit(1)<br />


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!