Pantech.AI

How to Interface BPM180 Barometer Sensor with Arduino UNO

Description

BMP180 Barometer Sensor

The BMP180, developed by Bosch Sensortec, is a widely used digital barometric pressure and temperature sensor known for its high accuracy and resolution. It is capable of measuring atmospheric pressure, temperature, and altitude. The BMP180 utilizes a piezo-resistive pressure sensor to measure absolute air pressure, while a temperature sensor compensates for any temperature fluctuations, ensuring precise readings. Using these measurements, the BMP180 can also calculate altitude above sea level. The module communicates with a microcontroller via the I2C protocol.

BMP180 Module Specification

  • Pressure Range: 300 hPa to 1100 hPa with a resolution of 0.1 hPa
  • Altitude Range: -500 m to 9000 m with a resolution of 0.1 m (0.328 ft)
  • Accuracy: ±1 hPa for pressure, ±1°C for temperature, and ±1 meter for altitude under standard conditions
  • Temperature Range: -40°C to +85°C
  • Interface: I2C, up to 3.4 MHz
  • Supply Voltage: 1.8 V to 3.6 V

BMP180 Pinouts

BMP180 Pin Description

  • VCC: Connects to the positive supply of 3.3V
  • GND: Common ground pin
  • SCL: Serial Clock Line pin for I2C communication
  • SDA: Serial Data pin for I2C communication

BMP180 Hardware Connection with Arduino

Connection diagram of BMP180 with Arduino Barometer Sensor

Extracting Data from BMP180 using Arduino

Reading values from the BMP180 sensor and displaying them on the Arduino IDE Serial Monitor.

In this example, we will use Adafruit’s BMP180 library, Adafruit_BMP085.h, which can be downloaded from the Arduino IDE’s Library Manager.

Now, open an example from the Adafruit ADXL345 library. To do this, navigate to File -> Examples -> Adafruit BMP180 Library -> bmp085test.

Code for reading values and display it on the Serial Monitor

/***************************************************
  This is an example for the BMP085 Barometric Pressure & Temp Sensor

  Designed specifically to work with the Adafruit BMP085 Breakout 
  ----> https://www.adafruit.com/products/391

  These pressure and temperature sensors use I2C to communicate, 2 pins
  are required to interface
  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries. 
  BSD license, all text above must be included in any redistribution
 ****************************************************/

// Connect VCC of the BMP085 sensor to 3.3V (NOT 5.0V!)
// Connect GND to Ground
// Connect SCL to i2c clock - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 5
// Connect SDA to i2c data - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 4
// EOC is not used, it signifies an end of conversion
// XCLR is a reset pin, also not used here

Adafruit_BMP085 bmp;
 
void setup() {
  Serial.begin(9600);
  if (!bmp.begin()) {
      Serial.println("Could not find a valid BMP085 sensor, check wiring!");
      while (1) {}
  }
}
 
void loop() {
    Serial.print("Temperature = ");
    Serial.print(bmp.readTemperature());
    Serial.println(" *C");
   
    Serial.print("Pressure = ");
    Serial.print(bmp.readPressure());
    Serial.println(" Pa");
   
    // Calculate altitude assuming 'standard' barometric
    // pressure of 1013.25 millibar = 101325 Pascal
    Serial.print("Altitude = ");
    Serial.print(bmp.readAltitude());
    Serial.println(" meters");

    Serial.print("Pressure at sealevel (calculated) = ");
    Serial.print(bmp.readSealevelPressure());
    Serial.println(" Pa");

  // you can get a more precise measurement of altitude
  // if you know the current sea level pressure which will
  // vary with weather and such. If it is 1015 millibars
  // that is equal to 101500 Pascals.
    Serial.print("Real altitude = ");
    Serial.print(bmp.readAltitude(101500));
    Serial.println(" meters");
   
    Serial.println();
    delay(500);
}
 
  • Upload the code to your Arduino board.
  • After uploading, open the Serial Monitor.
  • Set the baud rate to 9600 to view the output.

Output on the serial monitor

Let’s understand the code

Initially, we imported the BMP180 library.

The Adafruit_BMP085.h library contains all the necessary functions and classes for retrieving data from the BMP180 module.

#include <Adafruit_BMP085.h>

Next, we created an object of the Adafruit_BMP085 class named bmp.

Adafruit_BMP085 bmp; 
  • In the setup function, we set the baud rate to 9600.
  • Then, we used an if condition to check if the module is connected properly by calling the begin() function.
void setup() {
 Serial.begin(9600);
  if (!bmp.begin()) {
   Serial.println("Could not find a valid BMP085 sensor, check wiring!");
   while (1) {}
  }
}

In the loop function, we extracted data from the module using functions like readTemperature(), readPressure(), readAltitude(), and readSealevelPressure(). The values obtained from these functions are displayed on the serial monitor one by one, continuously in a loop.

Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.println(" *C");

Serial.print("Pressure = ");
Serial.print(bmp.readPressure());
Serial.println(" Pa");
Serial.print("Altitude = ");
Serial.print(bmp.readAltitude());
Serial.println(" meters");

Serial.print("Pressure at sealevel (calculated) = ");
Serial.print(bmp.readSealevelPressure());
Serial.println(" Pa");
Serial.print("Real altitude = ");
Serial.print(bmp.readAltitude(101500));
Serial.println(" meters");

Serial.println();
delay(500);

Leave a Comment

Your email address will not be published. Required fields are marked *