0

Currently I'm working with a gyro-sensor and need to use i2c in order to use it. Using a Pi 3 B (os:NOOBS) on kernel: Linux raspberrypi 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux

I activated i2c in my config and made sure to add it to the modules as well as the tools package and python-smbus.

So far so good. sudo i2cdetect -y 1 -> displays a table with a '68' at column 8, row 60.

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

This means my sensor is being detected but running sudo i2cget -y 0x68 0x68 is giving me the following error:

Error: Could not open file "/dev/i2c-104" or "/dev/i2c/104": No such file or directory

I suspect that I have to find the bus-adress though I've no idea what so ever.

  • Post your answer as an answer, not as a revision to the question. – Brick Feb 22 at 16:09
1

The bus address is 1 (as in the 1 used in -y 1).

The command sudo i2cget -y 0x68 0x68 is saying read device 0x68 on bus 0x68.

0x68 hex is 104 decimal, which is why it complains about the non-existent bus 104.

I presume you mean to enter sudo i2cget -y 1 0x68

  • question solved, I discovered the solution and it works now (see changes). Though I will mark your solution because it explains why the error occurs, thanks. – StellarEquilibrium Feb 22 at 16:08
1

I found the solution to this problem:

First of all read @joan 's answer for an explanation as to why the error occurs.

Secondly, run the following code: sudo i2cget -y 1 adress <-- adress needs to be replaced by what is in your table with the i2cdetect command as shown below!

In my case the adress is 0x68, the command will return something like 0x83 (my case) and that is your register.

  • 1
    With current versions of Raspbian you don't need sudo for I²C access. Stop using sudo when you don't need to. – Dougie Feb 22 at 21:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.