i2c read failed: 4 with mpu6050 and saberthooth 2x25

Hi. I'm facing a problem with my arduino UNO project. We use the mpu 6050 and the sabertooth 2x25 for a self balancing bot. When the application is running on debug mode (without sabertooth and motors connected) mpu data seems to be correct on the serial window. The problem is that when the power is on (24V batteries) and both sabertooth and mpu6050 are connected, the i2c communication fails sending a message on the serial monitor i2c read failed:4.

On the site it is reffered as "other" problem, (not much helpfull....). We checked on the net for solutions like the VIO pin on the mpu6050, but our mpu doesn't have one.

Are there any suggestions on what may I do? Can the sabertooth be causing the problem?

Everything is possible. DO the sabertooth/mpu use interrupts? Can be disruptive. Does the I2C have right pull up resistors? 4K7 or smaller.

Do you have a logic analyzer to check the I2C communication when it fails?

Are the GNDs connected of the 24V and the Arduino power? Can you post a schematic? can you post your code?

Hi , and thanks for the fast reply

None of the components use interrups as far as i know, We are missingthe 4K7 resistors though…
Yes there is a logic analyzer for the i2c communication on the begining of the code that forbids the code to move on unless the comunication is established. There is also the code that gave us the “i2c read failed:4”. This one is on the I2C part of the code that i have uploaded. There is also a schematic. We have connected all the groundings together… Might have we overdone it???

Thanks in advance!

test5.rar (5.23 KB)

Post your sketch and a link to the used libraries.

I have already posted the schematic. The libraries we use are: Wire.h, SoftwareSerial.h and SabertoothSimplified.h. The i2c is done manually.

I'm sorry, you did post the sketch. But I'm still missing the link to the SabertoothSimplified library, although I don't think that it is relevant, I just want to check it.

Try installing pull-up resistors (I'd start with 4k7 or 3k3) because on the MPU6050 (given you use the Sparkfun module) are only 10ks installed and with some instability from the driver this may cause errors on the I2C. If that doesn't help, get a bi-directional logic level converter (one that is made for I2C, p.e. https://www.sparkfun.com/products/12009) between your MPU module and the Arduino.

skoliro: I have already posted the schematic. The libraries we use are: Wire.h, SoftwareSerial.h and SabertoothSimplified.h. The i2c is done manually.

What you mean by "I2C is done manually"?

Hello, What i meant by saying the i2c is done manually is that the i2c communication, in the code we are using, does not use any additional library other than wire.h

The library we use for sabertooth is the one provided by the official site of the product. You can find it in the following link: http://www.dimensionengineering.com/info/arduino

The IMU we are using is the breakout board GY-521 which already includes 2k2 pull-up resistors and an onboard regulator for 3.3v as i have checked. The schematic can be found here: http://playground.arduino.cc/uploads/Main/MPU6050-V1-SCH.jpg

I have tried powering the board with 5v instead of 3.3v i was previously using in case it was a problem owing to the onboard regulator but i am still not getting any different results. I also tried powering on the MPU6050 board with an optocoupler after a short delay but i was unable to get any readings afterwards.

The IMU we are using is the breakout board GY-521 which already includes 2k2 pull-up resistors and an onboard regulator for 3.3v as i have checked. The schematic can be found here: http://playground.arduino.cc/uploads/Main/MPU6050-V1-SCH.jpg

If that's the correct schematics, the board has 4k7 pullups and not 2k2. Which information is correct?

If there is an onboard voltage regulator you must power it with 5V and not 3V3. Try adding another pair of 4k7 pullups (given your board really has the above schematics) to allow a more responsive bus.

The resestors mounted on the board are the SMD 222. These are 2k2 Ohms. There is an onbouard regulator, and we do power it with 5Volts.. The problem is still there..

On those modules, you have a choice of powering them with 5V into their voltage regulator, or suppling them with 3.3V to their 3.3V connection, which bypasses the module’s voltage regulator.

The statement that "you must power it with 5V " is not accurate, I don’t think.

On those modules, you have a choice of powering them with 5V into their voltage regulator, or suppling them with 3.3V to their 3.3V connection, which bypasses the module’s voltage regulator.

If the posted schematics is correct, there is no way to circumvent the onboard voltage regulator. In this case a power supply of 3V3 is not enough. You might have other modules, maybe the OP too but I think we should believe him if he tells otherwise.

The schematic is the same as my board. There is no 3.3V input... Come on guys.. Wouldn't I see this one? Why would I upload a different one? Any other suggestions?

I am a beginner with Sabertooth and Arduino Uno Circuit. I am having a tough time getting started and this seems kind of complex, nothing I have tried from Sabertooth and Arduino library has worked I did upload the blink test and that worked between the computer and the UNO but other than that I feel stuck. We are running a Sabertooth 2x25 with Arduino Uno Board. Our system is operated with a remote controller currently and we wanted to add the functionality option of autonomous.

So what we are trying to do is drive our system with remote control to a given location and then start the program.

Right now I have not even got the UNO circuit to even control the motors yet. Can anyone help? I uploaded programs but all seem to error out one way or the other.

Has anyone have the programs and code that works for the Saber tooth - UNO intergration? Thanks I appreciate any help I can get!

Yes there is a logic analyzer for the i2c communication on the begining of the code that forbids the code to move on unless the comunication is established.

You may have misunderstood the question. A logic analyzer is a kind of oscilloscope which will display the waveform of your I2C bit communications.

skoliro, i have the same trouble, when i try to switch on the motor. Did you find the answer?

I have the same problem too! I Use another drive motor without library, I managed to minimize the problem by separating the motor power source (24V) and that used by the rest of the circuit (optically) and using Snubbers filter in the output of the engines, but, the problem continues! Does anyone have any other tips? There exist any gyroscope&accelerometer sensor that use analog output?

This solves the problem (http://forum.balanduino.net/index.php?topic=47.0), however, create another, if you can not keep the sensor coupled to the Arduino board you must create a dedicada board with a ATMega to capture sensor data and send it to the main board, there arises another problem, interference can also affect communication between dedicated board and the Arduino board if you use the serial interface, in this case, the solution is implement a communication protocol. To make this solution more efficient leave the dedicated board to perform the treatment of the sensor signal and the Kalmann filter, only sending results. I'm trying to do this.

nivaldex, can you elaborate on using snubbers to the output of the motor? Do you mean to the motor power or to encoders? Also, did you get the two separate Arduinos to communicate successfully?