top of page

Arduino Based BMP280 Pressure, Temperature and Altitude Measure



In this tutorial shows how to connect BMP280 barometric pressure ,temperature and altitude sensor interface to Arduino UNO board with 4 line LCD display. It is ideally used for environment-related applications where pressure is a very critical parameter to work with. It is further useful in drones where pressure, temperature, and altitude can be useful to monitor and make further observations.


Circuit Diagram



Components Required

Arduino Uno - 1 no

LCD 20x4 I2C - 1 no

BMP/BME 280 - 1no



BMP280 Pressure Sensor Module:

The GY-BMP280 Barometer Sensor is a breakout board for Bosch BMP280 high-precision and low-power digital barometer. It can be used to measure temperature and atmospheric pressure accurately. It can be connected to a microcontroller with I2C.


Features

  • The GY-BMP280 module comes with BMP280 sensor, which is an environmental sensor with temperature, barometric pressure that is the next generation upgrade to the BMP085/BMP180/BMP183.

  • This sensor is great for all sorts of weather sensing and can even be used in both I2C and SPI.

  • This precision sensor is the best low-cost, precision sensing solution for measuring barometric pressure with ±1 hPa absolute accuracy, and temperature with ±1.0°C accuracy. Because pressure changes with altitude and the pressure measurements are so good, you can also use it as an altimeter with ±1 meter accuracy

  • Pin pitch: 2.54mm

  • Module size: 11.5mm*15mm

Electrical specifications of GY-BMP280 Module

  • Model: GY-BMP280-3.3

  • Chip: BMP280

  • Power supply: 3V/3.3V DC

  • Peak current: 1.12mA

  • Air pressure range : 300-1100hPa (equi. to +9000…-500m above sea level)

  • Temperature range: -40 … +85 °C

  • Digital interfaces: I²C (up to 3.4 MHz) and SPI (3 and 4 wire, up to 10 MHz)

  • Current consumption of sensor BMP280: 2.7µA @ 1 Hz sampling rate

How to use GY-BMP280 Module?


The GY-BMP280 module operates from 3.3V so requires 3.3V power and must be driven with 3.3V logic levels. If needed to operate at 5V, it can be done using voltage regulator and level shifters as it doesn’t contain one. It is typically recommended to operate it on 3.3V and maximum at 3.6VDC. The module GY-BMP280 module simply supports both I²C and SPI interfaces and comes with default I²C address of 0x76. 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. I2C is a two wire interface SDA SCK.

Leave pin 6 of the module (SDO) unconnected to set the I²C address to 0x76 – the on-board resistor pulls the SDO pin low setting the address to 0x76.

To change the I²C address to 0x77, connect pin 6 of the module (SDO) to Vcc which would typically be the 3.3V supply.

Pin 5 of the module (CSB) must be connected to Vcc to select the I²C interface. This is already done by an on-board pull-up resistor, so pin 5 can be left disconnected when using the I²C interface.

Applications of GY-BMP280 Module

  • Enhancement of GPS navigation (e.g. time-to-first-fix improvement, dead-reckoning, slope detection)

  • Indoor navigation (floor detection, elevator detection)

  • Outdoor navigation, leisure and sports applications

  • Weather forecast, Home weather stations

  • Health care application (e.g. sirometry)

  • Vertical velocity indication (e.g. risk/sink speed)

  • Handsets such as mobile phones, tablet PCs, GPS devices

  • Flying toys

  • Watches



Installing the Arduino Library

LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library.

Download Adafruit_BMP280_Library , we need to use this library.

Follow the next steps to install those libraries.


In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded.


After installing the required libraries, copy the following code to your Arduino IDE.


Subscribe and Download code.



Arduino code:

#include <Wire.h>

#include <SPI.h>

#include <Adafruit_BMP280.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display


Adafruit_BMP280 bmp; // I2C

Adafruit_Sensor *bmp_temp = bmp.getTemperatureSensor();

Adafruit_Sensor *bmp_pressure = bmp.getPressureSensor();

//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI

//Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);


void setup() {

Serial.begin(9600);

lcd.init(); // initialize the lcd

// Print a message to the LCD.

lcd.backlight();

Serial.println(F("BMP280 test"));


//if (!bmp.begin(BMP280_ADDRESS_ALT, BMP280_CHIPID)) {

if (!bmp.begin()) {

Serial.println(F("Could not find a valid BMP280 sensor, check wiring or "

"try a different address!"));

while (1) delay(10);

}


/* Default settings from datasheet. */

bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */

Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */

Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */

Adafruit_BMP280::FILTER_X16, /* Filtering. */

Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */

bmp_temp->printSensorDetails();

}


void loop() {

sensors_event_t temp_event, pressure_event;

bmp_temp->getEvent(&temp_event);

bmp_pressure->getEvent(&pressure_event);

Serial.print(F("Temperature = "));

Serial.print(bmp.readTemperature());

Serial.println(" *C");


Serial.print(F("Pressure = "));

Serial.print(pressure_event.pressure);

Serial.println(" hPa");


Serial.print(F("Approx altitude = "));

Serial.print(bmp.readAltitude(1013.25)); /* Adjusted to local forecast! */

Serial.println(" m");


Serial.println();

lcd.setCursor(0,0);

lcd.print("BMP 280 Live Monitor");

lcd.setCursor(0,1);

lcd.print("T (");

lcd.print((char)223);

lcd.print("C): ");

lcd.print(bmp.readTemperature());

lcd.print(" ");

lcd.setCursor(0,2);

lcd.print("P(hPa): ");

lcd.print(pressure_event.pressure);

lcd.print(" ");

lcd.setCursor(0,3);

lcd.print("A (m): ");

lcd.print(bmp.readAltitude(1013.25));

lcd.print(" ");

delay(2000);

}


After a successful upload, open the Serial Monitor at a baud rate of 9600. Press the “EN/RST” button on the Arduino Uno board and see the result in monitor.


Comentarios


bottom of page