BlueRobotics_MS5837_Library icon indicating copy to clipboard operation
BlueRobotics_MS5837_Library copied to clipboard

Bug: MS5837_30BA26 300 bar sensor detected as 2 bar sensor

Open scuba-hacker opened this issue 1 year ago • 0 comments

I switched from using the current Arduino library version 1.1.1 of MS58357.h/.cpp to head of master (I forked the project) and found that depth was being reported as zero despite being several metres under water. This is for the 300 bar sensor, bought just under a year ago.

It turns out that the model detection code in the init() function is assigning model = MS5837_02BA (value 1) instead of = MS5837_30BA (value 0). I am not calling setModel() anywhere in the client code. It seems that something in the "Read calibration values and CRC" is not working.

The current Arduino library version doesn't have this model check and _model defaults to MS5837_30BA. As a separate issue none of the private member variables are being initialised in the constructor so their values are officially undefined (and fortunately the compiler is setting them to zero automatically). They should be initialised in the constructor to 0, including the C[8] array contents.

scuba-hacker avatar Jan 12 '24 12:01 scuba-hacker