Diyprojectslab is an education website in Electronics Engineering Site related to Projects & Tutorials in Embedded, Arduino, Internet of Things (IoT), Tips, Tricks, How It Works, Projects..

Interfacing Pressure Sensor BMP180 with Arduino Uno

0

Overview

Hi Welcome In DiY Projects Lab  today we will explain how to interface Bmp180 with Arduino And 16×2 Display  . The brain of this project is an Arduino UNO board which in combination with BMP180 sensor provides a decent user interface.

This project  is available in video format (watch below) and in written format.

You can get the components for This projects  from the links below:

1. Arduino UNO  x1 

2. BMP180 Sensor x1

3. LCD 16×2   x1

WHAT IS A BMP180 Sensor?BMP180 Barometric Sensor Arduino | Random Nerd Tutorials

The BMP180 barometric pressure sensor  is designed to read atmospheric pressure and the height above sea level indirectly. Atmospheric pressure is the force exerted by air (atmosphere) on the surface of the earth. Atmospheric pressure is due to the weight of the air column over a given area, it is for this reason that when measuring atmospheric pressure at points with higher altitude, the pressure value is lower because the amount of air is lower. Atmospheric pressure also varies with climate, mainly with temperature, as it changes the density of the air, which is reflected in a change in weight and therefore a change in pressure.

 

Our BMP180 module also includes the BMP180 sensor, a voltage regulator (5V to 3.3V), pull-up resistors and by-pass capacitors. The Module can be powered directly from arduino’s 5V output. It has a small format and low current consumption.



Library for BMP180 pressure sensor

Description: So first we need to include the BMP180 library,

For this tutorial we will use the library developed by Sparkfun, this library can be downloaded at: https://github.com/sparkfun/BMP180_Breakout/…..

It is necessary to download and import the library to our Arduino IDE, before starting with the examples we will explain the functions that we will use:

begin()

Initialize the BMP180 sensor, it returns 1 if the initialization is correct or 0 if it has failed

startTemperature()

Function to start a temperature measurement and gives us back the time in milliseconds that we need to wait before getting the reading. If it returns us a 0, it is because the start of the temperature measurement has failed

getTemperature(T)

Get the temperature in the variable T, before using this function it is necessary to call the startTemperature() function and that the appropriate time has elapsed for reading; returns 1 or 0 whether or not the reading was successful respectively

startPressure;

Function to start a pressure measurement, we must indicate the number of additional samples (from 0 to 3) that the sensor must take for the pressure reading and returns the time in milliseconds that we need to wait before obtaining the reading. If it returns us a 0, it is because the start of the pressure measurement has failed

getPressure(P, T);

Get the value of the measurement previously started with startPressure(); it is necessary to give it as a parameter the temperature T which will serve to compensate for the influence of the temperature on the calculation of the pressure, the value of the absolute pressure is stored in the variable P. Return 1 or 0 whether the reading has been successful or not respectively

altitude(P, Po);

Calculates the altitude between the point where the pressure reading P (in mbar) was taken relative to a reference point with pressure Po (in mbar). We return the value of altitude in meters

sealevel(P, A);

This function performs the reverse calculation at altitude(P, Po) , given a pressure P (in mbar) and an altitude A (in meters) calculates the pressure at sea level or point from where the height is measured. Returns the pressure value in mbar

Connections between Arduino and BMP180 module

Connections are like any I2C connection:

BMP180 barometric pressure sensor example – Arduino Learning

BMP180 barometric pressure sensor example – Arduino Learning

LCD to I2C adapter Arduino One, Nano, Mini. Arduino Mega , DUE Arduino Leonardo
Vdc 5v 5v 5v
Gnd Gnd Gnd Gnd
Scl A5 21 3
Sda A4 20 2

Perform pressure and temperature readings with the BMP180

Performing this task is extremely simple, just start reading, wait for the duration of the reading and get that value. We will perform the same procedure for both temperature and pressure.

The following is the corresponding Sketch:

 

CODE

  1. #include <Adafruit_BMP085.h>
  2. #include <Wire.h>
  3. #include <LiquidCrystal.h>
  4. // initialize the library with the numbers of the interface pins
  5. LiquidCrystal lcd(13, 12, 11, 10, 9, 8);//RS,EN,D4,D5,D6,D7
  6. char PRESSURESHOW[4];// initializing a character of size 4 for showing the result
  7. char TEMPARATURESHOW[4];// initializing a character of size 4 for showing the temparature result
  8. Adafruit_BMP085 bmp;
  9. void setup() {
  10. lcd.begin(16, 2);
  11. // Print a logo message to the LCD.
  12. lcd.print(“Data Loading__]”);
  13. lcd.setCursor(0, 1);
  14. delay (2500);
  15. delay (2500);
  16. lcd.clear();//clear display
  17. // Print another message to the LCd
  18. Serial.begin(9600);
  19. if (!bmp.begin())
  20. {
  21. Serial.println(“ERROR”);///if there is an error in communication
  22. while (1) {}
  23. }
  24. }
  25. void loop()
  26. {
  27. lcd.print(“Pressure= “); // print name
  28. String PRESSUREVALUE = String(bmp.readPressure());
  29. // convert the reading to a char array
  30. PRESSUREVALUE.toCharArray(PRESSURESHOW, 4);
  31. lcd.print(PRESSURESHOW);
  32. lcd.print(“hPa “);
  33. lcd.setCursor(0, 1);
  34. //// set the cursor to column 0, line 1
  35. lcd.print(“Tempar.=”);// print name
  36. String TEMPARATUREVALUE = String(bmp.readTemperature());
  37. // convert the reading to a char array
  38. TEMPARATUREVALUE.toCharArray(TEMPARATURESHOW, 4);
  39. lcd.print(TEMPARATURESHOW);
  40. lcd.print(“C “);
  41. lcd.setCursor(0, 0);// set the cursor to column 0, line1
  42. delay(1000);
  43. }

 

The result we get by the Display :

 




Share.

About Author

Leave A Reply