This is only a preview of the December 2017 issue of Silicon Chip. You can view 38 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "Touchscreen Altimeter and Weather station":
Items relevant to "The Arduino MegaBox from Altronics":
Items relevant to "Build your own Super-7 AM Radio Receiver – Part 2":
Items relevant to "El Cheapo Modules 11: Pressure/Temperature Sensors":
Items relevant to "Part 3: Finishing our new 6GHz+ Digital Frequency Meter":
Purchase a printed copy of this issue for $10.00. |
Using Cheap Asian Electronic Modules Part 11: by Jim Rowe
Elecrow GY-68 & GY-BM
Barometer/Temperature
Sensor Modules
This month, we’re looking at two very tiny modules
which sense barometric pressure and air temperature.
One uses the Bosch BMP180 digital pressure sensor,
while the other uses the newer BMP280 sensor. Both
can send their readings to virtually any micro via a
standard I2C serial interface, while the BMP280-based
module also offers an SPI interface.
T
he first thing you notice about
the Elecrow GY-68 digital barometer module is its tiny physical size.
It measures only 13 x 10 x 2.5mm,
making it by far the smallest module
we’ve looked at so far in these articles.
The BMP180 sensor IC which forms
the functional heart of the module is
much smaller again, measuring only
3.6 x 3.8 x 0.93mm.
The BMP180 has what is described
as ultra-low power consumption,
drawing less than 10µA when taking
readings once per second and less than
1µA in standby mode. Clearly, it’s very
suitable for use in compact portable
devices like smartphones.
It’s also a low-cost device. The
Elecrow GY-68 module we’re looking
at here is available from the Silicon
Chip online shop for just $5 plus postage (catalog code SC4343).
The BMP180 sensor
This is made by Bosch Sensortec,
a division of the large German firm
Robert Bosch GmbH (www.boschsensortec.com). The BMP180 is based
on piezo-resistive MEMS technology,
where MEMS stands for “MicroElectroMechanical Systems”.
In other words, it uses a tiny sensor
element which flexes mechanically in
response to changes in atmospheric
78
Silicon Chip
pressure and the flexing is sensed by
measuring changes in the element’s
resistance.
The BMP180’s 3.6 x 3.8 x 0.93mm
metal package has a tiny vent hole
(about 0.5mm diameter) in the top to
allow the sensor element access to the
outside air. And apart from the sensor
element, there are three other functional blocks inside the device.
As shown in Fig.1, the three blocks
comprise an ADC (analog to digital
converter) to make the measurements,
a control unit which also provides
the I2C serial interface for communicating with an external micro and an
EEPROM which has 22 bytes of storage for the device’s 11 x 16-bit calibration parameters.
Every individual BMP180 device
is calibrated during manufacture,
after which the calibration parameters
are saved in its EEPROM. An external
micro can read these parameters and
use them to correct that sensor’s readings for offset, temperature dependence and other factors.
So with suitable software, the
BMP180 can provide very high accuracy measurements of both barometric
pressure and temperature. The relative accuracy for pressure is quoted as
±0.12hPa from 950-1050hPa at 25°C,
while the absolute accuracy is quotCelebrating 30 Years
ed as -4 to +2hPa over the range from
300-1100hPa and for temperatures of
0-65°C. Impressive!
With the right software, it’s also
fairly easy to use the BMP180 as an
altimeter, capable of indicating your
current altitude above mean sea level
(MSL). So its applications are not limited to being used as a barometer and
thermometer.
By the way, although the BMP180
normally comes with the I2C serial
interface, a variant is also available
with an SPI interface. Presumably, this
would be for large orders from equipment manufacturers.
By the way, if you’re unfamiliar with
barometers and the various units used
for atmospheric or barometric pressure, you might like to refer to the
panel headed “Barometric Pressure
and Units”.
Elecrow’s GY-68 module
As you can see from the photo of the
Elecrow module, there are few components apart from the BMP180 sensor itself: just an SOT-23 low-dropout
(LDO) voltage regulator, three surfacemount capacitors and two resistors.
Fig.2 shows its complete circuit.
REG1 is the MCP1700 3.3V LDO regulator, used to ensure that the supply
voltage for the BMP180 is kept within
siliconchip.com.au
Fig.1: block diagram of the BMP180 (the small metal
package located on the module). It contains 22 bytes
of EEPROM for storing calibration values.
its ratings (3.6V max). It also ensures
that the two pull-up resistors on the
I2C interface’s SDA and SCL are returned to the same safe voltage level.
The three capacitors are for supply
rail bypassing.
CON1 is the 4-pin connector used
both to supply the module with its
power and also to connect to an external micro via the I2C interface. Since
the module draws less than 10µA from
the supply when it’s taking one measurement per second, there’s no problem in powering it from an Arduino or
a Micromite module or from a power
bank using a 3.7V Li-ion cell.
Fig.2: complete circuit for the GY-68 module. CON1 provides
power and I2C interfacing for the module, which draws less than
10µA when taking readings, and 1µA in standby mode.
to the libraries in your Arduino IDE by
clicking on Sketch → Include Library
→ Add .ZIP Library and then directing it to the folder into which the zip
file was downloaded.
On the Silicon Chip website, you
can find a small sketch for running
the GY-68/BMP180 with an Arduino,
called “SFE_BMP180_barometer_
sketch.ino”. I have adapted it from a
sample sketch provided by Elecrow.
It’s pretty straightforward, first initialising the BMP180 (ie, extracting
the calibration parameters from its
EEPROM) and then taking a measurement of temperature and barometric
pressure every five seconds.
Each time it takes a measurement,
it crunches the data and displays the
results on the Arduino IDE’s Serial
Monitor. A sample of this is shown in
the screen grab of Fig.5.
Since the BMP180 only measures
the temperature and absolute air pressure, the sketch needs to know your
current altitude above sea level in
order to calculate the corresponding
MSL pressure.
Connecting it to a micro
Fig.3 shows a simple way of connecting the GY-68 barometer module to an Arduino. The SCL and SDA
lines of the GY-68 connect to the SCL/
A5 and SDA/A4 pins of the Arduino,
while the VIN and GND lines connect
to the +5V and GND pins respectively.
That’s all there is to it.
It’s equally simple to connect the
module to a Micromite, as you can
see from Fig.4. Here the SCL and SDA
lines connect to pins 17 and 18 of the
Micromite respectively, while as before, the VIN and GND lines go to +5V
and GND.
Programming it
It’s relatively easy to get the GY68 module working happily with an
Arduino, although this does involve
the use of a matching software library
called SFE_BMP180.zip. This can be
downloaded from the Elecrow website at https://github.com/sparkfun/
BMP180_Breakout
After downloading, it can be added
siliconchip.com.au
The Elecrow GY-68 module is shown here at three times actual size, as it is only
13 x 10mm. The metal package BMP180 sensor (3.6 x 3.8mm) is based on piezoresistive MEMS technology.
Celebrating 30 Years
December 2017 79
Fig.3 (top): the pin connections for the GY-68 to an Arduino are fairly
straightforward.
Fig.4 (upper right): pin connections for the GY-68 to a Micromite module.
Fig.5 (bottom left): example data from the GY-68 sensor module when connected to an Arduino.
Fig.6 (right): example data from the module when
connected to a Micromite.
Fig.7 (bottom right): when running the Micromite
sample software, if there is a screen attached, it will
also show the readings on the display.
80
Silicon Chip
Celebrating 30 Years
siliconchip.com.au
This information is fed to it in this
line, located very close to the start of
the sketch:
#define ALTITUDE 55.0
This sets the altitude to 55 metres,
which is a rough estimate of my workbench’s altitude above MSL. However, as the comment on the right of this
line explains, you can easily substitute
your own altitude if you want maximum accuracy.
You’ll note from Fig.5 that the sketch
repeats this altitude figure in the first
line of each set of measurements, giving it in both metres and feet. It also
shows the temperature reading in both
degrees Celsius and degrees Fahrenheit as well as the absolute and MSLrelative pressures in both millibars
and inHg (inch of mercury; reflecting
its origin in the USA).
Finally, it repeats the altitude figures
again, but this time describes them as
“computed altitude”. This sketch is a
good way to see what the GY-68 module can do.
It’s not quite so easy to get the GY68 module working with a Micromite
because there is no pre-existing or
built-in library designed to communicate with it and do the calculations
to provide the corrected temperature
and pressures.
However, I have written an MMBasic
program to do the job and you can download it (“BMP180 barometer check prog.
bas”) from the Silicon Chip website.
This program expects a GY-68/
BMP180 to be connected to the Micromite as shown in Fig.4 so once you do
this and upload the program, it should
spring into life.
If you have the Micromite still connected to your PC and have Micromite
Chat open, you’ll see that it produces
temperature and pressure measurements every second, as shown in the
screen grab of Fig.6.
Just as with the Arduino sketch,
this program also needs to know your
current altitude/elevation in order to
work out the equivalent barometric
pressure at MSL.
As before, you need to substitute
your elevation in this line, which
you’ll find near the start of the program and in about the middle of the
declaration of the program’s variables:
DIM AS INTEGER Alt = 50
Simply substitute your own altitude/elevation above MSL (in metres)
instead of the “50” in this line, then
upload the program to the Micromite
and get it going (by clicking on the little “gearwheel” button in the Micromite Chat toolbar). It will then show
the current mean-sea-level pressure
(MSLP) as the last item in each line.
If your Micromite is hooked up
to an LCD touchscreen, it will also
give you an on-screen display of the
temperature and pressure readings
as shown in the screen shot of Fig.7.
Like the measurements sent back to
your PC, the display is updated every second.
Incidentally, I compared the temperature and pressure readings achieved
using this program with the figures
shown on the Australian Government
Bureau of Meteorology website (which
updates every 10 minutes in the Sydney area), and they compared surprisingly well. The temperature was
within 0.2°C and the MSL pressure
within 0.5hPa; not bad at all for such
a small device!
If you want to make your own comparisons, you’ll find the Bureau of
Meteorology website at www.bom.
gov.au
You just have to select your state,
then Observations, then select your
area in the state.
Barometric Pressure and Units
You’ll find quite a few units in use for measuring atmospheric or barometric pressure: Pascals (Pa) and hectoPascals
(hPa), bars (B) and millibars (mB), millimetres of Mercury (mmHg) and inches of Mercury (inHg).
Basically, atmospheric pressure is due to the weight of air immediately above you and it corresponds to a force per
unit area. The primary SI unit for pressure is the Pascal (Pa), which is equivalent to a force of 1 Newton per square metre. That is, 1Pa = 1N/m2.
It turns out that a column of air one square centimetre in cross section, measured from sea level to the top of the Earth’s
atmosphere, has a mass of about 1.03kg and a weight of 10.1325N. This corresponds to a pressure of 101,132N/m2, or
101,325Pa (= 101.325kPa = 1013.25hPa, since 1hPa = 100Pa). So the standard atmosphere is defined as 101,325Pa
or 1013.25hPa.
The actual barometric pressure at any particular location depends upon its elevation or altitude with respect to mean sea
level (MSL), because the higher the elevation, the lower the weight of air directly above you and the lower the pressure.
For low altitudes, it can be estimated as falling by about 10hPa for every 100m rise above MSL. For higher altitudes,
the pressure at any elevation/altitude can be found by a standard expression known as the Barometric Formula.
The first barometers (invented in 1643 by Italian physicist Evangelista Torricelli) used to measure atmospheric pressure used a column of mercury in a vertical glass tube and as a result, they were calibrated in terms of the height of
the mercury column, measured in either millimetres or inches. So that’s where the “mmHg” and “inHg” units of pressure came from.
In fact, “inHg” is still used in the United States, Canada and Colombia. For the record, one standard atmosphere of
1013.25hPa is equivalent to 760mmHg or 29.92inHg.
So where do the bar and the millibar units fit in? Well, the bar was a unit of weight used in the metric system before
about 1800. Then around 1890, it was used as a unit of atmospheric pressure by Norwegian physicist and pioneering
meteorologist Vilhelm Bjerknes. Since then, it has been used sporadically as a unit of atmospheric pressure, although
nowadays it is frowned upon and not regarded as part of the SI system of metric units.
For the record, 1 bar is regarded as equal to 100kPa or 1000hPa and 1mbar equal to 1hPa or 100Pa. Thus, a standard atmosphere corresponds to 1013.25mbar or 1.01325bar. For more information, see https://en.wikipedia.org/wiki/
Atmospheric_pressure
siliconchip.com.au
Celebrating 30 Years
December 2017 81
The GY-BM module shown above,
close to actual size.
Fig.8: complete circuit diagram for the GY-BM module. Compared to the GY-68's
circuit shown in Fig.2, this device is quite a bit simpler in design, removing the
need for an external regulator.
You’ll then see a list of observation stations in that area and then
when you click on a station near you,
you’ll see a list of the weather data
for that day, including temperature
and MSLP.
The new GY-BM module
Elecrow have recently added a second digital Barometer/Temperature
module to their range: the GY-BM
module, based on Bosch Sensortec’s
new BMP280 digital sensor IC.
The new module is only slightly
larger than the GY-68, but it is still
very small – measuring only 15 x 11 x
3mm. On the other hand, the BMP280
sensor IC itself is even smaller than
the BMP180, measuring only 2.0 x
2.5 x 0.95mm.
Despite this tiny size the BMP280
offers some advantages over the
BMP180. These include a dual-mode
SPI interface (modes “00” or “11”) in
addition to the I2C interface, higher
measurement resolution for both pressure (0.16Pa vs 1Pa) and temperature
(0.01°C vs 0.1°C), lower current consumption (2.7µA vs 12µA) and an internal software configurable IIR filter
to allow minimisation of short-term
air pressure disturbances.
In terms of absolute accuracy, the
BMP280 is essentially identical to the
BMP180. Pressure accuracy is ±1hPa
from 0-65°C, while the temperature
accuracy is ±0.5°C at 25°C and ±1.0°C
from 0-65°C.
The internals of the BMP280 appear to be very similar to those of
the BMP180 shown in Fig.1, apart
from it being provided with an SPI
The new GY-BM module is a tad larger than the previous GY-68 model and
the BMP280 has near identical performance to the BMP180.
82
Silicon Chip
Celebrating 30 Years
interface as well as the I2C interface.
The calibration parameters are again
stored in a 22-byte internal EEPROM/
NVM (non-volatile memory) during
manufacture.
The circuit of the GY-BM module
is shown in Fig.8, and as you can see
it’s even simpler than that of the GY68 module shown in Fig.2. That is because the GY-BM module is intended
to run only from a nominal 3.3V supply, and as a result it has no on-board
LDO (low dropout) regulator.
On the other hand, it has a sixpin connector (CON1) compared to
the four pins of the GY-68. The two
extra pins are required because the
optional SPI interface requires four
pins, compared to just two for the
I2C interface.
To connect the GY-BM module to
a micro using the I2C interface, the
SDA line should be connected to pin
6 of CON1, while the SCL line is connected to pin 3.
Additionally, the CSB pin (CON1
pin 5) should be left floating, so it’s
pulled high via the 10kW pullup resistor – this signals to the BMP280 that
the I2C interface is to be used.
Finally, pin 4 of CON1 can be used
to set the module’s I2C address, connecting it to ground to give it the same
"default" address as the BMP180, or
connecting it to VIN (+3.3V) to give it
a different address.
However, if you want to connect
the GY-BM module to a micro using a
standard four-wire SPI interface, the
SDI line should be connected to pin
6 of CON1, the SDO line to pin 4 of
CON1, the SCK line to pin 3 of CON1
and finally the CSB (Chip Select-bar)
line to pin 5 of CON1.
The GY-BM module should be just
as easy to use as the GY-68 module.
Just make sure that you connect its
supply input VIN (CON1 pin 1) to
+3.3V, not the +5V supply used for
the GY-68 module. Otherwise the
BMP280 chip may be irrevocably
SC
damaged.
siliconchip.com.au
It’s not long to
Christmas – (just 3
weeks or 25 days!)
Here’s the perfect
Christmas Gift:
A SILICON CHIP subscription!
It’s the gift that keeps on giving – month after month after month!
If you know someone interested in electronics, why not give them a Silicon Chip gift
subscription? (Or even reward yourself if no-one else will!)
SILICON CHIP is Australia’s leading monthly magazine focused on electronics and
technology. Whether they’re a PhD in quantum mechanics, or the newest beginner
just starting out, SILICON CHIP is the one magazine that they’ll want to read from
cover to cover, every month.
Print subscriptions actually cost less than buying over the counter! Prices start at just
$57 for six months, $105 for 12 months or $202 for 24 months – INCLUDING postage!
And yes, we have binders available (Australia only) to keep those magazines safe!
Taking out a gift subscription for someone special has never been easier. Simply go
to our website, click on the <SUBSCRIBE> tab and select <GIFT SUBSCRIPTIONS>.
We’ll even send a special message from you to the recipient . . . AND we’ll send you a
reminder when the subscription is about to fall due. What could be easier?
Or call us – 02 9939 3295, between 9am and 5pm Monday to Friday (AEDST).
4
4
4
4
4
4
Remember, it’s cheaper to subscribe anyway . . . do the maths and see the saving!
Remember, we pick up the postage charge – so you $ave even more!
Remember, they don’t have to remember! It’s there every month in their letter box!
Remember, your newsagent might sell out – and they’ll miss out!
Remember, there’s also an on-line version you can subscribe to if you’re travelling.
Remember, subscribers qualify for a 10% discount on any item from the*excluding
online
shop*
subscriptions
We’re waiting to welcome them – or you – into the SILICON CHIP subscriber family!
A GIFT SUBSCRIPTION MAKES LOTS OF SENSE AND SAVES LOTS OF CENTS!
www.siliconchip.com.au
|