Advertisement

DIY Bosch BMP280 Pressure Sensor Project Primer

Nowadays, numerous electronic sensor modules are available on the market that can be combined with inexpensive microcontroller boards to measure environmental parameters of importance. The project presented here is a starter one that monitors and displays two prominent environmental parameters: air pressure and air temperature. At the heart of the project is a GY-BM E/P 280 module — actually a cheap Chinese variant of the estimable Adafruit BMP280 module, realized with the BMP280 digital pressure sensor from Bosch (www.bosch-sensortec.com). Bosch’s BMP280 is an absolute barometric pressure sensor especially designed for mobile applications. However, note that there’s also another version of the BMP280 chip: the BME280. As found in a forum, the main difference here is that the E version denotes “environmental” (pressure, temperature, and humidity), and the P version denotes “pressure” (temperature and pressure).

 

The GY-BM E/P 280 Module

 

PCB details of the Bosch BMP280 pressure sensor breakout board.

 

Unlike Adafruit’s BMP280 module, this Chinese module GY-BM E/P 280 comes as a six–pin module designed for 3.3-V operation; hence, you should add an external 3.3-V regulator (and a logic-level shifter) if you want to interface this module with any 5-V microcontroller. Although the notations of the pins indicated on the module are for I²C with default I²C address of 0x76, the module simply supports both I²C and SPI interfaces.

 

The BMP280 module pinout description.

 

The chip select (CSB) and serial data output (SDO) pins of the BMP 280 are necessary only when SPI-based (four-wire) communication is applied. For SPI, keep an eye on the pin assignments: VCC-VCC/GND-GND/SCL-SCK/SDA-MOSI/CSB-SS/SDO-MISO. Now to the official schematic of the GY-BM E/P 280 module:

 

The BMP280 module schematic.

 

First Test with Arduino

Connecting the GY-BM E/P 280 module to an Arduino is very easy being that there are only four wires between them:

 

  • VCC > Arduino VCC (3.3 V)
  • GND > Arduino GND
  • SCL > Arduino A5
  • SDA > Arduino A4

 

Also see the hardware setup diagram shown below:

 

Hardware wiring diagram. Note, you may need a level shifter depending on which Arduino board you use and its voltage requirements.

 

Next is the software to read barometric pressure and temperature from the hardware. The test code (sketch) included here provides the serial monitor output of barometric pressure and temperature. Two dedicated libraries are required here to support the code: Adafruit_BMP280 and Adafruit_Sensor. Once these libraries are installed, you just have to compile the test code, upload it, and run.

 

/*

 * GY-BM E/P 280 Module

 * Barometric Pressure & Temperature Sensor

 * Basic Test Sketch/Arduino Uno I2C

 * Chip Id: 0x58 / Address: 0x76 (if SDO=0)

 * Refined Sketch: Prepared & Tested by T.K.Hareendran

 */




#include <Wire.h>;

#include <Adafruit_Sensor.h>;

#include <Adafruit_BMP280.h>;




//I2C Interface

Adafruit_BMP280 bme;




 

void setup()

{

  Serial.begin(9600);

  if (!bme.begin())

  { 

    Serial.println(“Error! No BMP Sensor Detected!!!”);

    while (1);

  }

}

 

void loop()

{

    Serial.print(“------------BMP 280 -------------\n”);

    Serial.print(“Temperature = “);

    Serial.print(bme.readTemperature());

    Serial.println(“ *C”);

    Serial.print(“Pressure = “);

    Serial.print(bme.readPressure() / 100); // 100 Pa = 1 millibar (Pa = newton per square meter)

    Serial.println(“ mb”);

    Serial.print(“Approx Altitude = “);

    Serial.print(bme.readAltitude(1013.25)); // This should be lined up (atmospheric pressure at sea level is 1013 millibars)

    Serial.println(“ m”);

    Serial.print(“--------------------------------\n\n”);

    delay(2000);

}

 

 

Because this specific module is somewhat different than many others, you may need to change Line 37 in Adafruit_BMP280.h as #define BMP280_ADDRESS (0x76). See my Arduino 1.6.9 IDE screenshot given below:

 

Lines which may need to be edited depending on the exact address and chip ID.

 

And here is the random screenshot of my serial monitor:

 

The serial monitor displaying data being read from the BMP280 sensor.

 

There’s one important thing you need to note. The actual sensor-element in the module has a tiny hole; you should not cover this. Also, the sensor should not be in a direct wind path as it could cause erratic readings!

 

Summing Up

BMP280 from Bosch is a compact digital sensor that very accurately measures air pressure and simultaneously determines air temperature with reasonable accuracy. One advantage of this sensor is that it allows I²C and SPI interfaces that are supported by the Arduino family of microcontroller boards. I considered it as an active device to start experimenting with some portable weather station projects. My goal is to fabricate a truly portable Arduino (Nano or Pro Mini) Weather Station with a lippy display panel (TFT or OLED) to show at least three parameters — air pressure, ambient temperature, and relative humidity. Hopefully, the succeeding part of this article (thoughts about all things around my new project) will be published soon!

6 Comments

Join the conversation!

Error! Please fill all fields.
  • T.K.Hareendran

    @Adam: On the dot, dreaming, after all is a form of planning 🙂

  • T.K.Hareendran

    @Adam Carlson: I’m in a dream state! Hopefully, we can get something going in near-future. Thank you for inspiring me 🙂

    • Adam Carlson

      I always love thinking of the possibilities! Electronics really opens up a world of possibilities.

  • Adam Carlson

    TK, are you going to use this with you Radio Project from last week? I could see this as a great addition to that project.

    • Adam Carlson

      This could be interesting as a small weather radio. You could also set it up that it could connect to remote sensors when it was in range. You could make those sensors open access such that anyone with a similar device could then access those sensors. Ok, I need to stop dreaming, but it is fun to really think what could be done! 😉

    • T.K.Hareendran

      @Adam Carlson: Actually I wanted to build a portable weather station with some nice features. Thank you for the great idea of blending this with the radio. Sure, will try this after a short break!

Looking for the latest from TI?