Hi, everyone! I’m using a Bar30 depth sensor from BlueRobotics connected to an Arduino. When I power it up, it gives coherent pressure and depth readings, both in and out of water. The problem is that over time, these values start to oscillate either increasing or decreasing, as if losing reference as time passes. Has anyone experienced this or have any suggestions to stabilize these readings? Worth mentioning, I tested on two different Arduinos (Uno and Pro Micro), both at 5V and 3.3V. I also tested both in dry conditions and underwater, and the oscillation persists.
Hi @AdalcirJr -
Welcome to the forums!
Can you share the code you’re running on the Arduino, if different than our provided example?
An idea of the magnitude and time-scale o the oscillations you’re seeing would be helpful as well. Have you had the sensor immersed in water for more than 24 hours continuously?
I performed tests using both my own program and the official Arduino library example, and I observed the same behavior in both cases.
From what I have noticed, when the sensor is submerged, the depth reading shows a gradual drift, decreasing by approximately 0.01 m per minute, even while the sensor remains completely stationary. Out of the water, the same behavior seems to occur, but at a slower rate.
We have not left the sensor submerged continuously for more than 24 hours. The longest tests we performed lasted approximately 2 hours.
#include <Wire.h>
#include "MS5837.h"
MS5837 sensor;
void setup() {
Serial.begin(9600);
Serial.println("Starting");
Wire.begin();
// Initialize pressure sensor
// Returns true if initialization was successful
// We can't continue with the rest of the program unless we can initialize the sensor
while (!sensor.init()) {
Serial.println("Init failed!");
Serial.println("Are SDA/SCL connected correctly?");
Serial.println("Blue Robotics Bar30: White=SDA, Green=SCL");
Serial.println("\n\n\n");
delay(5000);
}
sensor.setModel(MS5837::MS5837_30BA);
sensor.setFluidDensity(997); // kg/m^3 (freshwater, 1029 for seawater)
}
void loop() {
// Update pressure and temperature readings
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);
}
Hi @AdalcirJr -
While the precision of the Bar30 is 2mm, the absolute accuracy of the sensor is ± 200 mbar across the full 30-bar range (equivalent to ± 204 cm in freshwater.) This can manifest in a drifting value - does the reading oscillate both up and down, or if only going in one direction, how far does it drift before stabilizing?
The reading does not oscillate around a fixed value; instead, it continuously drifts in a single direction. During our approximately 2-hour underwater test, the value never stabilized at any point and only continued to decrease over time.
We observed this behavior with multiple Bar30 sensors, which suggests it is not limited to a single unit.
While submerged, we measured a drift of approximately 0.01 m per minute, even with the sensor remaining completely stationary.