BMP180 sensor with Arduino code | BMP180 pressure sensor tutorial [Step by step instruction]

BMP180 sensor with Arduino code

        Hello guys, welcome back. In this tutorial, we will learn how to work the BMP 180 pressure sensor with Arduino code. This sensor has a very small shape through which the atmospheric pressure can be measured. Also, as this pressure decreases as it rises above sea level, it can also be used to get altitude. It can also be used to monitor weather changes. We can use this sensor mainly to making things like weather monitoring systems and drones.

BMP180 sensor with Arduino code

BMP180 sensor structure

This is a very small sensor and includes a chip called the BMP180. This chip measures both pressure and temperature. Also, this chip can measure barometric pressures between 300 hPa and 1100 hPa and temperatures between -40C and 85C. Next, if we talk about the power required for this sensor, it operates with a potential of 3.3v. However, due to the LM6206 voltage regulator included here, even a potential of 5v can be used. That is, a potential of 3.3 to 5 can be used for this. We can also get the values of this sensor through I2C communication. Through this, we can get the values of all the three factors of temperature, pressure, and altitude.

The PIN structure of this BMP180 sensor

BMP180 sensor with Arduino code
Okay, now we will learn step by step how to activate this sensor with Arduino. The required components are as follows.
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, identify these components.

Arduino Nano board

BMP180 sensor

LCD display

I2C module

Jumper wires

Breadboard

Step 2

Secondly, connect these components. To do this, use the circuit diagram below.
BMP180 sensor circuit diagram

Step 3

Thirdly, we will create the necessary program for this. It is as follows. Also, you need to download and install the BMP180 library and I2C library.
BMP180 library — Download
I2C library — Download
The complete program of this project – Download
OK, let’s look at the code below.
/*BMP-180 Pressure sensor tutorial.
   Created by the SriTu Hobby team.
   https://srituhobby.com
*/
 
#include <LiquidCrystal_I2C.h>
#include <SFE_BMP180.h>
#include <Wire.h>
 
#define ALTITUDE 390.0 //Enter your country evalution
 
LiquidCrystal_I2C lcd(0x27, 16, 2);
SFE_BMP180 bmp;
double T, P, S, A;
char status;
 
void setup() {
  Serial.begin(9600);
  bmp.begin();
  lcd.init();
  lcd.backlight();
}
 
void loop() {
  Serial.println();
  Serial.print(“provided altitude: “);
  Serial.print(ALTITUDE, 0);
  Serial.print(” meters, “);
  Serial.print(ALTITUDE * 3.28084, 0);
  Serial.println(” feet”);
 
  status =  bmp.startTemperature();
  if (status != 0) {
    delay(status);
    status = bmp.getTemperature(T);
    if (status != 0) {
      Serial.print(“Temperature :”);
      lcd.setCursor(0, 0);
      lcd.print(“Temp :”);
      lcd.print(T, 2);
      lcd.print(“C”);
      lcd.print(” “);
      Serial.print(T, 2);
      Serial.println(“*c”);
    }
    status = bmp.startPressure(3);// 0 to 3
    if (status != 0) {
      delay(status);
      status = bmp.getPressure(P, T);
      if (status != 0) {
        Serial.print(“absolute pressure: “);
        lcd.setCursor(0, 1);
        lcd.print(“Pres :”);
        lcd.print(P, 2);
        lcd.print(“mb”);
        lcd.print(” “);
        Serial.print(P, 2);
        Serial.println(“mb”);
      }
 
      S = bmp.sealevel(P, ALTITUDE);
      Serial.print(“relative (sea-level) pressure: “);
      Serial.print(S);
      Serial.println(“mb”);
 
      A = bmp.altitude(P, S);
      Serial.print(“computed altitude: “);
      Serial.print(A, 0);
      Serial.print(” meters, “);
      Serial.print(A * 3.28084, 0);
      Serial.println(” feet”);
 
      delay(3000);
 
    }
  }
}

Code explanation

Firstly, three libraries are included. They are I2C, BMP180, and wire.
#include <LiquidCrystal_I2C.h>
#include <SFE_BMP180.h>
#include <Wire.h>
 
Secondly, you need to include your city evaluation. Use the search browser to find this.
#define ALTITUDE 390.0 //Enter your country evalution
 
Next, creates objects for the I2C library and BMP180 library. Afterward, several variables were created to help the program.
LiquidCrystal_I2C lcd(0x27, 16, 2);
SFE_BMP180 bmp;
double T, P, S, A;
char status;
In the setup function, the library and serial monitor are started.
void setup() {
  Serial.begin(9600);
  bmp.begin();
  lcd.init();
  lcd.backlight();
}
 
In the loop function, temperature, pressure, and altitude factors are print on the serial monitor and LCD. These codes are included in the library file. Please study it.
void loop() {
The provided altitude is displayed on the serial monitor.
  Serial.println();
  Serial.print(“provided altitude: “);
  Serial.print(ALTITUDE, 0);
  Serial.print(” meters, “);
  Serial.print(ALTITUDE * 3.28084, 0);
  Serial.println(” feet”);
 
The temperature value is displayed on the serial monitor and LCD.
  status =  bmp.startTemperature();
  if (status != 0) {
    delay(status);
    status = bmp.getTemperature(T);
    if (status != 0) {
      Serial.print(“Temperature :”);
      lcd.setCursor(0, 0);
      lcd.print(“Temp :”);
      lcd.print(T, 2);
      lcd.print(“C”);
      lcd.print(” “);
      Serial.print(T, 2);
      Serial.println(“*c”);
    }
 
The pressure value is displayed on the serial monitor and LCD.
    status = bmp.startPressure(3);// 0 to 3
    if (status != 0) {
      delay(status);
      status = bmp.getPressure(P, T);
      if (status != 0) {
        Serial.print(“absolute pressure: “);
        lcd.setCursor(0, 1);
        lcd.print(“Pres :”);
        lcd.print(P, 2);
        lcd.print(“mb”);
        lcd.print(” “);
        Serial.print(P, 2);
        Serial.println(“mb”);
      }
 
The relative pressure is displayed on the serial monitor.
      S = bmp.sealevel(P, ALTITUDE);
      Serial.print(“relative (sea-level) pressure: “);
      Serial.print(S);
      Serial.println(“mb”);
 
The computed altitude displayed on the serial monitor.
      A = bmp.altitude(P, S);
      Serial.print(“computed altitude: “);
      Serial.print(A, 0);
      Serial.print(” meters, “);
      Serial.print(A * 3.28084, 0);
      Serial.println(” feet”);
 
      delay(3000);
 
    }
  }
}
 

Step 4

OK, finally select board and port. Afterward, upload this code to the Arduino board.
So, now you can test this sensor. For that, use the video below. We will meet in the next tutorial.

BMP180 sensor with Arduino code | BMP180 pressure sensor tutorial [Step by step instruction]

Similar Posts

2 Comments

Leave a Reply

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