Arduino BMP180 – Reading Temperature and Pressure
The BMP180 is an I2C device, You can use this I2C scanner to verify the address of the BMP180
System Overview
While building the Central Monitoring System, I chose the BMP180 because it as relatively inexpensive and to gain experience with the BMP180 and to demonstrate its use
I wanted to use multiple Temperature/humidity/pressure sensors to compare results, there are cheap sensors and expensive sensor and results vary across all the sensors
I ordered them from Aliexpress.com for less than a dollar each, and came in 5v and 3.3v versions, I ordered two of each – always great to have a spare
Wiring the BMP180 5v model to an Arduino UNO via I2C
Transmitter Pin -> UNO Pin 5v 5v SCL Pin 4 SCM Pin 5 Gnd GND
Sketch to read the BMP180 Sensor and send results to the Serial Monitor
#define ALTITUDE 138.0 // Altitude of our Home in meters #include <SFE_BMP180.h> SFE_BMP180 pressure; // defines pins numbers for ultrasonic sensor const int trigPin = 9; const int echoPin = 10; int press;//working values for Pressure void setup() { Serial.begin(9600); if (pressure.begin()) //initialize BMP180 and check status { Serial.println("BMP180 init success"); } else { Serial.println("----------------bMP180 init Failure-----------------"); } Serial.println("Setup Complete");// debug message to mark end of setup } void loop() { delay (500); //bMP180 Section char status; //status of BMP180 calls double T,P,p0,a; //working variables status = pressure.startPressure(3); //start pressure if (status == 0) { Serial.println("Pressure Start Failure"); } status = pressure.startTemperature(); //startTemperature read cycle if (status == 0) { Serial.println("Temperature Start Failure"); } Serial.println(); Serial.print("provided altitude: "); //print static altitude in M and F Serial.print(ALTITUDE,0); Serial.print(" meters, "); Serial.print(ALTITUDE*3.28084,0); Serial.println(" feet"); delay(500); //give time for BMP180 to get pressure status = pressure.getPressure(P,T); // get pressure with status if (status==0) //check for sensor failure { Serial.println("Pressure Read Failure"); //do not clear display on failure, leave old value } status = pressure.getTemperature(T); // get Temperature if (status==0) //check for sensor failure { Serial.println("Temperature Read Failure"); //do not clear displpay on failure, leave old value } Serial.println(); Serial.print("absolute pressure: "); Serial.print(P,2); Serial.print(" mb, "); Serial.print(P*0.0295333727,2); Serial.println(" inHg"); p0 = pressure.sealevel(P,ALTITUDE); // we're at 134 meters Serial.print("relative (sea-level) pressure: "); Serial.print(p0,2); Serial.print(" mb, "); Serial.print(p0*0.0295333727,2); Serial.println(" inHg"); a = pressure.altitude(P,p0); Serial.print("computed altitude: "); Serial.print(a,0); Serial.print(" meters, "); Serial.print(a*3.28084,0); Serial.println(" feet"); delay(3000); //wait to send next update }
Arduino BMP180 – Reading Temperature and Pressure