BMP180 Code

JSDL

Senior Member
Hi all, I am starting a new project using a Picaxe 08M2 and BMP180 pressure sensor breakout module. I would like to start by getting some sample pressure readings and then convert those to altitude. The Picaxe will just provide the readings and I will perform the calculations manually. I looked through the datasheet but am having some trouble getting started. Could anyone point me in the right direction? I'm still not an expert at interpreting datasheets and working with registers just yet but would like to learn. Thanks in advance.
 

neiltechspec

Senior Member
I played about with one of these a while ago, got fed up trying decipher the data returned though, so gave up.

Code:
        Main:

	hi2csetup i2cmaster,$EE, i2cslow, i2cbyte 'BMP180 address
	
	do
	
	hi2cin $D0,(b10)		'read sensor id - read only value, never changes
	if b10 <> $55 then	'should be $55
	 sertxd ("Sensor Not Found",cr,lf)
	 pause 1000
	 goto main
	endif
	 
	hi2cout $F4,($B4) 	'initiate standard pressure conversion
	pause 10			'allow conversion time to complete
	hi2cin $F6,(b1,b0)	'read raw pressure data
	sertxd(#w0,)
        loop
Neil.
 

JSDL

Senior Member
Thanks, I uploaded this code and am getting a reading, just not sure what it is. The values I am getting are roughly in the range of 59500 to 60580. Any ideas? I want to be able to calculate altitude.
 

eggdweather

Senior Member
This code works, it's set for my display so you will have to change the lines with T2400 in them to your display settings.

I've also have Arduino code, but have found in both versions the altitude calculation, whilst very accurate, I can measure the height difference between my floor and desk to 0.1M resolution, but if ambient air pressure changes, then so does altitude, so you have to enter todays known air pressure to get altitude. You can't get an absolute value, I liken it to why aircraft have to recalibrate their altimeters before each flight.
 

Attachments

JSDL

Senior Member
thanks for the code will give it a try. Might be a dumb question, but the datasheet for the BMP180 says that the I2C address is 0x77. Wouldn't that translate to %1110111 in binary? All the code I am seeing uses the address %11101110. Does the MSB (0) represent something else?
 

bpowell

Senior Member
I2C (in this instance) is 7-bit addressing...the LSB (bit 0) is the "read / write" bit....0 for write, 1 for read.

For PICAXE, always use "0" for that last bit....the PICAXE will handle flipping it to a 1 when reading from the slave.
 
Top