-
Notifications
You must be signed in to change notification settings - Fork 7.6k
MPU6050 I2C communication is not possible #53
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
Comments
By any chance do you have a logic analyzer that you can attach to the SDA and CLK to see what is being sent? |
I have looked many times at libs like this and never came up with a reason to why I2Cdev lib calls Wire.beginTransmission before reading data from I2C slave. That is a really wrong approach ;) begin and end transmission are used only for writing to slaves and not reading. I remember doing some hacking to the I2C lib for ESP8266 in order to get that resolved, but it's bad code non the less. |
hmm... I looked at the code and there is nothing to prevent even this from working. It will send a probe after reading and that is all that will happen |
@nkolban Unfortunately, I dont have a logic analyzer :( |
By the way, the same problem exists with the following "Short example sketch" in Arduino website which is free of I2C library. // MPU-6050 Short Example Sketch The result of this sketch on serial line is: |
I'll give it a go |
hey can you pull the latest master and give this another go?
|
Thank you for your great effort, now the "Short Example Sketch" works. However, I could not still make it work with the I2CDev library. I am trying possible modifications on I2CDev.cpp file but haven't found any solution :( |
If I2CDev tests the return endTarnsaction, it will receive error, because MPU does not send ACK. Maybe that is causing it to fail? |
Arduino-MPU6050-Example sketch (base code).txt The attached base code (directly taken from website http://playground.arduino.cc/Main/MPU-6050) is also not working. The serial monitor result is: I tried to comment out endTransmission return statement but it didnt help. Below is the serial monitor result: I will try to monitor the SDA and SCL lines and post here the results if I can :) |
make sure that the module has pull-ups or add ones yourself. Pins are floating |
Unfortunately, pull-up resistors didn't make any difference. I think the module has already pull-ups. |
Ok, I have 6050 somewhere around. I'll try to find it and give it a go. |
wait for data to be latched and increase timeout in attempt to fix clock stretch issues Connected issues: http://esp32.com/viewtopic.php?f=19&t=632&p=2832#p2801 #81 #53 #11
try the latest commit please :) |
Now, I2C communication cause a hang for esp32. The mcu does nothing just after the first wire communication :( |
please try now :) |
Arduino "Short Example Sketch" Works with the following result:
However "Example Sketch (Base Code)" still not working with following result:
|
Please try the latest commit. |
Unfortunately, similar results: |
MPU6050_raw ? no clue what that is, but I'll wildly guess that it's reading single bytes to get WHO_AM_I for example and it locks the bus |
ok, please try the latest commit |
Oh thank you for your great effort, I2C now works on MPU6050, I tried also I2CDev repo library and it also works :) |
@agcaahmet I am facing a similar issue but in this case I2Cdev will not even compile. How did you get it to compile with the library?! |
There exist some duplicate definitions, you need to comment out one of each duplicate definition. |
i2cdevlib does not work. Arduino: 1.8.5 (Windows 10), Board: "DOIT ESP32 DEVKIT V1, 80MHz, 921600, None" In file included from C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.h:80:0,
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp: In static member function 'static int8_t I2Cdev::readBytes(uint8_t, uint8_t, uint8_t, uint8_t*, uint16_t)': C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:276:62: error: 'BUFFER_LENGTH' was not declared in this scope
C:\Users\woodtiger\Documents\Arduino\hardware\espressif\esp32\cores\esp32/Arduino.h:181:24: note: in definition of macro 'min' #define min(a,b) ((a)<(b)?(a):(b))
C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp: In static member function 'static int8_t I2Cdev::readWords(uint8_t, uint8_t, uint8_t, uint16_t*, uint16_t)': C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:414:70: error: 'BUFFER_LENGTH' was not declared in this scope
C:\Users\woodtiger\Documents\Arduino\hardware\espressif\esp32\cores\esp32/Arduino.h:181:24: note: in definition of macro 'min' #define min(a,b) ((a)<(b)?(a):(b))
exit status 1 |
Any idea why it wont compile? I am not really sure on the status of the i2c and also those multiple definitions and where to find them |
//Hey guys,I just work it out,because arduino i2c AND ESP32 arduino i2c not same #include<Wire.h> const int MPU_addr=0x68; // I2C address of the MPU-6050 |
related to [issue 53](espressif/arduino-esp32#53)
wait for data to be latched and increase timeout in attempt to fix clock stretch issues Connected issues: http://esp32.com/viewtopic.php?f=19&t=632&p=2832#p2801 espressif/arduino-esp32#81 espressif/arduino-esp32#53 espressif/arduino-esp32#11
Adding some options to CPB like the nRF52840 has
related to [issue 53](espressif/arduino-esp32#53)
wait for data to be latched and increase timeout in attempt to fix clock stretch issues Connected issues: http://esp32.com/viewtopic.php?f=19&t=632&p=2832#p2801 espressif/arduino-esp32#81 espressif/arduino-esp32#53 espressif/arduino-esp32#11
Although I2C Scanner sketch is able to found the device, it is not possible to communicate with MPU6050 using jrowberg/i2cdevlib library. On the other hand, using esp8266 board works with the same sketch and library.
The text was updated successfully, but these errors were encountered: