Arduino BMP180

by samuel123abc in Circuits > Arduino

45171 Views, 43 Favorites, 0 Comments

Arduino BMP180

IMG_3008.JPG

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

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.


Connections

IMG_3007.JPG
IMG_3016.JPG
IMG_3017.JPG
IMG_3018.JPG
IMG_3019.JPG

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:

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); }