Comments (10)
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.
For me, this error was because I had connected the mpu up to the wrong pins
from mpu6050.
Hey I didn't know this. Thanks @toonijn!
from mpu6050.
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.
@danchendrickson I2C gets picky if you don't close everything neatly, I think that could cause your issue.
from mpu6050.
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.
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.
@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.
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.
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)
- Python3 support HOT 11
- Getting Tracebacks on calling get_accel_data() HOT 4
- 'module' object is not callable HOT 12
- no checking connectivity HOT 2
- Gyro and accelerometer range HOT 3
- AttributeError: 'int' object has no attribute 'read_i2c_word' HOT 1
- FileNotFoundError: [Errno 2] No such file or directory HOT 1
- Raspberry Pi - No Accelerometer Data Detected HOT 2
- ModuleNotFoundError when importing mpu6050 HOT 6
- Only zeros HOT 1
- Documentation overhaul HOT 1
- TypeError: 'module' object is not callable HOT 1
- OS Error : [Errorno 121] Remote I/O error HOT 6
- MODULE ERROR HOT 1
- Wrong question sorry delete
- Ask HOT 6
- accelometer data
- OSError: 121 HOT 1
- Init_py Type error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mpu6050.