Python with Arduino LESSON 9: Measuring Pressure and Temperature with the BMP180 Sensor

One of our goals with this series of lessons is to learn how to plot live data in Python. To do that, we need some interesting streaming data from the Arduino. In this lesson we will provide a live stream of temperature and pressure data. We will hook up the circuit, program the arduino, and stream the temperature and pressure data over the serial port. Then in the next lesson, we will read the data stream into Python, and provide a live plot of the incoming data. We will be using the Adafruit BMP180 Pressure Sensor.

This is the most excellent BMP180 Pressure Sensor from adafruit.

This is a really simple sensor to get set up. To connect it up, use the following connections:

Connecting Up the BMP180 Pressure and Temperature Sensor
BMP180 Pin Arduino Pin
Vin 5V


With the circuit hooked up, you are ready to start coding. The first thing you will need to do is to download and install the adafruit library for this component. I prefer the API V1 version of the library, so we will download that one. Do not worry that the documentation lists a different part number. This is an upgraded version of the sensor, and the documentation still references the old part number. You can download the library for this part here:

Click the “Download the Adafruit_BMP085 Arduino Library” large green box. This will download as a zip folder. Open the zip folder, and then drag and drop the contents on your desktop.  You want the contents of the zip folder, not the zip folder itself. Rename the folder you dropped to your desktop “adafruitBMP180”. Now you need to drag and drop this folder into your arduino library folder. To find your arduino library folder, in the arduino IDE window, look in file, preferences. A window should pop open, and it should show you where your arduino sketchbook folder is.  Drop your adafruitBMP180 folder into the Library folder of your arduino sketchbook folder. If this is not perfectly clear, watch the video above and you can watch me do it step-by-step. Once your adafruitBMP180 folder is in your arduino library folder, you are ready to start writing your code. You need to kill your arduino IDE window and reopen it for it to find your new library.

Now, to get this sensor to work, you just need a few lines of code. To begin with, you must load the Wire.h library and the Adafruit_BMP085.h library (again, do not worry that the library is named after an earlier model of this sensor).  After loading the libraries, you will need to create a sensor object. Then in void setup you will need to start the sensor, and then in void loop begin making measurements. The code below is a nice example of how to do this.

Now run the program and check your serial monitor and you should see measurements of temperature and pressure. Pressure in Pascals is a big number. To convert Pascals to inches of Mercury, or in Hg, which is what the weather sites usually report, take the Pascal reading, and divide by 3386.389. Then you should be in Inches of Mercury and you can check your reading against a weather report for your area. The numbers should be close.

16 thoughts on “Python with Arduino LESSON 9: Measuring Pressure and Temperature with the BMP180 Sensor”

  1. Pls help: got error:
    BMP180.ino:3:70: fatal error: Adafruit_BMP085_U.h: No such file or directory
    compilation terminated.

    I did check: the file at the right location but cannot verify

    Pls help to send your all library in zip then I can copy.

    Thanks a lot.

  2. Really very good explanations. You are the best! 😀 Thanks for everything that are published on this wonderful site.

  3. but..
    where did we defined that the ”analogic4” will read the sensor?
    there isn´t a ”pinMode(a4,input);” , or , ” tempC=analogicRead(A4);”

    is that all included in the adafruit library?


  4. Paul,

    Great job with all the tutorials, I am going through them in a nonlinear fashion as needed trying to get up to speed as fast as possible.

    One comment on the BMP 180. You should NOT be using 5V. As stated right in the BMP085 Test program in the BMP 085 library example,

    “Connect VCC of the BMP085 sensor to 3.3V (NOT 5.0V!)”

    Also, p. 8 table 2 of the Bosch BMP 180 data sheet gives the maximum ratings as
    Table 2: Absolute maximum ratings
    Supply voltage all pins -0.3 +4.25 V

    One of the reasons I like to use the Seeeduino is that it has a 3.3V output pin in addition to the 5V one (I don’t know if the Arduino does or not). Also the Seeduino has a 3.3V switch, so it can operate at 3.3V, which gives the analog in channels a bit more resolution when the signal is less than 3.3 V. Also uses less power in this mode.

    The Bosch data sheet for the BMP180 can be found at

    Lots of good information as well as an additional driver from Bosch website. Note that it can go to high resolution, 18bit mode also.

    1. The BMP180 breakout boards are listed by adafruit as 5V ready. The Bosch spec sheet refers to the sensor itself.

      From the adafruit product description. “This board is 5V compliant – a 3.3V regulator and a i2c level shifter circuit is included so you can use this sensor safely with 5V logic and power.”


  5. In Lesson 2, we used this function:

    if (arduinoSerialData.inWaiting()>0):

    As I recall, you indicated that reading from the serial port when there was no data available was a “bad thing”. Why don’t we use that function here?

  6. i am an electrical student ..and i want to messure the tire pressure nd temprature .but my sensor is in the tire it possible because its wire but i need wireless…please suggest me for it..

    1. YOu would need to use something like an Xbee radio to radio the data out. Power is still going to be an issue for you, as you will need to power the device.

  7. sir, thank you so much with your post. It is really a big help to our thesis project. But is it possible that python can produce two plots in two plotting planes at the same time?

  8. My sensor keeps reading 32 degrees and 234 Pa and it stays like that no matter what. Is it a problem with the sensor? I’ve already checked the code many times and I did a lot of experimenting to fix the problem but it keeps showing the same numbers. Great videos by the way. All of the tutorials were going well until this one.

  9. hello sir, i have followed you from beginning , but when i tried to check output of temperature and pressure using BMP180 , but on my Arduino IDE Serial Monitor is empty its not showing any output,,,,can you please help me???

Leave a Reply

Your email address will not be published. Required fields are marked *