Reading Bourns bps120 differential pressure sensor to get airspeed

After the usual fussing, I seem to have made Robert Rau’s MS4525 code work. See my code at bottom.

I do not understand what what these functions do:

const int16_t MS4525FullScaleRange = 1; // 1 psi
const int16_t MS4525MinScaleCounts = 1638;
const int16_t MS4525FullScaleCounts = 14746;

const int16_t MS4525Span=MS4525FullScaleCounts-MS4525MinScaleCounts;

const int16_t MS4525ZeroCounts=(MS4525MinScaleCounts+MS4525FullScaleCounts)/2;

It seems to me that this device emits a 14 bit sequence which decodes to a PSI measurement.

It is a 1 psi sensor so that it obvious

The Bourns BPS 120 data sheet shows only a MAX of 16384 which I assume is the Bourn version of the 14746 shown in the code, but if they don’t show the MinScaleCounts what should I use?

I have another calibrated airspeed sensor so I can fly this one with the other and see how close it is. Ground testing suggests it might be pretty close.
I would be delighted if someone detects something stupid in here and let’s me know.

 /*
 * much modfied sensor reader  6/13/2020 jaf
 */
#include <Wire.h>      // Arduino I2C library
#include <stdint.h>    // Standard C, Allows explicit data type declaration.


const uint8_t MS4525DAddress = 0x28;
const int16_t MS4525FullScaleRange = 1;  // 1 psi
const int16_t MS4525MinScaleCounts = 1638;
const int16_t MS4525FullScaleCounts = 14746;

const int16_t MS4525Span=MS4525FullScaleCounts-MS4525MinScaleCounts;

const int16_t MS4525ZeroCounts=(MS4525MinScaleCounts+MS4525FullScaleCounts)/2;

//  fetch_pressure is a function to do the I2C read and extraction of the three data fields
//
byte fetch_pressure(uint16_t &P_dat)
{
 byte _status;
 byte Press_H;
 byte Press_L;

 Wire.requestFrom(MS4525DAddress, static_cast<uint8_t>(2), static_cast<uint8_t>(true));  //Request 2 bytes, 2 pressure/status 
 Press_H = Wire.read();
 Press_L = Wire.read();
 
 
 _status = (Press_H >> 6) & 0x03;
 Press_H = Press_H & 0x3f;
 P_dat = (((uint16_t)Press_H) << 8) | Press_L;

  return _status;

}



//  setup is the main function to setup the diagnostic serial port and the I2C port
void setup()
{

 Serial.begin(115200);
 Wire.begin();
 // wait until serial port opens for native USB devices
 while (! Serial)
 {
   delay(1);
 }
 
 Serial.println("MS4525DO test");

}


void loop()
{

 byte _status;    // A two bit field indicating the status of the I2C read
 uint16_t P_dat;  // 14 bit pressure data
 float psi;
 float mps;
 float mph;
 
   _status = fetch_pressure(P_dat);

   switch (_status)
   {
     case 0:
       //Serial.println("Ok ");
       break;
     case 1:
       Serial.println("Busy");
       break;
     case 2:
       Serial.println("Slate");
       break;
     default:
       Serial.println("Error");
       break;
   }

   psi=(static_cast<float>(static_cast<int16_t>(P_dat)-MS4525ZeroCounts))/static_cast<float>(MS4525Span)*static_cast<float>(MS4525FullScaleRange);
   Serial.print("psi:");
   Serial.println(psi);

   mps=sqrt(2*(psi*6894.76)/1.225);
   mph=mps*2.23694;
   
   Serial.print("mph: ");
   Serial.println(mph);
delay(1000);
}

Never mind. I read Honeywell's excellent guide on I2C and their pressure sensors which emit data which must be transformed via a transfer function to reveal PSI pressure in my case.

Bourns publishes their transfer function in the device data, and all I need to do is use their funtiobn rather than Honeywell's or the MS4525 funtion on which my code was based.

Yippee.