Code Monkey home page Code Monkey logo

Comments (10)

toonijn avatar toonijn commented on June 30, 2024 5

The raspberry has two I²C busses.

bus 0: pins 27, 28
bus 1: pins 3,5 (default)

If you connected the mpu6050 to 27 and 28 you will have to specify bus=0:

from mpu6050 import mpu6050
sensor = mpu6050(0x68, bus=0)
accelerometer_data = sensor.get_accel_data()

If you're using the wrong bus you'll also get the OP's error.

For more info about the pins see: https://pinout.xyz/pinout/i2c

from mpu6050.

mdsimmo avatar mdsimmo commented on June 30, 2024

For me, this error was because I had connected the mpu up to the wrong pins

from mpu6050.

m-rtijn avatar m-rtijn commented on June 30, 2024

Hey I didn't know this. Thanks @toonijn!

from mpu6050.

danchendrickson avatar danchendrickson commented on June 30, 2024

I am seeing the same error, but on the second time I run my code; works fine on start up and first run. The first time, the sensors works, and I can read data. If I stop the code to make a change (been tweaking how it writes to file), when I restart it, the second time I get the error. Works fine on start up and first run.

from mpu6050.

m-rtijn avatar m-rtijn commented on June 30, 2024

@danchendrickson I2C gets picky if you don't close everything neatly, I think that could cause your issue.

from mpu6050.

maryam0707 avatar maryam0707 commented on June 30, 2024

I am getting the same error as Errno 121 Remote I/O error even after I have the correct addresses shown with the i2cdetect command.

from mpu6050.

spaceKelan avatar spaceKelan commented on June 30, 2024

I have trouble using your lib and respective sensort with other i2c devices. I think the problem is the smbus not being closed properly after each interaction on the bus. I am a newbie as well. I looked in another lib where the bus.close() function is called. I wonder if you could have an example explaining this, because I get an I/O error every time. Thanks for the lib, it helped me already a lot!

from mpu6050.

m-rtijn avatar m-rtijn commented on June 30, 2024

@spaceKelan Interesting. It indeed seems that I never implemented a mpu6050.close() method or something similar. It should be easy to implement though, just add the following code to mpu6050/mpu6050.py, after line 75:

def close(self):
    """Close the i2c bus. Make sure you don't use the object afterwards"""
    self.bus.close()

The problems might also be caused by unsafe exiting of a python program, I think.

from mpu6050.

kodecreer avatar kodecreer commented on June 30, 2024

The raspberry has two I²C busses.

bus 0: pins 27, 28 bus 1: pins 3,5 (default)

If you connected the mpu6050 to 27 and 28 you will have to specify bus=0:

from mpu6050 import mpu6050
sensor = mpu6050(0x68, bus=0)
accelerometer_data = sensor.get_accel_data()

If you're using the wrong bus you'll also get the OP's error.

For more info about the pins see: https://pinout.xyz/pinout/i2c

Sorry for such a late reply, I was using pins 3 and 5, and it works with i2cdetect -y 1 pulling up address 0x68 as expected.

 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: -- -- -- -- -- -- -- --

Just right when I try to load it in the library is when it has issues (even still after over 3 years) it still has the same problem). Also I verified that the pins I was using is 3 and 5.

from mpu6050.

kodecreer avatar kodecreer commented on June 30, 2024

Alright so the answer was super simple. It was cheap and faulty due to my soldering.
Since it's pretty cheap I just bought a new set and soldered it worked perfectly fine.

Lesson of the story is, there might be a slight chance you just have a fault accelerometer. It's cheap for a reason.

from mpu6050.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.