Hi,
I am using ESP32 for an IoT device that collected data underwater. I am also using Bar02 Ultra High Resolution 10m Depth/Pressure Sensor for a measuring the depth and temperature.
For other I2C pressure sensors like BMP280, if the device is not found, an error is given. But for BAR02 no error is given but only one data is shown
Altitude: 44307.70 m above mean sea level
Pressure: 0.00 mbar
Temperature: 20.00 deg C
Depth: -10.36 m
I guess the i2c bus hangs. I can use 3.3v or 5V. I tried both but it did not work. The code I used is from Blue Robotics example code
#include <Wire.h>
#include "MS5837.h"
MS5837 sensor;
void setup() {
Serial.begin(9600);
Serial.println("Starting");
Wire.begin();
sensor.setModel(MS5837::MS5837_02BA);
sensor.init();
sensor.setFluidDensity(997); // kg/m^3 (997 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);
}