0

Raspberry Pi and the BMP085
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Raspberry Pi and the BMP085

by static on Fri Apr 19, 2013 8:07 am

Brilliant work Snoopytoo!

I'm going to play around with this today. I'm hoping to post up by this afternoon.

Good job!

Any chance of a link to the new datasheet?

static
 
Posts: 182
Joined: Thu Dec 23, 2010 6:21 pm

Re: Raspberry Pi and the BMP085

by static on Fri Apr 19, 2013 9:12 am

Found it!
Here's the old version (1.0):
http://www.adafruit.com/datasheets/BMP085_DataSheet_Rev.1.0_01July2008.pdf

Here's version 1.3:
http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Pressure/BST-BMP085-DS000-06.pdf

Here's the link to the Adafruit-Raspbery-Pi-Python-Code:
https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/tree/master/Adafruit_BMP085

That will let folks do an easy comparison. I'm going to play a little bit.
I'm kinda thrilled to see this. It means I wasn't crazy.

static
 
Posts: 182
Joined: Thu Dec 23, 2010 6:21 pm

Re: Raspberry Pi and the BMP085

by static on Fri Apr 19, 2013 9:20 am

A couple of questions:

In the constructor, why not pass the "debug" and "busnum" parameter down to the i2c constructor? I modified my code to do this because it seemed to make sense to me. It allowed me to quickly set-up the parameters when I set the sensor up in the code.

Is there a reason to do it your way? Is there a style issue? I'd like my project to be easy to use and understand for others, which implies using a cohesive pattern/style.

static
 
Posts: 182
Joined: Thu Dec 23, 2010 6:21 pm

Re: Raspberry Pi and the BMP085

by snoopytoo on Tue Apr 23, 2013 8:20 am

Sorry for slow reply Static, forgot to tick the "notify me when a reply is posted" box!

Glad you found the datasheet, but 'fraid that was the only one of your questions I could probably have helped you with - am assuming your other questions are aimed at Adafruit posters and not me? I learnt a basic level of coding in Turbo Pascal then a little bit in Java over 15 years ago and this has been my first attempt at reading/writing code since!

I still don't quite fully get how the basics of Python fit together just yet... one step at a time! :) Would no doubt help my learning process to read someone more knowledgeable's answer to these questions?
snoopytoo
 
Posts: 4
Joined: Thu Apr 18, 2013 5:33 am

Re: Raspberry Pi and the BMP085

by static on Tue Apr 23, 2013 8:50 am

I programmed a fair amount when I was a kid. I stopped for about two decades and then started up again with Python, and I love it. I just spent a day coding up a similar driver for the ADXL345 (I needed a big chunk of help with bitwise operations), and I'm really impressed with how quick you can learn to do "esoteric" tasks with Python.

If you've got any questions that I might be able to help with, let me know. I'm learning a ton and I might be able to point you towards some useful sites.

static
 
Posts: 182
Joined: Thu Dec 23, 2010 6:21 pm

Re: Raspberry Pi and the BMP085

by bigt on Sat Aug 31, 2013 7:54 pm

I cloned the libraries from GitHub on August 30th, 2013 and the BMP095 code didn't work. I was getting the incorrect data mentioned above. I was usually (but not always) getting absurdly negative temperatures and pressures.

After reading all of the previous posts, and looking at the histories on GitHub, it looks like the 16-bit reading method in Adafruit_I2C.py changed on 19 August. The change seems to have broken the BMP085 code again. I reverted Adafruit_I2C.py to the previous version and everything works now.

bigt
 
Posts: 4
Joined: Sun Feb 26, 2012 2:50 am

Re: Raspberry Pi and the BMP085

by static on Sat Aug 31, 2013 9:04 pm

Shoot.
I think I fixed the code before to work around that issue. I need to revert back, but everything is packed up right now. I'll try to update my code, but do you want to post your working code? Others will probably be very thankful. It's going to be a bit before I can get back to it. I'm not sure where my BMP085 is.

static
 
Posts: 182
Joined: Thu Dec 23, 2010 6:21 pm

Re: Raspberry Pi and the BMP085

by bigt on Sun Sep 01, 2013 1:29 am

Static, I didn't apply your modifications to the code. I was using the files as downloaded from GitHub. My only change was to modify the I2C code to undo KTOWN's latest change per the history file.

bigt
 
Posts: 4
Joined: Sun Feb 26, 2012 2:50 am

