2
votes

I am new to the raspberry pi and I have been working through some i2c examples. I am receiving an IO Error: [Errno 22]Invalid argument when I run the code below:

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. Any help would be greatly appreciated.

1

1 Answers

0
votes

This might happen when you use an invalid address in the function. You can check addr is correct or not. Please have a look on slave address.