Setup

At compile time add "python-smbus" package.

Example

Let's read acceleration data from LIS302L accelerometer:

from smbus import SMBus
bus = SMBus(0)
addr = 0x1d
# enable the accelerometer by setting CTRL_REG_1 (0x20) appropriately
bus.write_byte_data(addr, 0x20, (0b0100 << 4 | 0b0111))
while True:
    print bus.read_byte_data(addr, 0x29) # print x axis