I'm trying to implement reading from I2C communication on Python. The problem that I've faced is that the sensor which I'm reading from answers with two bytes in one transaction. Is there a Python library which provides such a reading.
Here is the description of the sensor's answer:
The library you're looking for is the
smbus
library. If you're looking to read just two bytes as you suggest, useread_word_data(int addr,char cmd)
. If you're using some sensor that returns more than 2 bytes, you'll have to useread_block_data(int addr,char cmd)
and do some byte arithmetic.Information on the library: http://www.raspberry-projects.com/pi/programming-in-python/i2c-programming-in-python/using-the-i2c-interface-2