PIC16F_SMART_WEATHER_STATION.X/bme280.c
float BME280_readPressure(void)
{
    int32_t adc_P = BME280_read24(BME280_REGISTER_PRESSUREDATA);
    int32_t var1,var2 ;
    uint32_t p ;
    
    
    
  var1 = (((int32_t)t_fine)>>1) - (int32_t)64000;
  var2 = (((var1>>2) * (var1>>2)) >> 11 ) * ((int32_t)cal_data.dig_P6);
  var2 = var2 + ((var1*((int32_t)cal_data.dig_P5))<<1);
  var2 = (var2>>2)+(((int32_t)cal_data.dig_P4)<<16);
  var1 = (((cal_data.dig_P3 * (((var1>>2) * (var1>>2)) >> 13 )) >> 3) + ((((int32_t)cal_data.dig_P2) * var1)>>1))>>18;
  var1 =((((32768+var1))*((int32_t)cal_data.dig_P1))>>15);
  if (var1 == 0) {
    return 0; // avoid exception caused by division by zero
  }
  p = (((uint32_t)(((int32_t)1048576)-adc_P)-(var2>>12)))*3125;
  if (p < 0x80000000) {
    p = (p << 1) / ((uint32_t)var1);
  } else {
    p = (p / (uint32_t)var1) * 2;
  }
  var1 = (((int32_t)cal_data.dig_P9) * ((int32_t)(((p>>3) * (p>>3))>>13)))>>12;
  var2 = (((int32_t)(p>>2)) * ((int32_t)cal_data.dig_P8))>>13;
  p = (uint32_t)((int32_t)p + ((var1 + var2 + cal_data.dig_P7) >> 4));
  return (p/100.0);
    
    
    
    
}
// Returns pressure in Pa as unsigned 32 bit integer. Output value of ?96386? equals 96386 Pa = 963.86 hPa

Returns pressure in Pa as unsigned 32 bit integer. Output value of ?96386.
Returns pressure in Pa as unsigned 32 bit integer . Output value of ?96386 .
float BME280_readPressure(void)
{
    int32_t adc_P = BME280_read24(BME280_REGISTER_PRESSUREDATA);
    int32_t var1,var2 ;
    uint32_t p ;
  var1 = (((int32_t)t_fine)>>1) - (int32_t)64000;
  var2 = (((var1>>2) * (var1>>2)) >> 11 ) * ((int32_t)cal_data.dig_P6);
  var2 = var2 + ((var1*((int32_t)cal_data.dig_P5))<<1);
  var2 = (var2>>2)+(((int32_t)cal_data.dig_P4)<<16);
  var1 = (((cal_data.dig_P3 * (((var1>>2) * (var1>>2)) >> 13 )) >> 3) + ((((int32_t)cal_data.dig_P2) * var1)>>1))>>18;
  var1 =((((32768+var1))*((int32_t)cal_data.dig_P1))>>15);
  if (var1 == 0) {
    return 0; 
  }
  p = (((uint32_t)(((int32_t)1048576)-adc_P)-(var2>>12)))*3125;
  if (p < 0x80000000) {
    p = (p << 1) / ((uint32_t)var1);
  } else {
    p = (p / (uint32_t)var1) * 2;
  }
  var1 = (((int32_t)cal_data.dig_P9) * ((int32_t)(((p>>3) * (p>>3))>>13)))>>12;
  var2 = (((int32_t)(p>>2)) * ((int32_t)cal_data.dig_P8))>>13;
  p = (uint32_t)((int32_t)p + ((var1 + var2 + cal_data.dig_P7) >> 4));
  return (p/100.0);
}
float BME280_readPressure ( void ) { int32_t adc_P = BME280_read24 ( BME280_REGISTER_PRESSUREDATA ) ; int32_t var1 , var2 ; uint32_t p ; var1 = ( ( ( int32_t ) t_fine ) >> 1 ) - ( int32_t ) 64000 ; var2 = ( ( ( var1 >> 2 ) * ( var1 >> 2 ) ) >> 11 ) * ( ( int32_t ) cal_data . dig_P6 ) ; var2 = var2 + ( ( var1 * ( ( int32_t ) cal_data . dig_P5 ) ) << 1 ) ; var2 = ( var2 >> 2 ) + ( ( ( int32_t ) cal_data . dig_P4 ) << 16 ) ; var1 = ( ( ( cal_data . dig_P3 * ( ( ( var1 >> 2 ) * ( var1 >> 2 ) ) >> 13 ) ) >> 3 ) + ( ( ( ( int32_t ) cal_data . dig_P2 ) * var1 ) >> 1 ) ) >> 18 ; var1 = ( ( ( ( 32768 + var1 ) ) * ( ( int32_t ) cal_data . dig_P1 ) ) >> 15 ) ; if ( var1 == 0 ) { return 0 ; } p = ( ( ( uint32_t ) ( ( ( int32_t ) 1048576 ) - adc_P ) - ( var2 >> 12 ) ) ) * 3125 ; if ( p < 0x80000000 ) { p = ( p << 1 ) / ( ( uint32_t ) var1 ) ; } else { p = ( p / ( uint32_t ) var1 ) * 2 ; } var1 = ( ( ( int32_t ) cal_data . dig_P9 ) * ( ( int32_t ) ( ( ( p >> 3 ) * ( p >> 3 ) ) >> 13 ) ) ) >> 12 ; var2 = ( ( ( int32_t ) ( p >> 2 ) ) * ( ( int32_t ) cal_data . dig_P8 ) ) >> 13 ; p = ( uint32_t ) ( ( int32_t ) p + ( ( var1 + var2 + cal_data . dig_P7 ) >> 4 ) ) ; return ( p / 100.0 ) ; }
Returns pressure in Pa as unsigned 32 bit integer.
Returns pressure in Pa as unsigned 32 bit integer .
// avoid exception caused by division by zero
