Home        Store        Docs        Blog

BAR02 for ESP32


(Adnan Sabbir) #1

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

(Jacob) #2

Hi, please do not use 5V on SDA/SCL with the Bar02 sensor; it will damage the sensor.
Can you try adding external pullup resistors to pull the SCL/SDA lines to 3.3V? The Bar02 does not have on-board pullups, lots of other i2c modules like the bmp280 will have these on-board. The Arduino has internal pullups. The esp32 might have them, but you should make sure they are enabled (and still also try external pullups).


(Adnan Sabbir) #3

But, ESP32 gives 3.3V, it doesn’t have 5V pin.
So, there is no way I can use 5V for BAR02


(Jacob) #4

I’m just making sure


(Adnan Sabbir) #5

Yeah, I thought I can. But, there is no 5V in ESP32.


(Jacob) #7

I think we might have an ESP32 that we can test with @patrickelectric.