5 Replies Latest reply on May 13, 2015 12:50 AM by Weishan

    Adafruit BMP183 SPI Barometric Pressure & Altitude Sensor Calibration

    Weishan

      I have the Adafruit BMP183 SPI Barometric Pressure & Altitude Sensor and it works (sort of).

       

      Overview | Adafruit BMP183 SPI Barometric Pressure & Altitude Sensor | Adafruit Learning System

       

      Test result:

      Pressure:    111265.00 Pascals / 1112.65 millibar (hPa)

      Temperature: 14.77 C

       

      As you can see, the room temperature is around 20 C but it reads 14.77 C. When I put I hand on/off it, the value did change though.

       

      Sometime, it is even worse, I saw something like 90 C many times.

       

      Also, the pressure is off as well. The room pressure is around 1020 mbar, but it reads 1112.65 mbar.

       

      Do I need to calibrate this sensor? I didn't find any document on how to do that. If you have any experience, please do let me know. Really appreciate it!

        • 1. Re: Adafruit BMP183 SPI Barometric Pressure & Altitude Sensor Calibration
          Weishan

          I just restarted Edison and now I read this,

           

          Pressure:    174801.00 Pascals / 1748.01 millibar (hPa)

          Temperature: 97.73 C

           

          The values are way to high

          • 2. Re: Adafruit BMP183 SPI Barometric Pressure & Altitude Sensor Calibration
            DiegoV_Intel

            Hi Weishan,

             

            I've checked the datasheet and it seems that the sensor is fully calibrated so the issue should not be with the calibration. You can check the datasheet here: https://www.adafruit.com/datasheets/1900_BMP183.pdf, on page 2.

             

            I remember that you had some troubles making this sensor work (Adafruit BMP183 SPI Barometric Pressure & Altitude Sensor with Intel Arduino IDE) so although you were able to compile and run the library, which is originally AVR compatible, the sensor might not work as it should because the library is not validated for the Edison architecture.

             

            My suggestions for you are the following:

            1. You could try using the I2C interface instead of the SPI just to know if you are able to get accurate data.
            2. You could compare the SPI data received from the sensor when it is used with the Arduino UNO and compare it with the data received when the sensor is used with the Edison Arduino Expansion Board (I mean the data directly from the SPI communication, not the final data of pressure and temperature). This test will allow you to know if you are receiving the same data or not.
            3. You could write your own library. It can be written for example in Python. You can use the current Arduino library as a guide to write the new library.

             

            Regards,

            Diego.

            • 3. Re: Adafruit BMP183 SPI Barometric Pressure & Altitude Sensor Calibration
              Weishan

              Thanks for the reply! I have tested with UNO board and everything works fine. See below for testing result.

               

              Pressure: 100461 Pascals / 1004 millibar (hPa)

              Temperature: 23.97 C

              Sea level pressure: 1013.25 millibar/hPa

              Altitude: 72.27 m


              There are final data and I need a little more time to figure out how to get the data directly from the SPI communication. Will let you know once I figure it out. Thanks again!

              • 4. Re: Adafruit BMP183 SPI Barometric Pressure & Altitude Sensor Calibration
                Weishan

                To get the raw values, I used the following functions,

                 

                  UT = readRawTemperature();

                  UP = readRawPressure();

                 

                Here are the raw values from UNO board,

                 

                Pressure:    328243

                Temperature: 21769.00

                 

                And here are the raw values from Edison board,

                 

                Pressure:    328197

                Temperature: 21781.00

                 

                They are very close! So I think the problem is in the following code which calculates the temperature.

                 

                  X1 = (UT - (int32_t)ac6) * ((int32_t)ac5) / pow(2,15);

                  X2 = ((int32_t)mc * pow(2,11)) / (X1+(int32_t)md);

                  B5 = X1 + X2;

                  temp = (B5+8)/pow(2,4);

                  temp /= 10;

                 

                Notice ac6, ac5, etc. are read from register in begin() function,


                  ac5 = read16(BMP183_REGISTER_CAL_AC5);

                  ac6 = read16(BMP183_REGISTER_CAL_AC6);

                 

                And the registers are defined in Adafruit_BMP183.h like this,

                 

                      BMP183_REGISTER_CAL_AC5            = 0xB2,  // R   Calibration data (16 bits)

                      BMP183_REGISTER_CAL_AC6            = 0xB4,  // R   Calibration data (16 bits)

                 

                I am still trying to figure out how to modify the code to make it work with Edison. If you guys have any idea, please do let me know. Really appreciate it!

                • 5. Re: Adafruit BMP183 SPI Barometric Pressure & Altitude Sensor Calibration
                  Weishan

                  I made it work!

                   

                  Basically, the following code doesn't read the registers' values from Edison correctly (see below for my testing results),

                   

                    /* read calibration data */

                    ac1 = read16(BMP183_REGISTER_CAL_AC1);

                    ac2 = read16(BMP183_REGISTER_CAL_AC2);

                    ac3 = read16(BMP183_REGISTER_CAL_AC3);

                    ac4 = read16(BMP183_REGISTER_CAL_AC4);

                    ac5 = read16(BMP183_REGISTER_CAL_AC5);

                    ac6 = read16(BMP183_REGISTER_CAL_AC6);

                    b1 = read16(BMP183_REGISTER_CAL_B1);

                    b2 = read16(BMP183_REGISTER_CAL_B2);

                    mb = read16(BMP183_REGISTER_CAL_MB);

                    mc = read16(BMP183_REGISTER_CAL_MC);

                    md = read16(BMP183_REGISTER_CAL_MD);

                   

                  From UNO board,

                   

                  ac1 = 7553

                  ac2 = -1093

                  ac3 = -14411

                  ac4 = 33233

                  ac5 = 25446

                  ac6 = 13402

                  b1 = 6515

                  b2 = 39

                  mb = -32768

                  mc = -11786

                  md = 2548

                   

                  From Edison Board,

                   

                  ac1 = 7553

                  ac2 = -1093

                  ac3 = -19071

                  ac4 = 25446

                  ac5 = 23065

                  ac6 = 39

                  b1 = 209

                  b2 = 2548

                  mb = 188

                  mc = 0

                  md = 0

                   

                  As a temporary workaround, I just hard coded these variables with the values I got from UNO board in the following functions and it works now!

                   

                  getTemperature()

                  getPressure()

                   

                  For long term solution, I may need a little more time to figure it out. If you have any input, please do let me know, thanks a lot!