I am using an Arduino Nano to read the pressure data from 2 Bar02 sensors. They are connected via an I2C multiplexer TCA9548A and each sensor has an I2C level converter. I have both sensors out of the water and one seems to be working fine and showing a pressure of 1017 mbar. However, the other sensor reads a negative pressure of -14 mbar. The sensor that reads the correct pressure works fine when connected to either of the level converters, which makes me think that the multiplexer and the level converters are working properly. Does this mean that one of the sensors is faulty? If so, what could cause this? The sensor has not been used before.
It could maybe be incorrectly calibrated, or be faulty? The sensor datasheet doesnāt seem to specify a way to change the calibration, although it does allow you to read the calibration data, and provides a āCyclic Redundancy Checkā (page 13) to verify that the stored calibration data is at least valid (but not necessarily anything about how correct it is).
Iād suggest you start out by checking the CRC, and also comparing the calibration values to those from the working sensor, to see if theyāre at least in a similar range. Also worth seeing how the values change in the water over a known distance - itās precise enough that you should be able to test even just in a cup/bucket of water.
Thanks for the valuable advice. When testing in a cup of water, the non working sensor does not change its values which probably means that the sensor is indeed faulty. I will also look into the CRC. While testing, I noticed what seems to be a tiny hole in the gel. I wonder if it is possible to refill the gel. If so, is there a particular gel that would work?
Unfortunately there isnāt anything mentioned about this in the datasheet, and it doesnāt include any information about which gel is used. Most likely youāll need to get it replaced/refunded. Assuming you bought it from Blue Robotics, you can contact support@bluerobotics.com
Hello from the FUTURE!
I see this post was written in 2021, so I hope there are some updates about your successes.
What version of the Arduino Nano and blue robotics library were you using?
Iām using a NANO 33 BLE and the arduino code says it is unable to compile for this arduino.
The reason for posting here ist that I get a constant negative misreading of precisely 39 cm H2O on serial monitor and on Mission Planner quick tab after MS5837-BA02 calibration. IĀ“m aware of the fact that this not the ArduPilot forum. IĀ“m a new user here so I cant upload the arduino script for the moment. IĀ“ll try do do it later.
In brief: Looking at the bluerobotics website and with assistance from the ArduRover forum I managed to connect the bar02 via an arduino script to a NORA+ FC running ArduRover 4.5.3. The MS5873 test script puts out parameters as exspected on serial monitor. The script reads the baros I2C signal and convertes depth measurements (dont need the rest) to a digital PWM signal (50Hz; duration 1.000 to 2.000 mcrs) - a logic level shifter protects the bar02 SCL and SDA lines from 5V I2C signal of the arduino (PIN A4, A5) - everything has common GND - the PWM signal feeds into a GPIO PIN (62) of the NORA+ FC that is defined as a rangefinder with PWM input.
I conected a digital pressure gauge to the bar02 to check for accuracy - which is linear and precise between an external pressure of + 30 to + 800 and above cmH2O.
Now the tricky part that I havent managed to resolve. At ambient pressure (0 mmH2O) on the gauge the bar02 outputs a depth of minus 39 cm H2O on the serial - its 1.600 cm H2O on the rangefinder in Mp.
I increased pressure manually to 40 cm H2O - readings on MP now are +/- 0 mm H2O. But serial depth values remain 39 cm H2O lower than gauge pressure (I calibrated the gauge) across a pressure range of up to 800 cm H20.
Any ideas in this dedicated forum on how to solve the issue calibration misreading or at least modify the script to compensate the issue.
Hi @U-Boat -
The relative and absolute accuracy specifications of the Bar sensors can be a bit tricky. While the relative accuracy is quite good, the absolute can vary significantly as youāve found. ArduSub handles this by assuming the pressure at start up is ambient atmospheric, and sets that to 0 depth. Thus any increase from that point is tracked with the correct relative accuracy!
Is that approach possible in your application?
Hi Tony - I tried what you describe - up to now I failed to implement this feature into the arduino scetch.Would you mind to take a look at the scetch once I can upload it - as said I m still a newbee without rights to upload files.
Hi Tony thanks for the valuable information on relative and absolute accuracy of the bar sensors. Would be great if you could take a look at the sketch:
#include <Wire.h>
#include "MS5837.h"
MS5837 sensor;
const int pwmPin = 9; // PWM output pin
void setup() {
Serial.begin(9600);
Wire.begin();
sensor.setModel(MS5837::MS5837_02BA); // Change to MS5837_02BA
sensor.init();
while (!sensor.init()) {
Serial.println("Init failed!");
Serial.println("Are SDA/SCL connected correctly?");
Serial.println("Blue Robotics Bar02: White=SDA, Green=SCL");
delay(5000);
}
sensor.setFluidDensity(997); // kg/m^3 (freshwater, 1029 for seawater)
pinMode(pwmPin, OUTPUT); // Set the PWM pin as an output
}
void loop() {
// Update pressure and temperature readings
sensor.read();
// Get depth in meters
float depth = sensor.depth();
Serial.print("Depth: ");
Serial.print(depth);
Serial.println(" m");
// Convert depth to a delay in microseconds
int delayMicros = depth * 1000.0; // 10 us/cm is 1000 us/m
// Manual digital write-based PWM
digitalWrite(pwmPin, HIGH);
delayMicroseconds(delayMicros);
digitalWrite(pwmPin, LOW);
delay(200); // Delay to achieve 5 Hz update rate
}
There is also a description of hardware, wiring and reading depth values into Mission Planner.
Thanks for the context @U-Boat -
It seems youāre reading the sensor data with arduino, converting it to a different signal type, and then reading that with your flight controller? Ouch! I would guess that some level of error is being introduced by converting the signal from digital to āanalogā and back againā¦ as this can introduce noise and other factors as youāve found with integers in that thread.
Modifying the autopilot code to support reading the Bar02 may be the best option? ArduSub is gaining support for this soon, it should be possible to port this to ArduRover?
If the issue is just enabling the sensor for Rover to share values from then I expect that would be reasonably straightforward, since it would largely be around updating compilation checks for ArduSub to include ArduRover. I donāt believe the barometers are typically used much in Rover, so hopefully that wouldnāt require handling nuance between whether the sensor is being used for air or water applications.
There is an open Issue for a more advanced application (measuring boat draft), but no idea if thatās relevant to @U-Boatās application.
Iāve added this to your latest comment in this thread, in a code block. Short files of code and the like donāt need to be included as downloadable attachments