Bar100 Pressure Sensor Installation Guide and Sample Code



Installation

Step 1: Lubricating the O-ring

Use a small amount of silicone grease on the O-ring for lubrication and place it in the groove of the Bar100 Pressure Sensor.

Step 2: Installation

Install the Bar100 Pressure Sensor into an endcap and tighten by hand or with a wrench.

Example Code

Arduino

This example uses the BlueRobotics KellerLD Library with the connected sensor. The example reads the sensor and prints the resulting values to the serial terminal.

Please remember to use a logic level converter, such as this one, to convert Arduino 5v levels to 3.3v!

If you’ve never used Arduino before, we suggest checking out some tutorials!

#include <Wire.h>
#include "KellerLD.h"

KellerLD sensor;

void setup() {
  
  Serial.begin(9600);
  
  Serial.println("Starting");
  
  Wire.begin();

  sensor.init();
  sensor.setFluidDensity(997); // kg/m^3 (freshwater, 1029 for seawater)
}

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);
}

Python

This example uses the BlueRobotics KellerLD 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.

from kellerLD import KellerLD
import time

sensor = KellerLD()

if not sensor.init():
  print "Failed to initialize Keller LD sensor!"
  exit(1)

print "Testing Keller LD series pressure sensor"
print "Press Ctrl + C to quit"
time.sleep(3)

while True:
  try:
    sensor.read()
    print("pressure: %7.4f bar\ttemperature: %0.2f C") % (sensor.pressure(), sensor.temperature())
    time.sleep(0.2)
  except Exception as e:
    print e