smbus2
smbus2 is a pure-Python, drop-in replacement for the python-smbus /
python3-smbus Linux SMBus bindings. It wraps the Linux kernel’s I2C/SMBus ioctl
interface directly — no C extension required — and extends the familiar smbus API
with additional functionality such as combined read/write transactions (i2c_rdwr) and
Packet Error Checking (PEC).
Getting Started
Using smbus2
- Operations
- Best Practices
- Always Use the Context Manager
- Do Not Create Multiple
SMBusInstances for the Same Bus - Prefer
i2c_rdwrfor Devices That Do Not Use the Register-Address Protocol - Use
i2c_rdwrto Bypass the 32-Byte SMBus Limit - Add Small Delays Between Operations on Slow Devices
- Prefer
write_byte/read_bytefor Devices With No Register Concept - Handle
OSErrorGracefully
- Tips and Tricks
Support
- Troubleshooting
- FAQ
- Does smbus2 work on Windows or macOS?
- Can I read or write more than 32 bytes at once?
- How do I perform a repeated start (write then read without STOP)?
- Can I use 10-bit I2C addresses?
- Why does my device not respond when I use
read_byte_dataorwrite_byte_data? - Can I use smbus2 with asyncio?
- How do I set the I2C clock speed?
- Can I open multiple
SMBusinstances for the same bus in one process? - How do I convert a raw unsigned value to a signed integer?
- Where is the API documentation?