-
Notifications
You must be signed in to change notification settings - Fork 7.6k
wire.available returns 0 when reading mpu6050 fifo #594
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
Forgot to add my test sketch. This runs fine on esp8266 but not on esp32. |
see #53 |
Yeah I saw that thanks. However it's reading and writing to all the registers and initialized the dmp fine. I'm guessing some kind of timing issue possibly. Is there a way to set the clock speed slower on the esp32? |
Have you tried to set a lower value (i.e. 100000) for Wire.setClock() ? |
I couldn't get your sketch to work (requires modifications to MPU6050 lib) but I got this sketch working perfectly. [edit] pasting the example code here:
|
Thanks for testing. The sketch you got to work is only reading the raw values and that works. Its when it needs to read the fifo from the DMP there are problems. The request for data to be read is large and can be up to 1024 bytes which gets chunked up int0 smaller buffer sizes of 128. I reduced the buffer size to 32 for the wire library to see if that would work as that is what the size is on esp8266 implementation . However it still failed.
I'm out at the moment but can include the complete mpu605 lib I am using when I get back so you can compile. I'll also try lowering the clock speed on the ic2 bus. Hadn't tried that.
Much appreciate you looking at it. Haven't seen an implementation yet that uses the DMP processor with esp32 so I expect this is a new problem.
Cheers
Iain
…________________________________
From: tobozo <[email protected]>
Sent: Saturday, August 26, 2017 11:05 AM
To: espressif/arduino-esp32
Cc: ifrew; Author
Subject: Re: [espressif/arduino-esp32] wire.available returns 0 when reading mpu6050 fifo (#594)
I couldn't get your sketch to work (requires modifications to MPU6050 lib) but I got this sketch<http://tocknlab.hatenablog.com/entry/2017/03/11/182703> working perfectly.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#594 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AL-x4NHvUkRgVhUiBooA_5DZnsuWng50ks5scF5QgaJpZM4PDfM_>.
|
Ok. Tried a lower clock value no luck. Attached are the source files I am using in the test sketch for the mpu6050 library. Hopefully you may be able to compile now. I can of course go back to using raw values and doing the calculation but using the DMP makes better sense. |
You code seems to work just fine, until I shake the MPU then it crashes (the MPU, not the ESP), then I have to power-cycle it to get it back. |
Darn, thanks for posting the links, especially the first one as that is exactly the issue and code line that s failing. I had actually saw this a week ago when looking to resolve another issue and forgot about it. I can close this issue as a duplicate of that thread. Using the dmp does a lot of the maths for fusing the gyro and accel,data and so, off loads that from the host processor. According to the product sheet "The FIFO buffers the complete data set, reducing timing requirements on the system processor by allowing the processor burst read the FIFO data. After burst reading the FIFO data, the system processor can save power by entering a low-power sleep mode while the MPU collects more data " Many thanks again. I'll reduce the sampling rate to see if it makes a difference but I'm sure I have already tried that and it didn't work. I expect it is the mpu6050 i2c HW interface with esp32 that is the issue as discussed in the thread. Cheers |
Don't know how to close this issue. First time using this system. |
Update: Found a workaround.! Just so folks know after reading all the threads on this issue, it did seem to be a timing related issue when requesting a large amount of data to be read from the twowire library. So I thought about what happens if I just read a smaller amount of data and chunk up the requests. Well it turns out that the i2cdevlib library already does that so all I needed to do was change the buffer size to some value smaller. Lo and behold it works. Changing the buffer_length in the i2cdevlib library to 30 works with my test sample code here on my device. Anything greater it fails. In my actual application, I needed to reduce the buffer size to 16 to get it to work as during the DMP initialization the Fifo is also read but there is normally a large amount of data in it. So for this device, you may need to play with the buffer length to get it working on your application if you decide to use the DMP. Thanks to all those that work on this stuff and provide the support. It's a pretty amazing resource.! Cheers |
can i ask how difficult would it be to implement this on the C side of the esp32, i understand that here we are relaying on the "wire" library to perform the reads writes and buffer the read bytes, which i dont believe we have over on the non arduino-esp32. I'm wondering if its just a matter of waking the mpu6050, loading settings, loading the "firmware" (i call firmware the big array of bytes you have to write to the mpu6050), and reading the fifo periodically. am i over simplifying how to read the dmp? would it be way more complex than it is worth? i understand a bit of coding but i kind of feel trying to implement this is more than i can chew. Maybe its not, it would be nice some input from someone else. thanks in advance. p.d. i have a very mature implementation already working on the esp-idf, moving to esp32-arduino wouldnt be my best option atm. but as everyone else i see the advantage to reading the dmp |
my question is more about the implementation... as i don't think there is an i2cdevlib written for c that I can use on the esp32idf environment, so what i am wondering if reading the dmp, is just a matter of just replicating the register writes and read that the i2cdevlib does. would it be just a matter of using: i2cWrite(),i2cRead() , in such a way that i load the firmware in and just start reading the fifo registers? or would it be way more complex that its not something i can accomplish on a timely manner? I'm sorry for asking about esp-idf on the esp32-arduino git, just looking for some guidance |
idf also has I2C driver of it's own here. If you do not find that lib working on ESP32 then yes, you will need to replace the calls with the ones for the driver of your choice. Make sure you are using the same driver for all your I2C devices on that bus. |
@ifrew I would love to see your solution to get out the FIFO data. I am in the process of porting over code from other robot projects and currently stuck getting decent data from my MPU6050. ..just the raw stuff which is not much help |
what does 0.004 mean |
0.004 + 0.996 = 1 it's used for inertia, acceleration data is diluted into to gyro data 4 per thousands at a time |
Please fill the info fields, it helps to get you faster support ;)
If you have a Guru Meditation Error, please decode it:
https://github.com/me-no-dev/EspExceptionDecoder
----------------------------- Remove above -----------------------------
Hardware:
Board: nodemcu 32s
Core Installation/update date: 20/aug/2017
IDE name: vmicro visual studio
Flash Frequency: 80mhz
Upload Speed: 115200
Description:
First time posting to this forum. I am porting code that runs fine on nodemcu esp8266 to esp32 that communicates with a mpu6050 imu that is using i2cdevlib for the communication. This library uses the esp32 core two wire library. I am using the DMP processor on this chip rather than reading raw values. When data is available to be read from the FIFO on the DMP an interrupt is raised. I then read the number of bytes to be read from the FIFO and then read the FIFO.
The problem I am seeing on the esp32 is that the wire.available call is returning 0 bytes. I have read comments by Me-no-dev that the mpu6050 i2c bus interface on esp32 had some problems before and I am wondering now if this is a new issue? I had enabled debug trace statements in the calls and the relevant trace is attached. I have also attached the code from the i2cdevlib that is calling the two wire library. Ardunio version is greater than 100.
getfifobytesdmp.txt
int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout) {
}
The text was updated successfully, but these errors were encountered: