MPU 6050 goes wild once motors plugged in

I am building a self balancing robot. When my motor is not plugged in it returns the angle perfectly but once the motors are on then the MPU will go crazy before eventually setting off.

below is my circuit diagram, but the 9V batteries are actually AA's. and the Arduino is powered via usb cable at the moment.

I know this is EMI of some sort. To counter this I have attached my MPU 6050 directly to the Arduino, I put capacitors on the motors(as seen in the circuit diagram) and I have even put layers of tinfoil between my Arduino and motors/motor controller) and I moved them as far away as possible(approx. 12cm).

When I have 5 AA batteries for the motor it works well but my motors require 8 to operate at the speed I need and the when I use 8 the EMI comes and my robot will run for a second before the I2C communication fails.

Please give any suggestions you have, I am currently pulling my hair out.

Thanks :slight_smile:

edits:

here is my circuit diagram and photos or my Robot: Self balancing photo - Google Docs

I use a normal red L298N motor control module and a normal blue MPU 6050 that you can get off of Amazon

*Note that my motors/motor controllers work with the Arduino fine when I run any code that does not involve I2C communications.

Hi, @robmaster55647
Welcome to the forum.

Can you please post a circuit diagram, not a Fritzy.
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, component names and pin labels.

Can you post links to specs/data of your motors?
Can you please post image(s) of your project, so we can see your component layout?
Do you have a DMM?

Thanks.. Toom... :smiley: :+1: :coffee: :australia:

Ditch the 9V for the micro, looking for the schematic this frizzy is not readable.

Most likely the power supply is inadequate, or inadequately decoupled.

Fritzing diagrams are mostly useless and often very misleading, so please post a hand drawn wiring diagram, with all components and pins labeled. A photo of the setup would help, too.

False positive spam detection.

Please do not cross-post. Report (direct message) to moderator is the correct choice.

Original thread fished from the trash bin. Threads merged.

Hi, sorry for the late reply, please view my photos and circuit diagrams in the link that is in the edits of my post

Hi, the circuit diagram drawing and photos are in the google drive link in my edits

hi, phots and a circuit diagram are in the google drive link in my edits

Its possible the problem is caused by the way your grounds are connected.

Hi,

It is advised that you do not go back and add to your previous posts, but use a new post to show any info requested.

@robmaster55647 circuit.

Tom.... :smiley: :+1: :coffee: :australia:

Good job on the schematic. You are missing the pull up resistors for the I2C bus. Since the micro is at 5V 4.7K would work OK. With those resistors missing the noise may be helping you by putting charge on the I2C lines. This is not practical, repeatable or reliable. Add the resistors, they should swamp the noise out. Try putting a 100nf cap across the AAA batteries for high frequency bypass.

Hi again, do you mean I put the pull up resistors on the VCC or the SCL and SDA? and when I pull-up do I use the 5V line or 3.3V line? (My IMU is powered by 3.3v currently)
My reading also mentions something about disabling the Arduino's internal pull-ups, do you have any knowledge of that?

thanks

Hi,

One resistor from SCL to +5V and one resistor from SDA to +5V.

Tom... :smiley: :+1: :coffee: :australia:

Nice catch on the voltage. You need two resistors about 1.3K each. Fasten one end of each resistor to +3V3 and the other ends 1 each to SCL and SDA. Normally you pull up to the processor voltage. There are many I2C devices that will work on 3V3 but tolerate 5V on the SCL and SDA pins.