Re: Raspberry Pi and the BMP085

by static on Sun Sep 01, 2013 7:55 am

Gotcha. You may still want to post your working code. When I started playing around with this I was a complete noob. One of the things that made it difficult was having to bounce around and put together the changes that people made to make the code work.

static
 
Posts: 182
Joined: Thu Dec 23, 2010 6:21 pm

Re: Raspberry Pi and the BMP085

by bigt on Sun Sep 01, 2013 4:56 pm

Fair enough. From the commit notes for Adafruit_I2C.py, seen here: https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/commit/6ce7476dd0a9b103bd4e00b0653e1c8a03787ef5#Adafruit_I2C/Adafruit_I2C.py

Code: Select all | TOGGLE FULL SIZE
   def readU16(self, reg):
     "Reads an unsigned 16-bit value from the I2C device"
     try:
       hibyte = self.readU8(reg)
       lobyte = self.readU8(reg+1)
       result = (hibyte << 8) + lobyte
       #result = self.bus.read_word_data(self.address,reg)
       if (self.debug):
         print "I2C: Device 0x%02X returned 0x%04X from reg 0x%02X" % (self.address, result & 0xFFFF, reg)
       return result
      except IOError, err:
        return self.errMsg()

   def readS16(self, reg):
     "Reads a signed 16-bit value from the I2C device"
     try:
       hibyte = self.readS8(reg)
       lobyte = self.readU8(reg+1)
       result = (hibyte << 8) + lobyte
       #result = self.bus.read_word_data(self.address,reg)
       if (self.debug):
         print "I2C: Device 0x%02X returned 0x%04X from reg 0x%02X" % (self.address, result & 0xFFFF, reg)
       return result
      except IOError, err:
        return self.errMsg()

bigt
 
Posts: 4
Joined: Sun Feb 26, 2012 2:50 am

Re: Raspberry Pi and the BMP085

by static on Sun Sep 01, 2013 4:59 pm

Speaking as someone who has trouble putting everything together, this kind of stuff really helps.

Thanks,
You Rock!

static
 
Posts: 182
Joined: Thu Dec 23, 2010 6:21 pm

Re: Raspberry Pi and the BMP085

by F481 on Mon Sep 02, 2013 8:10 am

Is there a commit to GitHub in the foreseeable future that fixes the problem?
Can anyone give a rough guess when the fixed code releases?

Much thanks for the work on it!
F481
 
Posts: 4
Joined: Mon Sep 02, 2013 6:42 am

Re: Raspberry Pi and the BMP085

by static on Mon Sep 02, 2013 8:48 am

I thought I saw that this was a known issue and was being addressed, but I don't remember where I saw that (I just looked back and it's not on any of the lists I hit frequently).

static
 
Posts: 182
Joined: Thu Dec 23, 2010 6:21 pm

Re: Raspberry Pi and the BMP085

by F481 on Mon Sep 02, 2013 12:59 pm

F481
 
Posts: 4
Joined: Mon Sep 02, 2013 6:42 am

Re: Raspberry Pi and the BMP085

by ktownsend on Mon Sep 02, 2013 2:34 pm

There is no standard way to do 16-bit reads in I2C since the bytes can be combined differently or come in a different order on different sensors. The only safe way is to do pure 8-bit reads/writes and keep any 16-bit or higher logic on the driver side. Including the 16-bit methods in the original Adafruit_I2C libs was a mistake in that respect, and they will probably be removed from a future version entirely.

That said ... I just tested the Adafruit_BMP085 library and it sems to work for me?

Code: Select all | TOGGLE FULL SIZE
webide@raspberrypi /usr/share/adafruit/webide/repositories/Adafruit-Raspberry-Pi-Python-Code/Adafruit_BMP085 $ sudo python Adafruit_BMP085_example.py                                                                                 
Temperature: 24.50 C                                                                                                                                                                                                                   
Pressure:    1020.20 hPa                                                                                                                                                                                                               
Altitude:    -58.78


What are you getting, and are you sure you have the latest code from the repository?

UPDATE: That negative altitude is correct since I'm not adjusting the reference sea level pressure for an actual reading, but using the generic 'rough estimate' SLP value in the driver. Adjusting for local weather conditions would give me an altitude closer to the 60m or so I should have at my current location.

ktownsend
 
Posts: 1257
Joined: Thu Nov 05, 2009 2:18 am

Please be positive and constructive with your questions and comments.