Skip to content
Python bindings for Linux SMBus access through i2c-dev using cffi
Branch: master
Clone or download
Latest commit 7486931 Apr 8, 2017



Latest Version Implementation License Download format Requirements Status

This Python module allows SMBus access through the I2C /dev interface on Linux hosts. The host kernel must have I2C support, I2C device interface support, and a bus adapter driver.

This module is a cffi-based python reimplementation of the python-smbus C-extension ( and works on PyPy and CPython (2.6 and up).


The SMBus methods read_block_data and block_process_call are not fully tested, and might not work correctly, see note below.

Note of caution for Raspberry Pi users: when calling read_block_data and block_process_call the underlying i2c/smbus library/driver causes a kernel panic on the Raspberry Pi. Testing these features on other hardware would be a great way to contribute.


Assuming you have a device connected at address 4 on the bus

>>> from smbus import SMBus

>>> bus = SMBus(4)

>>> bus.write_quick()

>>> some_reg = 123

>>> bus.write_i2c_block_data(4, some_reg, [1, 4, 7])


To install smbus-cffi you will need: provides a good description on how to setup the dependencies.

On Debian based distributions these can be installed with:

sudo apt-get install build-essential libi2c-dev i2c-tools python-dev libffi-dev

On Arch Linux:

pacman -S base-devel
pacman -S i2c-tools

Finally install cffi using pip or from source.

pip install cffi


There are several methods to install the package. First install the dependencies as described above. Note: unfortunately at the moment when installing using pip or on CPython you need to make sure that the cffi package already is installed.

1. pip install from PyPi

pip install smbus-cffi

2. pip install from git

pip install git+

3. Clone the repository and run

git clone
python install

Bug Reporting

To submit a bugreport use the GitHub bugtracker for the project:


You can get the latest version from the repository hosted at GitHub

The file requirements.txt contains the list of dependencies needed to work with smbus-cffi.

The project uses py.test for testing and tox to test on pypy and python.

The file test/ contains a set of integration tests for the smbus wrapper. To run the integrations tests you need an Arduino board flashed with the sketch provided in test/test_sketch. The serial port and the i2c pins of the Arduino board need to be connected to the machine running the tests. The sketch implements the counterpart of the smbus protocol that reads and writes data for each test using smbus and the serial port.


  • David Schneider

Author of the original smbus C extension:

  • Mark M. Hoffman


This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

See LICENSE for full license text

You can’t perform that action at this time.