BMP180 - Senzor atmosferskog pritiska i temperature vazduha

Proizvodjač: BOSCH Sensortec
Napon napajanja: 1.8...3.6 V
Izlazni signal: I2C interface
Opseg merenja: pritisak 300...1100 hPa, temperatura -40 °C...+85 °C
Rezolucija merenja: pritisak 0.01 hPa, temperatura 0.1 °C
Tačnost merenja: pritisak ±1 hPa, temperatura ±0.5°C (±1°C)
Period merenja: pritisak 4.5...25.5 ms, tempetatura 4.5 ms

Software in C++ for Raspberry Pi
//****************************************************************************
// Calibration values - BMP180
//****************************************************************************

const unsigned char bmp_oversample = 3;	// oss=3

// Pomocu: i2cdump -y 1 0x77, prepisati vrednosti od adrese 0xAA do 0xBF
// These are stored in the BMP180       // MSB, LSB
short int            bmp_ac1 = 0x20C6;  //0xAA,0xAB
short int            bmp_ac2 = 0xFB20;  //0xAC,0xAD
short int            bmp_ac3 = 0xC742;  //0xAE,0xAF
unsigned short int   bmp_ac4 = 0x848D;  //0xB0,0xB1
unsigned short int   bmp_ac5 = 0x63C3;  //0xB2,0xB3
unsigned short int   bmp_ac6 = 0x43A1;  //0xB4,0xB5
short int            bmp_b1  = 0x1973;  //0xB6,0xB7
short int            bmp_b2  = 0x0034;  //0xB8,0xB9
int                  bmp_b5;
short int            bmp_mb  = 0x8000;  //0xBA,0xBB
short int            bmp_mc  = 0xD1F6;  //0xBC,0xBD
short int            bmp_md  = 0x09BC;  //0xBE,0xBF

//----------------------------------------------------------------------
...
// ----- Pritisak vazduha (mbar)
		msb = hex_val(buf[18],buf[19]);
		lsb = hex_val(buf[20],buf[21]);
		bmp_b5 = bmp_b5_Get(msb,lsb);
		msb = hex_val(buf[12],buf[13]);
		lsb = hex_val(buf[14],buf[15]);
		xsb = hex_val(buf[16],buf[17]);
		p = (float)bmp_GetPressure(msb,lsb,xsb)/100;
		printf("%5.0fmbar ",p);

// ----- Temperatura vazduha 2 (C)
		t2 = ((float)((bmp_b5 + 8)>>4))/10;
		printf("%5.1fC ",t2);
...
//----------------------------------------------------------------------
// Calculate calibrated pressure BMP180
// Value returned will be in hPa
int bmp_GetPressure(int msb, int lsb, int xsb)
{
  unsigned int up;
  int x1, x2, x3, b3, b6, p;
  unsigned int b4, b7;

  up = (((unsigned int) msb << 16) + ((unsigned int) lsb << 8) + ((unsigned int) xsb)) >> (8-bmp_oversample);

  b6 = bmp_b5 - 4000;
  x1 = (bmp_b2 * (b6 * b6)>>12)>>11;
  x2 = (bmp_ac2 * b6)>>11;
  x3 = x1 + x2;
  b3 = (((((int)bmp_ac1)*4 + x3)<>2;

  x1 = (bmp_ac3 * b6)>>13;
  x2 = (bmp_b1 * ((b6 * b6)>>12))>>16;
  x3 = ((x1 + x2) + 2)>>2;
  b4 = (bmp_ac4 * (unsigned int)(x3 + 32768))>>15;

  b7 = ((unsigned int)(up - b3) * (50000>>bmp_oversample));
  if (b7 < 0x80000000)
    p = (b7<<1)/b4;
  else
    p = (b7/b4)<<1;
  x1 = (p>>8) * (p>>8);
  x1 = (x1 * 3038)>>16;
  x2 = (-7357 * p)>>16;
  p += (x1 + x2 + 3791)>>4;
  return p;
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Calculate calibrated temperature BMP180
// Value returned will be in units of 0.1 deg C
int bmp_b5_Get(int msb, int lsb)
{
  unsigned int ut;
  int x1, x2;
//  int t;

  ut=((msb<<8)+lsb);

  x1 = (((int)ut - (int)bmp_ac6)*(int)bmp_ac5) >> 15;
  x2 = ((int)bmp_mc << 11)/(x1 + bmp_md);
  bmp_b5 = x1 + x2;

//  t = ((bmp_b5 + 8)>>4);
  return bmp_b5;
}
//----------------------------------------------------------------------


Software in Assembler for PIC16F876, rutine se pozivaju svake sekunde sa pauzama
;---------------------------------------------------------------------
;Start BMP180 - Temperatura
Start_BMP180_T
	i2c_start
	movlw	0xEE		;Module address WR (0x77)
	call	i2c_send

	movlw	0xF4		;address
	call	i2c_send
 
	movlw	0x2E		;Start Temperature, wait 4.5ms
	call	i2c_send

	i2c_stop
	return
;---------------------------------------------------------------------
...
Pauza veca od 4.5ms
;---------------------------------------------------------------------
;Citaj podatke iz BMP180 - Temperatura
BMP180_T
	i2c_restart
	movlw	0xEE		;Module address WR (0x77)
	call	i2c_send

	movlw	0xF6		;address
	call	i2c_send
;- - - - - - - - - - - - - - - - - - - - - - - -

	i2c_restart
	movlw	0xEF		;Module address RD (0x77)
	call	i2c_send

	i2c_receive
	i2c_send_ACK
	movf	SSPBUF,W	;uzmi podatak 1
	movwf	T2_H

	i2c_receive
	i2c_send_NACK
	movf	SSPBUF,W	;uzmi podatak 2
	movwf	T2_L

	i2c_stop
	return
;---------------------------------------------------------------------
...

;---------------------------------------------------------------------
;Start BMP180 - Pritisak
Start_BMP180_P
	i2c_start
	movlw	0xEE		;Module address WR (0x77)
	call	i2c_send

	movlw	0xF4		;address
	call	i2c_send
 
;	movlw	0x34		;Start Pressure (oss=0) Max. conversion time  4.5ms
;	movlw	0x74		;Start Pressure (oss=1) Max. conversion time  7.5ms
;	movlw	0xB4		;Start Pressure (oss=2) Max. conversion time 13.5ms
	movlw	0xF4		;Start Pressure (oss=3) Max. conversion time 25.5ms
	call	i2c_send

	i2c_stop
	return
;---------------------------------------------------------------------
...
Pauza veca od 25.5ms
;---------------------------------------------------------------------
;Citaj podatke iz BMP180 - Pritisak
BMP180_P
	i2c_restart
	movlw	0xEE		;Module address WR (0x77)
	call	i2c_send

	movlw	0xF6		;address
	call	i2c_send
;- - - - - - - - - - - - - - - - - - - - - - - -

	i2c_restart
	movlw	0xEF		;Module address RD (0x77)
	call	i2c_send

	i2c_receive
	i2c_send_ACK
	movf	SSPBUF,W	;uzmi podatak 1
	movwf	P_H

	i2c_receive
	i2c_send_ACK
	movf	SSPBUF,W	;uzmi podatak 2
	movwf	P_L

	i2c_receive
	i2c_send_NACK
	movf	SSPBUF,W	;uzmi podatak 3
	movwf	P_X

	i2c_stop
	return
;---------------------------------------------------------------------


Download File:
  • bmp180.py - Python software za testiranje BMP180
  • Šema RPI WS
  • Šema PIC WS
  • Data Sheet - BMP180.pdf