Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BMP390L doesn't get the pressure value.

    BMP390L doesn't get the pressure value.

    javierrobledo
    Member

    Hi all,

    I have a problem using the BMP390L. I have configurated it correctly following the datasheet and a example project that I have found on this forum. But always the sensor returns me values around 975-977mbar and my atmospheric pressure is 940-945mbar aprox (35mbar of difference is so much). The MSB of the pressure data (reg 0x06) is always returning me the value 0x00. It is normal?

    The measurement of temperature always returns me 1.5ºC more than real temperature, but I can assume this error.

     

    The compensation coefficientes that I get are those seen in the following image, and I think that they are corrects because they are similar with normal values of calibration.

    calib.PNG

    Furthermore, I have been checking the code of temperature and pressure compensation and the script is OK.

     

    Does someone have any idea about why I can not get the right pressure?

     

    Thank you all!

     

    5 REPLIES 5

    Hi Minhwan,

    At this moment I do not have more questions. If you want, let me post the script for if someone has the same problem on the future.

    It is very important works with the correct data types. The struct that I have used is:

    struct BMP390L_calib_data
    {
        double par_t1;
        double par_t2;
        double par_t3;
        double par_p1;
        double par_p2;
        double par_p3;
        double par_p4;
        double par_p5;
        double par_p6;
        double par_p7;
        double par_p8;
        double par_p9;
        double par_p10;
        double par_p11;
        double t_lin;
    	
    };
    
    struct bmp3_reg_calib_data
    {	
        uint16_t par_t1;
        uint16_t par_t2;
        int8_t par_t3;
        int16_t par_p1;
        int16_t par_p2;
        int8_t par_p3;
        int8_t par_p4;
        uint16_t par_p5;
        uint16_t par_p6;
        int8_t par_p7;
        int8_t par_p8;
        int16_t par_p9;
        int8_t par_p10;
        int8_t par_p11;
        int64_t t_lin;
    };

    And the function that works to get the compensation coefficients is the following. (PAY ATTENTION TO '#DEFINE BMP3_CONCAT_BYTES'):

    /**\name Macro to combine two 8 bit data's to form a 16 bit data */
    #define BMP3_CONCAT_BYTES(msb, lsb)             (((uint16_t)msb << 😎 | (uint16_t)lsb)
    
    
    void get_compensation_coefficients(struct BMP390L_state *st)
    {		
    	tUint32 tmp;
    	double potencia; // valores del datahseet que corresponden a la división de las potencias
    	uint8_t i, addr;
            uint8_t reg_data[21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    		
    	struct bmp3_reg_calib_data reg_calib_data;
    	
             //	BMP390L_ReadRegs(regs, 0x31-0x45, 21 registros) - modo BURST para evitar latches en la lectura
            addr = 0x31;
            for (i = 0; i < 21; i++) {
                 PAReadReg_BMP390L(st, 0, 0, addr, (uint32_t) BMP390L_CALIBRATION_SIZE_BYTES, &tmp.all);
                 reg_data[i] = tmp.ui8.byteLow;
                 addr++;
    	}
    	
    	// Appendix datasheet BMP390L
    	potencia = pow(2.0, -8.0);
    	reg_calib_data.par_t1 = BMP3_CONCAT_BYTES(reg_data[1], reg_data[0]);
    	calib_data.par_t1 = ((double)reg_calib_data.par_t1 / potencia);
    	
    	potencia = pow(2.0, 30.0);
    	reg_calib_data.par_t2 = BMP3_CONCAT_BYTES(reg_data[3], reg_data[2]);
    	calib_data.par_t2 = ((double)reg_calib_data.par_t2 / potencia);  
    	
    	potencia =  pow(2.0, 48.0);
    	reg_calib_data.par_t3 = (int8_t)reg_data[4];
    	calib_data.par_t3 = ((double)reg_calib_data.par_t3 / potencia); 	
    	
    	potencia = pow(2.0, 20.0);
    	reg_calib_data.par_p1 = (int16_t)BMP3_CONCAT_BYTES(reg_data[6], reg_data[5]);
    	calib_data.par_p1 = ((double)(reg_calib_data.par_p1 - (16384)) / potencia);
    	
    	potencia = pow(2.0, 29.0);
    	reg_calib_data.par_p2 = (int16_t)BMP3_CONCAT_BYTES(reg_data[8], reg_data[7]);
    	calib_data.par_p2 = ((double)(reg_calib_data.par_p2 - (16384)) / potencia);
    	
    	potencia = pow(2.0, 32.0);
    	reg_calib_data.par_p3 = (int8_t)reg_data[9];
    	calib_data.par_p3 = ((double)reg_calib_data.par_p3 / potencia);
    	
    	potencia = pow(2.0, 37.0);
    	reg_calib_data.par_p4 = (int8_t)reg_data[10];
    	calib_data.par_p4 = ((double)reg_calib_data.par_p4 / potencia);
    	
    	potencia = pow(2.0, -3.0);
    	reg_calib_data.par_p5 = BMP3_CONCAT_BYTES(reg_data[12], reg_data[11]);
    	calib_data.par_p5 = ((double)reg_calib_data.par_p5 / potencia);
    	
    	potencia = pow(2.0, 6.0);
    	reg_calib_data.par_p6 = BMP3_CONCAT_BYTES(reg_data[14], reg_data[13]);
    	calib_data.par_p6 = ((double)reg_calib_data.par_p6 / potencia);
    	
    	potencia = pow(2.0, 8.0);
    	reg_calib_data.par_p7 = (int8_t)reg_data[15];
    	calib_data.par_p7 = ((double)reg_calib_data.par_p7 / potencia);
    	
    	potencia = pow(2.0, 15.0);
    	reg_calib_data.par_p8 = (int8_t)reg_data[16];
    	calib_data.par_p8 = ((double)reg_calib_data.par_p8 / potencia);
    	
    	potencia = pow(2.0, 48.0);
    	reg_calib_data.par_p9 = (int16_t)BMP3_CONCAT_BYTES(reg_data[18], reg_data[17]);
    	calib_data.par_p9 = ((double)reg_calib_data.par_p9 / potencia);
    
    	potencia = pow(2.0, 48.0);
    	reg_calib_data.par_p10 = (int8_t)reg_data[19];
    	calib_data.par_p10 = ((double)reg_calib_data.par_p10 / potencia);
    	
    	potencia = pow(2.0, 65.0);
    	reg_calib_data.par_p11 = (int8_t)reg_data[20];
    	calib_data.par_p11 = ((double)reg_calib_data.par_p11 / potencia);
    
    }

    Then, you cant work with the struct "calib_data" as double data.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist