{"id":652,"date":"2015-03-10T20:26:41","date_gmt":"2015-03-10T19:26:41","guid":{"rendered":"http:\/\/hirt.se\/blog\/?p=652"},"modified":"2015-03-10T20:26:41","modified_gmt":"2015-03-10T19:26:41","slug":"the-bmp-180-pressure-sensor","status":"publish","type":"post","link":"https:\/\/hirt.se\/blog\/?p=652","title":{"rendered":"The BMP-180 Pressure Sensor"},"content":{"rendered":"<p>For detecting small altitude changes, reading the barometric altitude, or for just detecting changes in pressure, you may want to use a pressure sensor. The Bosch BMP-180 is a very reasonably priced one, which is accessed over I2C. There are several nice breakout boards available from Adafruit.featuring the BMP-180. There is, for example, one featuring only the <a href=\"http:\/\/www.adafruit.com\/product\/1603\">BMP-180<\/a>, and another <a href=\"http:\/\/www.adafruit.com\/product\/1604\">one<\/a> featuring gyros and accelerometers as well. <\/p>\n<p><a href=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2015\/03\/BMP.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"BMP\" style=\"border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;border-top-width: 0px\" border=\"0\" alt=\"BMP\" src=\"https:\/\/hirt.se\/blog\/wp-content\/uploads\/2015\/03\/BMP_thumb.jpg\" width=\"304\" height=\"404\"><\/a> <\/p>\n<p>No matter which, you would access it in a similar fashion.<\/p>\n<p>As usual, before you start, you need to install <a href=\"http:\/\/pi4j.com\/\">PI4J<\/a> and <a href=\"https:\/\/learn.adafruit.com\/adafruit-16-channel-servo-driver-with-raspberry-pi\/configuring-your-pi-for-i2c\">set up the Rasberry for i2c communication<\/a>.<\/p>\n<p>Next decide in which mode you want the device to run. Check out the OperatingMode for details. The higher resolution, the longer time it takes to read values, and the higher the current draw.<\/p>\n<p>If you are using the standard address and i2c bus, next create a BMPDevice:<\/p>\n<blockquote>\n<p>BMPDevice bmp = new BMPDevice(OperatingMode.STANDARD); <\/p>\n<\/blockquote>\n<p>Next, reading the pressure, altitude and temperature is done like this:  <\/p>\n<blockquote>\n<p>System.out.println(String.format(&#8220;Temperature: %.1fC, Pressure: %dhPa, Altitude: %.1fm&#8221;, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bmp.readTemperature(),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bmp.readPressure() \/ 100, <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bmp.readAltitude()));<\/p>\n<\/blockquote>\n<p>To run the standard example, which will print the above every two seconds:  <\/p>\n<blockquote>\n<p>sudo java -classpath .:classes:\/opt\/pi4j\/lib\/*:.\/bmp.jar se.hirt.pi.adafruit.bmp.test.BMPTest<\/p>\n<\/blockquote>\n<h2>Summary<\/h2>\n<p>The Bosh BMP-180 is an easy way to measure the barometric altitude and\/or changes in pressure.<\/p>\n<ul>\n<li><a href=\"http:\/\/hirt.se\/downloads\/software\/rpi\/bmp.jar\">Library<\/a>\n<li><a href=\"http:\/\/hirt.se\/downloads\/software\/rpi\/bmp_src.jar\">Source<\/a><\/li>\n<\/ul>\n<p><font style=\"background-color: #ffffff\"><\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>For detecting small altitude changes, reading the barometric altitude, or for just detecting changes in pressure, you may want to use a pressure sensor. The Bosch BMP-180 is a very reasonably priced one, which is accessed over I2C. There are several nice breakout boards available from Adafruit.featuring the BMP-180. There is, for example, one featuring [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-652","post","type-post","status-publish","format-standard","hentry","category-java-mission-control-fair-dj"],"_links":{"self":[{"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=652"}],"version-history":[{"count":1,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/652\/revisions"}],"predecessor-version":[{"id":653,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/652\/revisions\/653"}],"wp:attachment":[{"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hirt.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}