The BMP085 sensor measures barometric pressure (and temperature). I’ve hooked it up to port 2 via I2C:
As SMD, it’s tiny …
The 4 wire-wrap wires are connected to port pins 2..5, respectively: SDA (DIO), ground, SCK (AIO), and 3.3V power.
There’s now a bit-banging I2C master driver in the Ports library which works with any of the 4 ports, plus a new driver for the BMP085. Here’s the new demo code, now included with the library:
It looks like the elaborate algorithm from the BMP085 data sheet to calculate pressure in Pascals (millibar) contains an error. After some guess-work and with information from the older SMD500 sensor, I think I’ve come up with the proper computations. The results are now as expected:
This is a very sensitive MEMS sensor. It’s accurate enough in its lowest resolution mode to calculate altitude to 50 cm accuracy given the exact pressure at sea level – just moving the sensor up and down shows a matching variation! Higher-resolution modes have been not been implemented.
Update – There’s a problem with the calculations: with temperatures 25.0 °C and up, the pressure calculations fail and a result of 2.35 mBar is reported. Will need to look into this.
Update 2 – Thanks to a private email suggestion, I’ve finally been able to resolve the > 25 °C bug. The current source code no longer has the problem and shows consistent values also at higher temperatures.
I wonder if I could get the source code for those sensor(BMP085).
I do know this is kind of rude(asking your source code)
But I’m a student who just begins to study.
I promise I never use your code as commercial purpose!
Where did you source these sensors? I’ve been trying to find them since coming across this great site. Thanks…
Sure – it’s open source, you can find the code at https://jeelabs.org/view/libraries/Ports/
Enjoy :)
(URL updated 2009-12-09)
Thanks for that Jean-Claude.