Arduino with Python LESSON 12: Calculating Height from Changes in Pressure

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys I'm Paul my quarter and I am here with lesson number 12 on using Python with Arduino and we're kind of starting out with where we ended up on lesson number eleven and that is we are streaming and graphing live data from the Arduino connected to an Adafruit bmp180 most excellent pressure and temperature sensor it's taking the measurement it's streaming that data over the serial port Python is reading it from the serial port and then making a live graph and this is where we ended up in in lesson number eleven I just want to recap one of the kind of neat things about this sensor it is really really really sensitive and so you see if I put my finger on it I can see the temperature going up there in the red and then the pressure changing but watch this if I hold it down here and I hold it up what happens the pressure drops one is the pressure drop there's less up air up here then there is down here if I put it on the floor that was about a five feet change and look at that the pressure goes up because there's more air on the floor come up here pressure goes down and so that is pretty neat just about four feet change in height and I can see a discernible signal that I can really delineate I can really delineate between the the noise and the data and about a four foot change in element and so I think that that is just pretty pretty neat and so kind of the question that that brings up then is can we use this data stream that we have coming off of this bmp180 and create sort of a height o meter where I can measure how high I am above the floor based on the measurement that I'm getting from the pressure sensor and the answer is yes we can do that because pressure does depend on elevation and when I first started this I thought that it was going to be real easy but then I started seeing the math and the physics are a little bit more complicated than what I had originally anticipated and so I want to kind of go through with you the math and this and then unless a number 13 will actually go in and will change our program to incorporate that math but that was a little bit too much to try to do the math and the programming in one lesson so we're just going to do the math today and what we're gonna have to do is to keep the math manageable we're gonna have to make some simplifying assumptions okay but what we are trying to do is we're trying to approximate a height change from a pressure change and we're going to do this all relatively based on a change in pressure we get a change in height and that way as far as we are concerned for this project the ground is an elevation of zero okay so we're gonna call the ground in my floor here my floor in this room I define as zero okay and so then this is the way that the math is gonna go that we're gonna have to make a simplifying assumption and the simplifying assumption that we're gonna make is is that the temperature is constant over our range of the experiment well it's pretty constant let's look here I'm looking at like I can easily see this as 8081 I could see you know here it's right it's it's right that the temperature does change as we go through this room all right then if I got way up there it would be a little bit more than down on the floor but as far as what I can measure between there and it's about as far as I can lift it up here I'm not really seeing any change in the temperature that's discernible and so for the sake of this analysis where we're going to be doing things in my room we're going to assume that the temperature does not change with elevation what you have to see is though that this is a simplifying assumption and if we wanted to say go beyond this and when we start using this sensor to calculate altitudes for our high-altitude balloon experiments we're gonna have to go in and do some more careful math but for today we're gonna do the math it just assumes the temperature is the same we will be doing that more careful math but I just want to get a first feel for it today and the easiest way to get the first feel for the the first look at it is to assume that the temperature is constant over the range of the experiment and so here's kind of the parameters and here's how we're going to look at it okay we're gonna have the ground here and there's a pressure on the ground and that we're going to call p0 and there's also a temperature on the ground and that temperature we're going to call T zero and then if the ground is zero you know my floor here the floor the floor in my room when you do it you can make it the floor in your room the height above that floor we can say is H and then up at H we have a pressure H okay now we don't have a th up here because we assume that the temperature is the same so we have one temperature and that's T zero with this simplifying assumption what we can say is is that the pressure at that height is equal to the pressure at the ground P Zero times the exponential of this thing minus G times M times H divided by R divided by T zero what are these numbers okay pH is the pressure at the height that would be when I hold the thing up here all right P Zero is the pressure on the ground or for me the pressure on the floor what is G G is the acceleration of gravity and I'm working in feet today and what you got to do is you've got to make sure that you're careful with your units so that all your units are going to play nicely together I'm on a working feet and so because I'm working in feet the acceleration of gravity is going to be thirty two point one seven feet per second squared M is the molar mass of air that is how much does one mole what is the mass of one mole of air and the answer for that is twenty eight point nine six pounds per pound mole okay then we have R and R is sort of like a universal gas constant and in the in the units we're working in toward in feet and pounds it is eighty-nine thousand four hundred and ninety four point six pound feet square per pound mole degree Kelvin second squared and then t0 is the ground temp in Kelvin okay so I kind of had to be careful with all of my units there but now we should be able to calculate pH based on p0 and a and a known age the problem is I don't want to calculate pH I'm will measure pH so what is it I want to calculate I want to calculate height because I want to make a hydrometer where I can raise the thing up and down and as I raise it up and down it'll show me how high above the floor we are and so if I'm gonna want to make a hydrometer I want to calculate H based on everything else I can measure pH I can measure zero and then down here in these constants I know GM R and T so I should be able to calculate H but we had to do some algebra okay if you're in my algebra 2 class or if you've taken a good algebra 2 class you should be able to follow along on the math on the math that I'm going to be showing you here if you're a freshman you probably haven't quite gotten to this math yet but just sit back and watch it and know what's coming up when you get into altitude ok we started with this equation pH is equal to p 0 exponential minus g-m H over RT and we want to solve for H so we want to get H by itself well what's the first thing that we can do we can divide both sides of the equation by p0 and then at least we just end up with the exponential by itself and so then we end up with pH over p0 because we're dividing both sides by p0 is equal to exponential minus g-m H over RT not ok now we got to get the H out from that exponential we got to get the exponential off of there well how can I get rid of an exponential that's an e to the how do I get rid of an e to the I take the log of it so if I take the log of an exponential the exponential will drop out and I'll just be left with this term but if I take the log of this side I have to take the log of this side so I have the natural log of this natural log of pH over p0 is equal to the natural log of this side which neutralizes that exponent and I am just ended up with minus g-m H over RT not I want to solve for H and so what do I have to do I have to multiply both sides by RT and divide both sides by minus g-m and then I'll get H by itself so I have h is equal to multiplying by RT I have R times T over G times n so I'm inverting that to get it over here so H is minus RT over G M times the Ln of P H over p0 I am getting H by itself I don't like to have this negative here and you know one of the powers of one of the rules of logarithm you can take a negative out front and you can pop it up as an exponent or whatever constant you have here you can pop over here as an exponent and so I take that -1 and I move it up here so I have H's RT over G natural log of the pressure at the height divided by the pressure of the floor to the minus 1 well taking a term to the -1 inverts it and so I can make it H is equal to R T over G M natural log p0 over pH and let's see remember p0 was p0 on the floor was larger than p0 up here and so R P up here so this is gonna be a number greater than 1 so this number is going to be positive and H is positive so just check and make sure I didn't do something goofy with the Sun yes it works I like to do a little checks like that when I'm doing math now what we need to do is we need to check the units and if I put all my units in do I end up with something in feet just to make sure that I haven't made a mistake in that I'm using the right constants well a pressure divided by a pressure it's not going to matter which units I use because the units are going to cancel or they're going to divide out to make one and so all of this is unitless now let's look what is the unit on our R is pound foot square per pound mold degree second squared so that's pound foot squared pound mole degree Kelvin second squared and then T the T is just Kelvin so I have Kelvin and then the G here is in feet per second squared that's an acceleration in the M we learned over here the M is in pounds per pound mole and so I put it in the unit's pound for pound mole okay now let's look at this the pound for pound mole pound pound mole will cancel pound pound mole so those two terms cancel this Kelvin cancels that Kelvin this second squared cancels that second squared so I end up with foot squared over foot foot squared over foot is feet and so all of these constants are right in my units are right because I end up with feet which is what I was going for and so then what we can say is we can actually plug in these constants that I gave you here the ones we know and what I can say is H is eighty nine four ninety four point six which was our R times RT which we're gonna measure divided by 32 feet per second squared for the acceleration of gravity and then twenty eight point nine six pounds per pound mole for the molarity of the air the molar mass of the air okay and we put those numbers in and then we sort of multiply them out and what we end up with is H is equal to ninety eight point five seven times the temperature on the ground times the natural log of the pressure on the ground divided by the pressure at the height so I'm measuring a pressure at height and I'm measure a pressure on the ground okay and I divide the pressure on the ground by the pressure at the height multiplied by the temperature very important the temperature has to be in Kelvin okay the temperature has to be in Kelvin and so temperature in Kelvin times the natural log of the pressure on the ground divided by the pressure at the height time 98.5 seven and that should give me that should give me the height okay this is an easy way for us to just play around with it in the room when we do our experiments outside with high-altitude ballooning we're going to have to go back and we're going to have to read arrive this equation more carefully taking into account that the temperature at the height is not the same as the temperature on the ground and so we're going to have to make make adjustments for that what we're going to do in the next lesson coming up we will be programming up the Arduino to take those pressure measurements that we're making and then measure the height see you then Calma quarter tune in for the next lesson subscribe to this channel maybe give me a sense thumbs up every once in a while talk to you guys later
Info
Channel: Paul McWhorter
Views: 14,164
Rating: undefined out of 5
Keywords: BMP180, Python, Arduino, Pressure, Altitude, Elevation, Tutorial, STEM, High School Math
Id: L38vPuYNxas
Channel Id: undefined
Length: 14min 7sec (847 seconds)
Published: Fri Jul 25 2014
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.