Next up in my Arduino research is the BMP280 pressure/temperature module. This is a device manufactured by Bosch, and is ideally suited to high altitude balloon atmospheric measurements.

The bmp280 datasheet has many details about the device.  Each module based on this device will have its own quirks, but they seem to generally follow the datasheet for functionality.

Major differences noted between modules are the inclusion or lack of level conversion, ie 5v to 3.3v.  Since the device runs on 3.3v, if you want to use it with most Arduinos at 5v, you will need to check that the module includes a 3.3v regulator and level conversion scheme.

If there is no voltage conversion on the module, you should only use it with 3.3v based Arduinos, such as the Due.

The Adafruit module that I selected does include the necessary voltage conversion circuitry.  So it may be run on either 5v or 3.3v Arduinos without fear of killing anything.

Adafruit BMP280 Module

I began my research by downloading the Adafruit libraries that simplify talking to the module.  I used the IDE Manage Libraries function to search for BMP280, and install them on my laptop.

Manage Libraries

 

Install BMP280 Library

I notice that there are several libraries for the bmp280, and I may explore them after my initial research.  They may have better ways of interacting with the module, or may perhaps be smaller in size.

Next, I looked for an example sketch that is often included with libraries.  I found on and loaded it into the IDE.

Example Sketch

On my first attempt to compile this sketch, I found that I was missing a second library that the first one relies on: the Adafruit Unified Sensor Library. I should have caught that, by the extra Adafruit_Sensor.h include file specified.

Unified Sensor Missing

I found it and installed it, as well.

Unified Sensor Library

 

RBBB (Really Bare Bones Board) BMP280 Testing

Once I installed the second library, I was able to compile for the RBBB (Really Bare Bones Board) without errors.

Compile Success RBBB

I was surprised that this worked, as I was anticipating that the RBBB was going to fall short on memory again, but these libraries must be smaller than the SD Card libraries I was experimenting with earlier.

There is a nice hookup guide with specifics for use with the Arduino at the startingelectronics.org site.

Following the Adafruit guide, I wired up the RBBB with the pins specified for an Arduino Uno on page 12, and was successful running the test program using I2C communication.

BMP280 Card Pin Arduino RBBB Pin
VCC POWER 5V
GND POWER GND
SCK A5
SDI A4

 

RBBB wired for I2C

After downloading the program, and opening the serial port monitor, I saw that the sensor was providing seemingly valid pressure and temperature readings.

Valid Output

The Adafruit module uses the SDO pin to determine which of two I2C addresses the module wil respond to: 0x77 or 0x76.  Since the pin is tied high through a pullup resistor on the board, it defaults to 0x77, and is compatible with the library default address.

SDO Pulled High

When you apply a ground to the SDO pin, it pulls the input low, and changed the I2C address to 0x76.

bmp280 I2c 0x76 test

If you do this, you must change the expected address for the bmp280test program to match the hardware.  There are two ways to accomplish this:

The first way is to modify the begin() function call in the bmp280test program by adding the correct address in the parenthesis following the begin statement. ie…

I2C Address in begin() call

The second way is to open the ADAFRUIT_BMP280.h file and edit the entry for 0x77 to 0x76.  Then it will work.  This is handy to know, since not all manufacturers will be set up for the 0x77 address.

adafruit_bmp280.h entry

If you have a device with the wrong address selected, you may see the “not found” error:

wrong address

If you have any doubts about what address your device is set up for, you can install the i2cdetect library and run the example code to detect what addresses the device on your I2C bus supports.

I2C Detect Library

In the default configuration, the i2cdetect program finds address 0x77, as expected…

i2cdetect 0x77

When I ground the SDO pin, the i2cdetect program detects the module on address 0x76…

i2cdetect 0x76

So, after testing with address 0x76, and getting identical output as I did for address 0x77,  I set up the bmp280test program to talk to the module using SPI software communications.

BMP280 SPI Test

 

BMP280 Card Pin Arduino RBBB Pin
VCC POWER 5V
GND POWER GND
SCK 13
SDO 12
SDI 11
CS 10

Note the use of pin 10 for a chip select.  The BMP280 uses this CS pin to determine whether to talk over I2C or SPI.  When we drive it low, it chooses SPI communication.  When it is high, it selects I2C communication.

In addition to the hardware changes, I had to modify the test program to use SPI, as well, by commenting out the I2C selection line and un-commenting the SPI Software selection line.

SPI Software setup

This configuration worked fine.

Next, I switched to Hardware defined SPI.  The wiring happened to remain the same for this, although it may be different with other kinds of Arduinos.

I changed the lines in the test program to turn off I2C and Software SPI, and turn on Hardware SPI.

Hardware SPI setup

The module worked fine in this configuration, as well.

 

Arduino Duemilanove and Uno BMP280 Testing

The Arduino Duemilanove and Uno share pinouts with the RBBB board, with some additional components to support a USB programming jack, and an led on pin 13.

This boards worked fine in I2C communication mode with the following connections:

BMP280 Card Pin Arduino Duemilanove/Uno Pin
VCC POWER 5V
GND POWER GND
SCK A5
SDI A4

 

For SPI communications, I connected the pins as follows:

BMP280 Card Pin Arduino Duemilanove/Uno Pin
VCC POWER 5V
GND POWER GND
SCK 13
SDO 12
SDI 11
CS 10

This configuration worked for both Hardware and Software SPI communications.

 

I also used the SPI connector on the boards to do SPI Hardware Comms:

BMP280 Card Pin Arduino Duemilanove/Uno Pin
VCC POWER 5V
GND POWER GND
SCK ICSP-3
SDO ICSP-1
SDI ICSP-4
CS 10

 

Arduino Mega2560 BMP280 Testing

The Mega2560 has a little different connections

For I2C Communications:

BMP280 Card Pin Arduino Mega Pin
VCC POWER 5V
GND POWER GND
SCK 21 (SCL)
SDI 20 (SDA)

And for SPI Software Comms, I used:

BMP280 Card Pin Arduino Mega Pin
VCC POWER 5V
GND POWER GND
SCK 13
SDO 12
SDI 11
CS 10

For Hardware SPI via the ICSP Port, I used:

BMP280 Card Pin Arduino Mega Pin
VCC POWER 5V
GND POWER GND
SCK ICSP-3
SDO ICSP-1
SDI ICSP-4
CS 10

 

Arduino Due BMP280 Testing

The Due only differs from the Mega pinout in that it uses a 3.3v supply.

For I2C Communications:

BMP280 Card Pin Arduino Due Pin
VCC POWER 3.3V
GND POWER GND
SCK 21 (SCL)
SDI 20 (SDA)

And for SPI Software Comms, I used:

BMP280 Card Pin Arduino Due Pin
VCC POWER 3.3V
GND POWER GND
SCK 13
SDO 12
SDI 11
CS 10

For Hardware SPI via the ICSP Port, I used:

BMP280 Card Pin Arduino Due Pin
VCC POWER 3.3V
GND POWER GND
SCK ICSP-3
SDO ICSP-1
SDI ICSP-4
CS 10