Tag Archives: BMP180

Measure Altitude with an Arduino Project

In this video lesson I show you how you can create a project for measuring altitude using an arduino and a BMP180 Pressure Sensor. We go through the physics, math, circuit and coding to make this project work. For our example, we are using a GY-87 module, which has a BMP180 sensor on it. If you are using a BMP180 sensor directly, it should work the same. For your convenience, this is the circuit schematic we will be using:

Schematic for connecting the GY-87 module to the Arduino

For your convenience, the code we developed in the video lesson above is included below. Enjoy!

 

Measure Air Pressure with the Arduino and BMP180 Pressure Sensor

In this video lesson we explain how to use the BMP180 to measure barometric pressure and temperature. We explain basic concepts of what pressure is, and we show how the BMP180 measures pressure. The circuit schematic we use is shown here:

Schematic for connecting the GY-87 module to the Arduino

For your convenience, this is the code we developed in the video for measuring Temperature and Barometric Pressure.

 

 

Python with Arduino LESSON 17: Sending and Receiving Data Over Ethernet

This circuit contains an Arduino Nano and Pressure Sensor Communicating over Ethernet

In LESSON 16 we showed a simple Client Server model that allows us to send strings between Python running on a PC and the arduino over Ethernet. That lesson simply passed strings back and forth to show a very basic Server on Arduino, and Python acting as the Client. In this lesson we show a more practical example, with the Arduino connected to an Adafruit BMP180 Pressure Sensor. In order to complete this lesson, you will need an Arduino, an Ethernet Shield, and the Pressure Sensor. If you do not have this particular pressure sensor, you can probably follow along in the lesson using whatever sensor you have that is of interest. The video will take you through the tutorial step-by-step, and then the code we developed is shown below.

The key issue in getting this project to work is to get your mac address and IP address from your router or network. If you are at school, simply speak to your network administrator, and he will help you get an IP address for your arduino. If you are at home, you will need to connect to your router from a browser, and configure it to assign an IP address and agree on a mac address for your arduino. Some arduino Ethernet shields have a sticker with a mac address. If your Ethernet shield has a sticker with mac address, use that one. If it does not, you will need to come up with a unique mac address. There are thousands of possible routers and networks out there, so I can not help you with that part. But if you look in the router documentation, you should be able to get the IP address and mac address worked out. The arduino itself does not have a hard wired mac address, but you set the mac address in the arduino software, and the IP address as well. The key thing is that the mac address is unique on your network, and the router and arduino agree on the IP address and mac address. If you have a clearer way to explain this, please leave a comment below.

This is the server side software to run on the arduino. Again, you should use a suitable IP address and mac address for your network. Do not think you can just copy the ones I use in the code below.

Once you have this on your arduino, and the arduino connected to the internet via an Ethernet cable, you can test by opening a command line in Windows. Then ping the address you have assigned to the Arduino. If it pings correctly and you get a reply, you are ready to develop the Python code. The Python will be the client. It will send the requests to the Arduino, and the Arduino will respond with data. Since our circuit can measure pressure or temperature, you can request either of those. When the arduino receives a request for temperature, it will go out, make the temperature measurement and then return the data to Python. Similarly, if you request Pressure the arduino will read the request, will make the Pressure measurement, and then return pressure reading to the client (Python).

 This python code will request Temperature, will then read the response, and then will print the data. It then requests Pressure, reads the response, and then prints it. If you look at our earlier lessons you can see graphical techniques to visually present the data. The hard part is getting the data passed back and forth, which we show how to do in this lesson.

Arduino LESSON 21: Log Sensor Data to an SD Card

In most of our work so far, we have just watched our data go by on the Serial Monitor. In most cases, you will want to have some means to store your data. The easiest way to do this is to use a simple SD card reader. For this example, we use the Virtuabotix SD Card Reader.

Arduino connected to a BMP180 pressure sensor and an SD Card Reader

In this tutorial, we will need to have some sensor hooked up so we will have some data to store. We will be using the BMP 180 Pressuer and Temperature sensor from adafruit.  We have a complete tutorial on this sensor  HERE.  You will need to go to that lesson and get the sensor hooked up, the library installed, and the software done. All this is explained step-by-step in the LESSON.

The BMP180 is connected to the arduino as follows:

Connecting Up the BMP180 Pressure and Temperature Sensor
BMP180 Pin Arduino Pin
Vin 5V
GND GND
SCL A5
SDA A4

Once you have the BMP180 connected, test and make sure your code is working, and you are getting good pressure and temperature readings. Once that is working, you are ready to connect your SD card Reader/Writer.

The SD card reader should be connected as follows:

Connecting the SD Card Reader
Sd Card Reader Pin Arduino Pin Details
GND GND Common Ground
3.3 V – (NOT USED)
+5 5V Power
CS 4 Chip Select
MOSI 11 SPI Data
SCK 13 Clock
MISO 12 SPI Data
GND GND Common Ground

In the video we will show step-by-step how to develop the software. You should follow along in the video, and not copy and paste the code below. You will never learn to program if you do not write your own code. The code below is to help you in case you get stuck.

If you have the BMP180 and the SD card connected correctly,  this should create a file called PTData.txt on the card, and write comma delimited data to the file. Note that if the file does not exist on the card, the command:

will create the file. If the file already exists, this command will append data to the existing file. If you want to start with a clean new data set, erase the old PTData file.

When you run the program, you end up with a PTData.txt file on the SD card. When you have finished logging your data, you can pop the card out, put it into your PC, and then import the data into excel. You should now be able to plot, graph or analyze the data using all the powerful features of Excel.

Python with Arduino LESSON 13: Calculating Height from Pressure measurements from BMP180 Pressure Sensor.

It is time to bring together a lot of things we have learned in our earlier lessons to create a Height-O-Meter, which will plot how high our BMP180 pressure sensor is above the floor. For this lesson we make simplifying assumption of constant temperature. When we use the sensor for our space probe or other high altitude experiments we will need to derive the equation again to take into account changing temperature. We went through the math of calculating height from changing pressure in LESSON 12.

In this lesson, we start with the software we developed in LESSON 11 for measuring, streaming, and plotting pressure and temperature data from the BMP180 sensor.

Remember, we connect the sensor to the Arduino as follows:

Connecting Up the BMP180 Pressure and Temperature Sensor
BMP180 Pin Arduino Pin
Vin 5V
GND GND
SCL A5
SDA A4

 

The software we are using on the arduino side is shown below, from LESSON 11.

We modify the Python code from LESSON 11 as explained in the video above to get this code for the Python side.

 Please go through video for complete description of this software. Remember this is only valid for small changes in height over which temperature is constant.