Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running a basic example #40

Open
ghost opened this issue Dec 8, 2019 · 1 comment
Open

Error when running a basic example #40

ghost opened this issue Dec 8, 2019 · 1 comment
Labels

Comments

@ghost
Copy link

ghost commented Dec 8, 2019

Hey there,

Looking forward to using this library. I ran the pip install and run one the basic examples to read a byte.

I get the following error:

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    b = bus.read_byte_data(80,0)
  File "/home/david/.local/lib/python3.7/site-packages/smbus2/smbus2.py", line 412, in read_byte_data
    ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 6] No such device or address

which I believe is permission related as i2cdetect -l returns:

sudo i2cdetect -l
i2c-3   smbus           SMBus PIIX4 adapter port 3 at 0b00      SMBus adapter
i2c-10  i2c             NVIDIA i2c adapter 7 at 41:00.0         I2C adapter
i2c-1   smbus           SMBus PIIX4 adapter port 0 at 0b00      SMBus adapter
i2c-8   i2c             NVIDIA i2c adapter 5 at 41:00.0         I2C adapter
i2c-6   i2c             NVIDIA i2c adapter 1 at 41:00.0         I2C adapter
i2c-4   smbus           SMBus PIIX4 adapter port 4 at 0b00      SMBus adapter
i2c-11  i2c             NVIDIA i2c adapter 8 at 41:00.0         I2C adapter
i2c-2   smbus           SMBus PIIX4 adapter port 2 at 0b00      SMBus adapter
i2c-0   i2c             Synopsys DesignWare I2C adapter         I2C adapter
i2c-9   i2c             NVIDIA i2c adapter 6 at 41:00.0         I2C adapter
i2c-7   i2c             NVIDIA i2c adapter 3 at 41:00.0         I2C adapter
i2c-5   smbus           SMBus PIIX4 adapter port 1 at 0b20      SMBus adapter

I took it out of virtualenv but still get an error. Any suggestions?

@kplindegaard
Copy link
Owner

Could it be that you try to read from address 80 but there is nothing there?

What does i2cdetect -y BUS_NUMBER tell you? (Of course you must replace BUS_NUMBER with actual bus you want to check ;) ).

On my Pi, I have one bus:

$ i2cdetect -l
i2c-1	i2c       	bcm2835 I2C adapter             	I2C adapter

And if I want to see what there on that bus:

$ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 51 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                        

Voila. Two accessible addresses. 0x50 and 0x51, i.e. 80 and 81 in decimal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant