{"id":1987,"date":"2015-01-22T03:56:02","date_gmt":"2015-01-22T03:56:02","guid":{"rendered":"http:\/\/41j.com\/blog\/?p=1987"},"modified":"2015-01-22T03:56:02","modified_gmt":"2015-01-22T03:56:02","slug":"bmp180-barometric-pressure-sensor","status":"publish","type":"post","link":"https:\/\/41j.com\/blog\/2015\/01\/bmp180-barometric-pressure-sensor\/","title":{"rendered":"BMP180 Barometric Pressure Sensor"},"content":{"rendered":"<p><a href=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2015\/01\/BMP180.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2015\/01\/BMP180.jpg\" alt=\"BMP180\" width=\"1010\" height=\"1010\" class=\"aligncenter size-full wp-image-1988\" srcset=\"https:\/\/41j.com\/blog\/wp-content\/uploads\/2015\/01\/BMP180.jpg 1010w, https:\/\/41j.com\/blog\/wp-content\/uploads\/2015\/01\/BMP180-150x150.jpg 150w, https:\/\/41j.com\/blog\/wp-content\/uploads\/2015\/01\/BMP180-300x300.jpg 300w\" sizes=\"auto, (max-width: 1010px) 100vw, 1010px\" \/><\/a><\/p>\n<p>I pick the module above up on <a href=\"http:\/\/www.ebay.co.uk\/itm\/251682477948?_trksid=p2059210.m2749.l2649&#038;ssPageName=STRK%3AMEBIDX%3AIT\">ebay<\/a> for about 2USD shipped. I figured at that price it would be interesting to pay around with. As a first step I attached it to a bus pirate v4 to see if I could get some basic readings, this post contains my notes on reading the temperature from the device. It should be pretty easy to modify this for pressure readings. The bus pirate setup looked like this, pretty standard I2C connection:<\/p>\n<p><a href=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2015\/01\/busp_bmp180.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2015\/01\/busp_bmp180.jpg\" alt=\"busp_bmp180\" width=\"992\" height=\"558\" class=\"aligncenter size-full wp-image-1990\" srcset=\"https:\/\/41j.com\/blog\/wp-content\/uploads\/2015\/01\/busp_bmp180.jpg 992w, https:\/\/41j.com\/blog\/wp-content\/uploads\/2015\/01\/busp_bmp180-300x169.jpg 300w\" sizes=\"auto, (max-width: 992px) 100vw, 992px\" \/><\/a><\/p>\n<p>For these tests the initial, I2C setup was as <a href=\"http:\/\/41j.com\/blog\/2014\/05\/buydisplay-captouch-panel\/\">described here<\/a>. Both the 3.3V and VCC lines on the module needed to be connected to the 3.3V supply. The output of the bus scan was as follows:<\/p>\n<pre>\r\nI2C>(1)\r\nSearching I2C address space. Found devices at:\r\n0xEE(0x77 W) 0xEF(0x77 R)\r\n<\/pre>\n<p>The address values above are correct according to the <a href=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2015\/01\/BST-BMP180-DS000-09.pdf\">datasheet<\/a>. After the initial scan I shorted the power and ground lines (clever me!) and the magic smoke was released from VR2. Looks like I&#8217;ll be replacing that. However, surprisingly everything still works.<\/p>\n<p>Before you can do much with the BMP180 you need to read the calibration values from its EEPROM. These start at EEPROM address 0xAA and are described on page 15 of the datasheet. Here&#8217;s an example of how you&#8217;d read the first calibration value, which is stored at indexes 0xAA and 0xAB with the bus pirate. Writing 0xAA to 0xEE selects the register. Reading from 0xEF then reads the register bytes. It looks like it auto-increments too:<\/p>\n<pre>\r\nI2C>[0xee 0xaa]\r\nI2C START BIT\r\nWRITE: 0xEE ACK\r\nWRITE: 0xAA ACK\r\nI2C STOP BIT\r\nI2C>[0xef rr]\r\nI2C START BIT\r\nWRITE: 0xEF ACK\r\nREAD: 0x1F\r\nREAD:  ACK 0x98\r\nNACK\r\nI2C STOP BIT\r\n<\/pre>\n<p>Here are the register values I read on my device, with the values required for temperature conversion decoded as decimal. <\/p>\n<pre>\r\nNAME: REG IDX  : VALUES    : DEC\r\nAC1 : 0xAA 0xAB: 0x1F 0x98 : 8088\r\nAC2 : 0xAC 0xAD: 0xFB 0x9E : -31646\r\nAC3 : 0xAE 0xAF: 0xC7 0x17 : -18199\r\nAC4 : 0xB0 0xB1: 0x81 0x51 :\r\nAC5 : 0xB2 0XB3: 0x62 0x3A : 25146\r\nAC6 : 0xB4 0xB5: 0x3B 0xB2 : 15282\r\nB1  : 0xB6 0xB7: 0x19 0x73 :\r\nB2  : 0xB8 0xB9: 0x00 0x2A :\r\nMB  : 0xBA 0xBB: 0x80 0x00 :\r\nMC  : 0xBC 0xBD: 0xD1 0xF6 : -20982\r\nMD  : 0xBE 0xBF: 0x0A 0xAB : 2731\r\n<\/pre>\n<p>As I understand it writing 0x2e to register 0xf4 selects temperature reading:<\/p>\n<pre>\r\nI2C>[0xee 0xf4 0x2e]\r\nI2C START BIT\r\nWRITE: 0xEE ACK\r\nWRITE: 0xF4 ACK\r\nWRITE: 0x2E ACK\r\nI2C STOP BIT\r\n<\/pre>\n<p>The temp can then be read by writing 0xf6 to select the MSB (and 0xf7 for LSB), and then reading from register 0xef:<\/p>\n<pre>\r\nI2C>[0xee 0xf6]\r\nI2C START BIT\r\nWRITE: 0xEE ACK\r\nWRITE: 0xF6 ACK\r\nI2C STOP BIT\r\nI2C>[0xef r]\r\nI2C START BIT\r\nWRITE: 0xEF ACK\r\nREAD: 0x59\r\nNACK\r\nI2C STOP BIT\r\n\r\nI2C>[0xee 0xf7]\r\nI2C START BIT\r\nWRITE: 0xEE ACK\r\nWRITE: 0xF7 ACK\r\nI2C STOP BIT\r\nI2C>[0xef r]\r\nI2C START BIT\r\nWRITE: 0xEF ACK\r\nREAD: 0xC3\r\nNACK\r\nI2C STOP BIT\r\n<\/pre>\n<p>The above reads show a value of 0x59 for the MSB and 0xC3 for the LSB. Converting these to a single decimal gives 22979. Page 15 of the datasheet describes how to convert the temperature and the calibration values into a reading in Celsius. I threw this all into bc:<\/p>\n<pre>\r\nx=(22979-15282)*(25146\/(2^15))\r\ny=(-20982*(2^11))\/(x+2731)\r\nz=x+y\r\n((z+8)\/(2^4))\/10\r\n5.873557310957312033718\r\n<\/pre>\n<p>So approximately 6 degrees. Given it&#8217;s about 4 degrees outside in Tokyo, and I don&#8217;t have the heating on that seems about right!<\/p>\n<p>If I decide to move forward with this part I&#8217;ll likely attach it to a dedicated microcontroller now I have basic I2C comms working.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I pick the module above up on ebay for about 2USD shipped. I figured at that price it would be interesting to pay around with. As a first step I attached it to a bus pirate v4 to see if I could get some basic readings, this post contains my notes on reading the temperature [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-1987","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1RRoU-w3","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/1987","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/comments?post=1987"}],"version-history":[{"count":1,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/1987\/revisions"}],"predecessor-version":[{"id":1991,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/1987\/revisions\/1991"}],"wp:attachment":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/media?parent=1987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/categories?post=1987"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/tags?post=1987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}