Hello everybody,
I'm still working on my quadcopter (adapting the code I wrote for Arduino Due, to a Teensy 3.1 version). I hope you'll be able to help me with the strange problem I discovered today. I was stuck with an incomprehensible problem, for about 4 weeks or even more... Then, today I finally discovered that my code was working perfectly... but not every time... So, I was able to identify where the problem comes from, but I really don't have any idea why this thing could possibly happen.
My problem comes from the I2C. I try to read an MPU6050 chip (to estimate the angles of my quadcopter). As I said earlier, my code works sometimes. It fact it works only just after uploading the code to the Teensy. If I unplug the power, and plug it back, it is impossible to read the sensor anymore. And what is strange is that I don't have any error message like if the device wasn't found on the bus... Thus, to sum up, if I restart the Teensy, I have an I2C error.
Now, I'll try to add as much information as I have for you to help me. I am sure that the MPU6050 board is working properly, because I have no problem using it with my Arduino Due. I also tried to add the 4.7kOhm pull-up resistors to the SDA and SCL pins, as advised on several topics. For the code, I am using the same libraries as for my Arduino Due. I am using Arduino 1.0.5-r2 IDE and TeensyDuino. If I compile with "compile verbose", I get these lines which hold my attention:
Does anybody have an idea where does this problem come from ? The only idea I have is that maybe I don't have the correct libraries for the Teensy. But if this is not the problem, I am really completely lost.
Thanks in advance for your precious help !
I'm still working on my quadcopter (adapting the code I wrote for Arduino Due, to a Teensy 3.1 version). I hope you'll be able to help me with the strange problem I discovered today. I was stuck with an incomprehensible problem, for about 4 weeks or even more... Then, today I finally discovered that my code was working perfectly... but not every time... So, I was able to identify where the problem comes from, but I really don't have any idea why this thing could possibly happen.
My problem comes from the I2C. I try to read an MPU6050 chip (to estimate the angles of my quadcopter). As I said earlier, my code works sometimes. It fact it works only just after uploading the code to the Teensy. If I unplug the power, and plug it back, it is impossible to read the sensor anymore. And what is strange is that I don't have any error message like if the device wasn't found on the bus... Thus, to sum up, if I restart the Teensy, I have an I2C error.
Now, I'll try to add as much information as I have for you to help me. I am sure that the MPU6050 board is working properly, because I have no problem using it with my Arduino Due. I also tried to add the 4.7kOhm pull-up resistors to the SDA and SCL pins, as advised on several topics. For the code, I am using the same libraries as for my Arduino Due. I am using Arduino 1.0.5-r2 IDE and TeensyDuino. If I compile with "compile verbose", I get these lines which hold my attention:
D:\Mes documents\Arduino\libraries\I2Cdev\I2Cdev.cpp:64:14: warning: #warning Using current Arduino IDE with Wire library is functionally limiting. [-Wcpp]
D:\Mes documents\Arduino\libraries\I2Cdev\I2Cdev.cpp:65:14: warning: #warning Arduino IDE v1.0.1+ with I2CDEV_BUILTIN_FASTWIRE implementation is recommended. [-Wcpp]
D:\Mes documents\Arduino\libraries\I2Cdev\I2Cdev.cpp:66:14: warning: #warning This I2Cdev implementation does not support: [-Wcpp]
D:\Mes documents\Arduino\libraries\I2Cdev\I2Cdev.cpp:67:14: warning: #warning - Timeout detection (some Wire requests block forever) [-Wcpp]
D:\Google Drive\Temps-libre\Geekeries\Arduino\arduino-1.0.5-r2\libraries\Wire\Wire.cpp: In member function 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t, uint8_t)':
D:\Google Drive\Temps-libre\Geekeries\Arduino\arduino-1.0.5-r2\libraries\Wire\Wire.cpp:345:10: warning: variable 'tmp' set but not used [-Wunused-but-set-variable]
Does anybody have an idea where does this problem come from ? The only idea I have is that maybe I don't have the correct libraries for the Teensy. But if this is not the problem, I am really completely lost.
Thanks in advance for your precious help !
Last edited: