BMP180 Writing

#1
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.../BST-BMP180-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 :eek: :eek:

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

Thanks.
 

Aries

New Member
#2
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_BME280_Arduino_Library/blob/master/src/SparkFunBME280.cpp
 

AllyCat

Senior Member
#5
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.
 

marks

Senior Member
#6
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/showthread.php?30524-BMP180-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
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.
 
Top