​ ​ ​ ​ BMP180 Writing
Results 1 to 7 of 7

Thread: BMP180 Writing

  1. #1
    New Member
    Join Date
    May 2015
    Location
    France
    Posts
    19

    Default BMP180 Writing

    Good evening, I am interested in the temperature sensor and atmospheric pressure BMP180.

    I am trying to understand the protocol that is exchanged via the i2c bus.

    From the code I found here: http://www.picaxeforum.co.uk/showthread.php

    -----

    hi2cout $ F4, ($ B4) 'launches standard pressure conversion
    10 'pause allows the conversion time to complete
    hi2cin $ F6, (b1, b0) reads raw pressure data

    -----

    As well as after the directions for use (PAGE 20):
    https://cdn-shop.adafruit.com/datas....0-DS000-09.pdf

    Must write in a register to initialize the module?
    I did not understand what to write and in what AND why?

    To have the code you have to write $B4 in $F4

    I did not understand either the table page 21, what is this story "" oss ""?

    Thanks.

  2. #2
    New Member
    Join Date
    Jan 2014
    Location
    Surrey
    Posts
    20

    Default

    I don't know the BMP180, but this is part of the code I use for initialising a BME280 via I2C, which is very similar.
    Code:
    symbol BME280_CTRL_HUMIDITY_REG        = $F2 ' Ctrl Humidity Reg
    symbol BME280_STAT_REG                        = $F3 ' Status Reg
    symbol BME280_CTRL_MEAS_REG                = $F4 ' Ctrl Measure Reg
    symbol BME280_CONFIG_REG                    = $F5 ' Configuration Reg
    
    symbol TwoMS    = 2                                ' two milliseconds at clock frequency
    symbol TenMS    = 10                            ' ten milliseconds at clock frequency
    ' settings for BME280
    symbol I2CAddress = %11101110        ' Bosch 0x77 shifted to left
    
    '    runMode can be:
    '      0, Sleep mode
    '      1 or 2, Forced mode
    '      3, Normal mode
    symbol runMode = 3    ' Normal mode
    
    '    tStandby can be:
    '      0, 0.5ms
    '      1, 62.5ms
    '      2, 125ms
    '      3, 250ms
    '      4, 500ms
    '      5, 1000ms
    '      6, 10ms
    '      7, 20ms
    symbol tStandby = 0
    
    '    filter can be off or number of FIR coefficients to use:
    '      0, filter off
    '      1, coefficients = 2
    '      2, coefficients = 4
    '      3, coefficients = 8
    '      4, coefficients = 16
    symbol filter = 0
    
    '    tempOverSample can be:
    '      0, skipped
    '      1 through 5, oversampling *1, *2, *4, *8, *16 respectively
    symbol tempOverSample = 1
    
    '    pressOverSample can be:
    '      0, skipped
    '      1 through 5, oversampling *1, *2, *4, *8, *16 respectively
    symbol pressOverSample = 1
    
    '    humidOverSample can be:
    '      0, skipped
    '      1 through 5, oversampling *1, *2, *4, *8, *16 respectively
    symbol humidOverSample = 1
    
    BME280Start:        ' start up BME280
        sertxd(13,10,"Start BME")
        pause 5000
    
        hi2csetup I2Cmaster,I2CAddress,I2Cslow,I2cbyte
        pause TenMS
        
    ' set sleep mode for configuration
        b0 = 0
        hi2cout BME280_CTRL_MEAS_REG,(b0)
        pause TenMS
        
    ' set configuration word
        b0 = tStandby * 32 & $E0
        b0 = filter  * 4 & $1C | b0
        hi2cout BME280_CONFIG_REG,(b0)
        pause TenMS
    ' set humidity control
        b0 = humidOverSample & $07
        hi2cout BME280_CTRL_HUMIDITY_REG,(b0)
        pause TenMS
        
    ' set temperature oversampling ...
        b0 = tempOverSample * 32 & $E0
    ' and pressure oversampling ...
        b0 =pressOverSample * 4 & $1C | b0
    ' and runmode
        b0 = runMode & $03 | b0
        hi2cout BME280_CTRL_MEAS_REG,(b0)
        pause TenMS
    oss (as it says on the heading for Table 8) is over-sampling setting.

    If you are into C++, the SparkFun library includes a BME280 program (on which I based my Picaxe version)

    https://github.com/sparkfun/SparkFun...kFunBME280.cpp

  3. #3
    Technical Support
    Join Date
    Jan 1970
    Location
    UK
    Posts
    24,438

    Default

    Quote Originally Posted by guitoon41 View Post
    From the code I found here: http://www.picaxeforum.co.uk/showthread.php

    As well as after the directions for use (PAGE 20):
    https://cdn-shop.adafruit.com/datas....0-DS000-09.pdf
    Unfortunately neither of those links are complete so can not be accessed. If you can post the full links to both that may help others determine what the answers should be to your question.

  4. #4
    New Member
    Join Date
    Jan 2014
    Location
    Surrey
    Posts
    20

    Default

    I don't know which Picaxe forum thread the OP was referring to. However, the link to the datasheet was full of ... s. I found the correct one:

    https://cdn-shop.adafruit.com/datash...0-DS000-09.pdf

  5. #5
    Senior Member
    Join Date
    Feb 2012
    Location
    London
    Posts
    2,896

    Default

    Hi,

    Actually, the BMP180 and BMP/E280 have their I2C registers organised rather differently, so you do need to use the "correct" code! Acquiring the "raw" data from either chip family is not too difficult, but "calibrating" the results is.

    There is probably much more information than you want, in my thread here, but it does include some hot links to other relevant forum threads.

    Cheers, Alan.

  6. #6

    Default

    hi guitoon41,
    The native adc resolution of the bmp180 is 16bit
    they try and achieve additional bit resolution through filtering.

    18bit is selected when using $b4
    really its justs adding four samples
    the code you are showing (b1,b0) is only holding a 16bit number
    you need to read in an additional 3rd variable for the extra 2bits
    which you add to your 16 bit number after you've multiplied it by 4.
    also likewise at the code in the datasheet oss becomes x4 and oss /4.
    because of the noise of this sensor it does not make it worthwide to do.

    they do recommend 16bit 1 sample for weather 0.06 resolution which is better than most.
    http://www.picaxeforum.co.uk/showthr...-Code-Examples

    It would be more interesting to try the BME280 a later and improved version over the BMP280
    similiar specs to BMP180 but with noise said to be 3 folds less adding the extra bits here
    makes more sense

  7. #7
    New Member
    Join Date
    May 2015
    Location
    France
    Posts
    19

    Default

    Hi all,

    It's pretty complicated for me. For a simple sensor.

    I'm thinking of using Arduino libraries to use it.

    A sensor with i2c reading simple data would have been simpler.

    Here with the 16bit and the calibration .....
    Complicated.

    A simple reading of the data would have been good for me.

    Thank you for your answers.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •