SMBus module

Provides an SMBus wrapper for use with Micropython machine.I2C

class SMBus.SMBus(i2c)

Bases: object

Provides an ‘SMBus’ module which supports some of the py-smbus i2c methods, as well as being a subclass of machine.I2C.

Hopefully this will allow you to run code that was targeted at py-smbus unmodified on micropython.

Use it like you would the machine.I2C class:

from SMBus import SMBus

bus = SMBus(1, pins=(‘G15’,’G10’), baudrate=100000) bus.read_byte_data(addr, register) … etc

Parameters:

i2c (machine.I2C) – I2C Channel.

read_byte(*args, **kwargs)

Not yet implemented

read_byte_data(addr, register)

Read a single byte from register of device at addr Returns a single byte

read_i2c_block_data(addr, register, length)

Read a block of length from register of device at addr Returns a bytes object filled with whatever was read

read_word_data(*args, **kwargs)

Not yet implemented

write_byte(*args, **kwargs)

Not yet implemented

write_byte_data(addr, register, data)

Write a single byte from buffer data to register of device at addr Returns None

write_i2c_block_data(addr, register, data)

Write multiple bytes of data to register of device at addr Returns None

write_word_data(*args, **kwargs)

Not yet implemented