The BMP085 — produced by Bosch Sensortec — is just such a device. This eight- pin marvel is exceedingly accurate, yet priced to be within easy reach of the most frugal DIYer. Communication with the chip is by way of the popular I2C bus, meaning
that we can concentrate almost exclusively on
manipulating the data it sends, rather than fussing over
how to receive the data in the first place. As icing on the
cake, the BMP085 also contains an integral thermometer.
Not only is knowing the temperature useful to us humans,
but the value detected also automatically figures into the
barometric pressure measurement.
If you’re a weather junkie like me who’s always
wanted a decent barometer which doesn’t break the bank,
then read on! In this article, you’ll learn how to interface
the BMP085 to most any PIC microcontroller. After
covering the electrical requirements, we’ll unravel the
somewhat nasty software aspects (don’t worry — all of the
ugly mathematics and tricky data type manipulations have
been taken care of for you). With what you learn here,
you’ll be all set to design a customized barometer and
start making your own weather forecasts.
One final thing before we tuck into the details. Using
the BMP085 with an Arduino is a breeze since software
libraries already exist for it, but going with a
microcontroller chip instead has a number of advantages.
The PIC16F1825 that I used costs about one-tenth of an
Arduino. Moreover, the required program code runs half
as long.
Finally, with a PIC you get total
control of the design at a much lower
level. When you throw in the fact that
we’ll be using a free compiler to create
the firmware, we’re talking a complete
high performance barometer for about
ten smackers!
Hooking It Up
The BMP085 is a tiny device (about
a quarter inch square) intended for
surface-mount construction. I don’t know
about you, but my eyes and hands are
way too old to deal with such things.
Fortunately, the component is readily
available already soldered to a breakout
board from a number of suppliers. See
Figures 1 and 2 which show the front
and back.
This nifty affair features standard
0.1” pin spacing, meaning that it’s easy
to socket on a circuit board or try out on
a solderless breadboard. I got mine for
some six bucks from Amazon, but if you
shop around you’ll find it for even less
on eBay. Just so you know, you might also bump into the
BMP180 (and breakout board) which is a newer version of
the thing. The hardware and software described in this
article are compatible with either.
Apart from making the chip more conducive to hand
construction, the breakout board sports two other features
to really help things along. First, you need to know that
the BMP085 is a 3.3V device, but frequently (as with the
circuit described herein) you’ll want to use it with a 5V
microcontroller. Conveniently, the breakout board comes
loaded with a regulator and appropriate decoupling
capacitors to derive the required lower voltage.
It was mentioned above that communication with the
chip proper is by means of the relatively straightforward
I2C bus, which is a two-wire affair. If you’ve played with
this protocol at all, then you’ll already know that the two
lines comprising it — called SCL and SDA — each require a
pull-up resistor. These, too, are provided on the breakout
board.
Now, one thing might worry you at this point. If the
microcontroller is powered by 5V and the BMP085 by
3.3V, are we cruising for a bruising on the I2C bus with
incompatible clock and data voltages? Not at all. One of
the excellent features of this protocol is that the bus lines
are configured around open-drain FETs. Instead of forcing
pins high (to a possibly hazardous voltage for the
BMP085), instead we’re only safely bringing them low
through those pull-up resistors just pointed out.
We’ve come this far, so let’s go ahead and see the
August 2015 49
FIGURE 1.
FIGURE 2.