Updated MS5837 Library to add support for the MS5837_30BA Sensor.
Dependents: AUV_depth_sensor_072319
Diff: MS5837.cpp
- Revision:
- 3:128270625e55
- Parent:
- 2:365c8caabc0e
- Child:
- 4:d9ba4ce3e1d8
--- a/MS5837.cpp Tue Jul 17 16:35:51 2018 +0000 +++ b/MS5837.cpp Tue Jul 23 13:14:46 2019 +0000 @@ -97,27 +97,39 @@ D2 = MS5837ReadADC(); // read the temperature value //printf("D1 = %d\n", D1); /* calculation according MS5837-01BA data sheet DA5837-01BA_006 */ - dT = D2 - ((uint32_t)C[5]* 256); - OFF = (int64_t)C[2] * (1<<17) + ((int64_t)dT * (int64_t)C[4]) / (1<<6); - SENS = (int64_t)C[1] * (1<<16) + ((int64_t)dT * (int64_t)C[3]) / (1<<7); + dT = D2 - ((uint32_t)C[5]* 256l); + //OFF = (int64_t)C[2] * (1<<17) + ((int64_t)dT * (int64_t)C[4]) / (1<<6); //BAR02 + //SENS = (int64_t)C[1] * (1<<16) + ((int64_t)dT * (int64_t)C[3]) / (1<<7); //BAR02 + OFF = (int64_t)C[2] * (1<<16) + ((int64_t)dT * (int64_t)C[4]) / (1<<7); //BAR30 + SENS = (int64_t)C[1] * (1<<15) + ((int64_t)dT * (int64_t)C[3]) / (1<<8); //BAR30 temp = 2000 + ((int64_t)dT * C[6]) / (1<<23); press = (((int64_t)D1 * SENS) / (1<<21) - OFF) / (1<<15); + //if((temp/100)<20){ //Low temp + // //Serial.println("here"); + // Ti = (11*int64_t(dT)*int64_t(dT))/(34359738368LL); + // OFFi = (31*(temp-2000)*(temp-2000))/8; + // SENSi = (63*(temp-2000)*(temp-2000))/32; + //} if((temp/100)<20){ //Low temp //Serial.println("here"); - Ti = (11*int64_t(dT)*int64_t(dT))/(34359738368LL); - OFFi = (31*(temp-2000)*(temp-2000))/8; - SENSi = (63*(temp-2000)*(temp-2000))/32; + Ti = (3*int64_t(dT)*int64_t(dT))/(8589934592LL); + OFFi = (3*(temp-2000)*(temp-2000))/2; + SENSi = (5*(temp-2000)*(temp-2000))/8; } + OFF2 = OFF-OFFi; //Calculate pressure and temp second order SENS2 = SENS-SENSi; temp = (temp-Ti); - press = (((D1*SENS2)/2097152l-OFF2)/32768l); + //press = (((D1*SENS2)/2097152l-OFF2)/32768l); //BAR02 + press = (((D1*SENS2)/2097152l-OFF2)/8192l); //BAR30 T_MS5837 = (float) temp / 100.0f; // result of temperature in deg C in this var - P_MS5837 = (float) press / 100.0f; // result of pressure in mBar in this var + //P_MS5837 = (float) press / 100.0f; // BAR02 result of pressure in mBar in this var + P_MS5837 = (float) press / 10.0f; // BAR30 result of pressure in mBar in this var + }