The Raspberry Pi includes support for Python, which makes it easy to get access to a lot of low-level hardware and software stacks -- USB, TCP/IP, multiple file systems etc.  This is a good thing since it means you don't need to wrap your head around all the obscure details that go along with these complex stacks or the implementation details of various serial buses: you can focus on getting your data off your sensor and into your project as quickly as possible.  Hurray for abstraction!

Most sensors tend to communicate with other devices based on one of three well-defined mechanisms: I2C, SPI or good old analog output.  There are dozens of other serial buses and communication protocols out there (CAN, 1-Wire, etc.), and they all have their strengths and weaknesses, but I2C, SPI and analog cover the overwhelming majority of sensors you're likely to hook up to the Pi.

I2C is a particularly useful bus with the pin-limited Pi for two main reasons:
  • It only requires two shared lines: SCL for the clock signal, and SDA for the bi-direction data transfers.
  • Each I2C device uses a unique 7-bit address, meaning you can have more than 120 unique I2C devices sharing the bus, and you can freely communicate with them one at a time on an as-needed basis.
This tutorial will show you how you can read data from the I2C-based BMP085 Barometric Pressure Sensor using Python and the pins available on the Raspberry Pi.

A Note on Distributions

Please note that this tutorial is based on Occidentalis, Adafruit's own educational Linux distro for the Raspberry Pi.  It should work just as well with the latest Wheezy distro, etc., but it hasn't yet been tested on anything else.
Last updated on 2014-04-16 at 07.58.49 PM Published on 2012-08-14 at 05.07.18 PM