简体   繁体   English

Raspberry Pi 3.0 i2c SMBus的问题

[英]Issue with Raspberry pi 3.0 i2c SMBus

I am new to the raspberry pi and I have been working through some i2c examples. 我是树莓派的新手,我一直在研究一些i2c示例。 I am receiving an IO Error: [Errno 22]Invalid argument when I run the code below: 我运行以下代码时收到IO错误:[Errno 22]无效的参数

import smbus

bus = smbus.SMBus(1)
addr = 0xa0
data = 0x20
bus.write_byte(addr, data)

Would someone please explain why this might be happening? 有人可以解释为什么会这样吗? I can see the device using the i2cdetect in the terminal but my code is failing. 我可以在终端中使用i2cdetect看到该设备,但是我的代码失败了。 Any help would be greatly appreciated. 任何帮助将不胜感激。

This might happen when you use an invalid address in the function. 当您在函数中使用无效地址时,可能会发生这种情况。 You can check addr is correct or not. 您可以检查addr是否正确。 Please have a look on slave address. 请看一下从站地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM