python - 在Python中读取2字节的I2C事务

标签 python raspberry-pi3 i2c honeywell

我正在尝试在Python上实现I2C通信的读取。我遇到的问题是,我从一个事务中读取两个字节的答案的传感器。有没有一个Python库提供这样的阅读。

以下是传感器答案的描述: Sensor's I2c answer

最佳答案

您要查找的库是smbus 库。如果您只想按照建议读取两个字节,请使用 read_word_data(int addr,char cmd)。如果您使用的传感器返回超过 2 个字节,则必须使用 read_block_data(int addr,char cmd) 并执行一些字节算术。

图书馆信息:http://www.raspberry-projects.com/pi/programming-in-python/i2c-programming-in-python/using-the-i2c-interface-2

关于python - 在Python中读取2字节的I2C事务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50675233/

相关文章:

python - Pony ORM - 按特定顺序排序

python - 如何聚合查询集中多个日期范围的总和?

python - Unittest + Selenium - __init__() 采用 1 个位置参数,但给出了 2 个

python - Pygame如何获取上一首歌曲

opencv - 在树莓派 3 上安装 OpenCV 需要多少空间

linux - 为什么 linux 不支持基于重复启动的 i2c 操作?

c++ - i2c 错误 : ‘i2c_smbus_read_byte_data’ was not declared in this scope

python - 故意创建套接字错误/Python 脚本

linux - 树莓派 3 上的 ftrace + addr2line

linux - 通过GPIO访问连接FPGA的RTC I2C芯片