• Worldwide Shipping

  • 24/7 Customer Support

  • FAQ
  • Worldwide Shipping

  • 24/7 Customer Support

  • FAQ

HUM: BMP180

You are a beginner with Croduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by e-radionica where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect module with Croduino and the basic code. Everything else is left to your imagination.

Introduction

BMP180 is a very precise Bosh's solution for measuring barometric pressure and temperature. Its successor is the BMP085 and represents a new generation of precise digital pressure sensors. Ultra low consumption (5uA per measurement) and low voltage are optimised for the sensor to work in modern devices, so you will often find it in cellphones, GPS devices, etc. Sensor is adjusted to I2C communication so we can easily connect it to Croduino. The voltage regulator and I2C pull-up resistors are located on the breakout board.
dsc_1239
Characteristics:
Measurement range: 300 - 1100hPa
Voltage: 2 - 6V
Current: 5uA (per measurement)
Deviation: 0.02hPa (0.17m)
Dimensions: 21mm x 18mm

Air pressure is measured in 1hPa (=0.01hPA =0.01mbar) steps, and the temperature 0.1°C. Besides for air pressure and temperature, this sensor is used for measuring altitude and pressure on the surface of the sea. We will talk about it later. For now, just the link for datasheet.

How does BMP work?

BMP180 uses piezo effect to determine pressure and temperature. The resulting analog signal is converted to digital by the ADC. BMP180 has an integrated EEPROM memory with data for calibration. Each sensor has a special, specific 176bit data string used for noise-canceling, offset compensation and temperature dependency determination. Those are actually records of the ratios of actual and measured measurements, and they are precisely the reason for the very good accuracy of the final results.

One measurement procedure is the following:

Microcontroller sends a series of commands to trigger the measurement of pressure and temperature. After the ADC conversion we get uncompressed values: UP - uncompensated pressure and UT - uncompensated temperature. This data can be read through I2C interface, however, for the calculation of temperature in degrees and pressure in hectopascals, calibration is required.  The calibration constants are read from the EEPROM memory, and they are also read through the I2C and finally we get the data that means something to us.
Untitled
Sampling can be of maximum 128 times per second, and in that case only one temperature measurement is recommended.

How to connect module?

For those who have skipped this section, BMP180 uses the I2C interface. Breakout has everything necessary for that type of communication and the regulator, so the input voltage can vary from 2-6 VDC. That is, it practically does not matter if we connect it to 3V3 or 5V Croduino's pin.

Untitled Sketch_bb

Arduino code

To read off the BMP180 we will use the library which you can download here. If you are uncertain of how to install the new library, follow this tutorial. An example of a code, as always, after the installation of the library, can be found under File - Examples. Below is our version which provides air pressure and temperature readings.

Bosch's engineers have predefined something they named oversampling_settings, and the speed and accuracy of the readings and electricity consumption depend on it. There are 4 options possible and the parameters are shown in the table below. The parameter 3 or ultra high resolution is used in the code.

Untitled

///////////////////////////////////////////////////////////////////////////////
/* */
/* */
/* (c) e-radionica.com 2015 - http://e-radionica.com/hr/faq/#privatnost */
/* [email protected] */
/* */
/* */
/* Air pressure sensor BMP180 - HUM tutorial */
///////////////////////////////////////////////////////////////////////////////
#include "SFE_BMP180.h"
#include "Wire.h"
SFE_BMP180 tlak;
double tlakZraka, tempZraka;
void setup() {
// we begin the serial communication
Serial.begin(9600);
// checking if everything is fine
if(tlak.begin()) Serial.println("BMP180 uspjesno povezan.");
else
{
Serial.print("Upss.. provjeri kako je modul spojen na Croduino...");
while(1);
}
}
void loop() {
// reading and printing air pressure
tlakZraka = ocitajTlak();
Serial.println("Tlak zraka = " + String(tlakZraka) + "hPa");
// reading and writing down air temperature
tempZraka = ocitajTemperaturu();
Serial.print("Temp zraka = " + String(tempZraka));
Serial.print(char(176));
Serial.println("C");
// print out the data every 1000ms = 1second
delay(1000);
Serial.println();
}
double ocitajTlak()
{
char status;
/*
* we define variables:
* temp - air temperature
* Tlak - air pressure
* tlak0 - pressure on the surface of the sea
* nadVisina - altitude
*/
double temp, Tlak, tlak0, nadVisina;
// we start off the temperature measurement
// if the measurement is successful the function returns delay to ms
// otherwise it returns 0 (zero)
status = tlak.startTemperature();
if(status != 0)
{
delay(status);
// it returns 1 for successful, or 0 for unsuccessful measurement
status = tlak.getTemperature(temp);
if(status != 0)
{
// starting off the pressure measurement
// 3 is oversampling_settings, check the tutorial
// if the measurement is successful the function returns delay to ms
// otherwise it returns 0 (zero)
status = tlak.startPressure(3);
if(status != 0)
{
delay(status);
// it returns 1 for successful, or 0 for unsuccessful measurement
status = tlak.getPressure(Tlak,temp);
if(status != 0)
{
return(Tlak);
}
}
}
}
}
double ocitajTemperaturu()
{
char status;
double temp;
// starting off the temperature measurement
// if the measurement is successful the function returns delay to ms
// otherwise it returns 0 (zero)
status = tlak.startTemperature();
if(status != 0)
{
delay(status);
// it returns 1 for successful, or 0 for unsuccessful measurement
status = tlak.getTemperature(temp);
if(status != 0)
{
return(temp);
}
}
}

How to calculate the altitude?

We have already mentioned that by using BMP180 pressure sensor, we can calculate the altitude, or the pressure on the surface of the sea. For the calculation of the above mentioned we must know the current air pressure and one of the given parameters. Let's say we would like to calculate the altitude, we will use this formula: Untitled
Where the:
p - stands for current air pressure
p0 - the pressure on the surface of the sea

We come to the conclusion that the pressure change of 1hPa equals to the 8.43 m change of height. That is, with the change of height which is 10m, the pressure changes for 1.2hPa. The formula for calculating the pressure on the surface of the sea is:

Untitled
If we translated it to Arduino language, it would look like this:

// the function for calculating the pressure on the surface of the sea using air pressure and altitude
// where the: p-stands for air pressure, p0 - pressure on the surface of the sea and a-altitude
double racunajTlak0(double p, double a)
{
return(p/pow(1-(a/44330.0),5.255));
}
// the function for calculating the altitude using air pressure and pressure on the surface of the sea
// where the: p- stands for air pressure, p0 - pressure on the surface of the sea and a-altitude
double racunajTlak0(double p, double p0)
{
return(44330.0*(1-pow(p/p0,1/5.255)));
}

Blynk + NOVA + BMP180 example download

Leave a Reply