Arduino BMP180

44K4316

Intro: Arduino BMP180

This tutorial will show you how to connect the BMP180 (or BMP085) to arduino and displaying the data in the serial monitor. Enjoy!

STEP 1: Parts

Let's get your parts together:

One arduino (10-15$ for a clone), I am using the mega although you may use any arduino you would like. Of course the micro controller can be displaced over future projects.

A BMP180 sensor (1-2$) Measures air pressure and has an embedded temperature sensor.

A few jumper cables (These do some already have at home, and do not have to be bought although I had to buy some for 2-3 $ (a pack of 60 pcs I think) ).

That's about what you need, now let's connect everything up.


STEP 2: Connections

Remember that the BMP180 uses 3.3V, which if you connect the sensor to 5V it will be destroyed fast. Be sure to have your power cable disconnected throughout the connection part.

Connect your wires as following:

VIN (or VCC) -> Arduino 3.3V

GND -> GND

SCL -> SCL

SDA ->SDA

Next let me give you my code:

STEP 3: The Code

The code for this sensor is fairly simple, although you are going to need a library to get your values.

Go ahead and navigate here to download the library from adafruit. The code I used is found below:

(I have compiled and uploaded this code to my arduino and it work very well.) Thank you for reading!

#include <Wire.h> //Including wire library

#include <SFE_BMP180.h> //Including BMP180 library

#define ALTITUDE 35.6 //Altitude where I live (change this to your altitude)

SFE_BMP180 pressure; //Creating an object

void setup() { Serial.begin(9600); //Starting serial communication

Serial.println("Program started");

if (pressure.begin()) //If initialization was successful, continue Serial.println("BMP180 init success"); else //Else, stop code forever { Serial.println("BMP180 init fail"); while (1); } }

void loop() { char status; double T, P, p0; //Creating variables for temp, pressure and relative pressure

Serial.print("You provided altitude: "); Serial.print(ALTITUDE, 0); Serial.println(" meters");

status = pressure.startTemperature(); if (status != 0) { delay(status);

status = pressure.getTemperature(T); if (status != 0) { Serial.print("Temp: "); Serial.print(T, 1); Serial.println(" deg C");

status = pressure.startPressure(3);

if (status != 0) { delay(status);

status = pressure.getPressure(P, T); if (status != 0) { Serial.print("Pressure measurement: "); Serial.print(P); Serial.println(" hPa (Pressure measured using temperature)");

p0 = pressure.sealevel(P, ALTITUDE); Serial.print("Relative (sea-level) pressure: "); Serial.print(p0); Serial.println("hPa"); } } } } delay(1000); }

11 Comments

Arduino: 1.8.1 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\shubh\OneDrive\Documents\Arduino\sketch_jan15a\sketch_jan15a.ino:3:51: fatal error: SFE_BMP180.h: No such file or directory

#include <SFE_BMP180.h> //Including BMP180 library

^

compilation terminated.

exit status 1

Error compiling for board Arduino/Genuino Mega or Mega 2560.

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

have you downloaded the bmp180 library?

Kindly get through the image attached and suggest me what initialization error I had did. The altitude in my place is 6.7 m. The program is not entering into the loop structure.

the initialization of your bmp180 is not correct

I have the same error too, did you get the solution for it?
If yes, please put it here how to solve this.
Thank you

Wrong code.
The breakout used has a 5-3.3v regulator, so can use with a 5v pin. The naked BMP180 (not used here) can only be used with 3.3v.

Working code:

#include <Wire.h>
#include <Adafruit_BMP085.h>

/***************************************************
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 displays 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);
}

Uso esta placa normalmente com alimentação de 5V!. Ela vem com regulador de tensão incorporado. Uso também um conversor de nível para se comunicar com arduino 5V.

not the correct library in the code (from what i can see)

Also, is the module 5V compatible, since there's a 3.3V regulator on it?

Really cool project! What plans do you have for this project?

Hello,

Thanks for your awesome feedback! I do not really have any plans, in the future I will try to make an intractable to connect a LCD screen and display temp and pressure on it. Like a weather station. Again thanks for your feedback.

Samuel