Jump to content
Sign in to follow this  
OppaErich

BMP085 - I'm low on pressure and VERY low on temperature

Recommended Posts

Trying to interface a BMP085 and it looks like another fail, there is hope it's the sensor this time.

 

The calibration values I get back are not the same as in the datasheest but they are in the right range. So this looks promising. But temperature and pressure conversion deliver always 0x8000 (checked back with logic analyzer).

 

Nothing on that in the datasheet. Does someone know what this means ?

 

You think it does not get below 0 Kelvin ? Ha, me got 33 Million degree sub zero but only 50 mbar pressure. Looks like I'm floating in deep deep space.  :blink:

 

 

 

 

post-3-14264605451309_thumb.png

Share this post


Link to post
Share on other sites

I  assume you implemented the formula following the datasheet. Make sure that you use exactly the same data types and signed-ness for all the variables. You might also need to add in a few casts to make sure the compiler handles the integers as you expect.

 

I did this by recreating / verifying the formula in an Excel sheet and then single-stepping and cross-checking each step in the debugger.

https://github.com/astuder/BMP085-template-library-Energia

 

PS: instead of short/long, use the explicit int16/int32 types to ensure the correct number of bits.

Share this post


Link to post
Share on other sites

Yes, I did but that's not (yet) my main problem. I doubt both readings, exactly 0x8000. I've ordered another one and I haven't tried any of the higher resolution modes, maybe it doesn't wake up on low power mode...

Share this post


Link to post
Share on other sites

Because the other one did NOT arrive and just for the fun of it, I gave it Vbus and connected the EOC, end of conversion, pin to the logic analyzer. Still get back 0x8000 and EOC does never ever toggle. It's dead Jim !

Share this post


Link to post
Share on other sites

I'm a bit on the high side, 10 kOhm. I think the communication is fine, the calibration values look reasonable.

 

http://www.amazon.de/gp/product/B00DI1WZRO/ref=oh_aui_detailpage_o03_s00?ie=UTF8&psc=1 probably machine translated from English to German.

 

Ah, the next one arrived. This one has 3V3 and 5V inputs, I've also ordered two BMP180 via ebay.

 

Haha, 0x8000 again and EOC doesn't toggle too. I conclude there's something wrong with the 'start conversion' command. Looks like conversion is never started to me. I'll look into that...

Edited by Oppa

Share this post


Link to post
Share on other sites

Aha, I get something different from 0x8000 and EOC toggles. B) Temp is still way off but that's the type stuff during calculation methinks. Pressure looks like it's off by a factor of 2 now.

 

I did [write, F4, write, 2E] and the sensor wants [write, F4, 2E], also an I2C STOP was missing after the last byte.

 

Thanks all,

Stephan

Share this post


Link to post
Share on other sites

The final results are still garbage so I've put in the example values from the datasheet to debug the calculation. I found and corrected some wrong calculations but pressure is still way off.

		/******************************************
		 * example values from datasheet to test calculation
		 ******************************************/
		AC1 = 408;
		AC2 = -72;
		AC3 = -14383;
		AC4 = 32741;
		AC5 = 32757;
		AC6 = 23153;
		B1 = 6190;
		B2 = 4;
		MB = -32767;
		MC = -8711;
		MD = 2868;
		UT = 27898;
		UP = 23843;
		/******************************************
		 * calculate true temperature
		 ******************************************/
		X1 = ((UT - AC6) * AC5)>>15;		// funny math from the BMP085 datasheet
		X2 = (MC<<11) / (X1 + MD);
		B5 = X1 + X2;
		T = (B5 + 8)>>4;												// T = true temp in 0.1[�C]
		/******************************************
		 * calculate true pressure
		 ******************************************/
		B6 = B5 - 4000;				// the math gets funnier
		X1 = (B2 * ((B6 * B6)>>12))>>11;
		X2 = (AC2 * B6)>>11;
		X3 = X1 + X2;
		B3 = (((AC1 * 4 + X3)<<oss) + 2) / 4;
		X1 = AC3 * B6>>13;
		X2 = (B1 * (B6 * B6>>12))>>16;
		X3 = ((X1 + X2) + 2)>>2;
		B4 = AC4 * (unsigned long)(X3 + 32768)>>15;
		B7 = ((unsigned long)UP - B3) * (50000>>oss);
		if(B7 < 0x80000000){                  // intermediate values up to here are OK
			p = (B7 * 2) / B4;            // this "hard" calculation fails
		} else{                               // p should be 70003, I get -58369
			p = (B7 / B4) * 2;
		}
		X1 = p>>8 * p>>8;
		X1 = (X1 * 3038)>>16;
		X2 = (-7357 * p)>>16;
		p = p + (X1 + X2 + 3791)>>4;							

What's going on here ?

 

post-3-14264605454228_thumb.png

Share this post


Link to post
Share on other sites

Yep, p is unsigned long. (hehe, it's not i see **) After some trial & error change I finally got the (almost, 1 off) right p value. The actual sensor reading was still garbage but at least within the boundaries of nature, -257 C, 20hPa. Just for fun I used the other BMP085 (the one I got first) and the readings were way off. So one of these is broken, at least. Yesterday, the 2 BMP180 arrived. I've just wired one of them up and T = 263 and p = 101990. The next weather station around reports 1008.4 hPa. Doesn't look too bad. It just takes about 20 samples for the readings to stabilize. Temp started at 270 and pressure at 58000...

 

Thanks,

Stephan

 

** I tried unsigned long but this results in insanely high p values. The other sensor gives the best readings but p is negative, hacked to use the absolute value.

int main(void){
	short AC1, AC2, AC3, B1, B2, MB, MC, MD;// 16-bit calibration data
	unsigned short AC4, AC5, AC6;		// 3 values are unsigned ?
	short oss = 0;				// oversampling setting (0-3)
	long X1, X2, X3, B3, B4, B5, B6, B7;	// intermediate values for calculation
	long UT, UP, T, p;			// uncompensated and final values

post-3-14264605454727_thumb.png

Edited by Oppa

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...