I built a small Arduino "robot" on a tracked chassis. The device uses MPU-5060 for direction finding (on a prototype shield) and Adafruit MotorShield v2 to control two 320-type motors. The goal at the moment is to simply be able to turn in 90 degree increments.

All communications between the devices happen on I2C bus. The motors have their own power supply, and the logic boards have their own. The I2C uses 4.7K pull-up resistors for 5v voltage. I tried 400K and 100K frequency on I2C

I wrote a bunch of code using the I2Cdev library and AdaFruit's own library for controlling the motors.

The problem is, as long as motors' power supply is off or at least the the motors are not connected to it (using LEds instead of motors) all the code works correctly.

When I turn on the motors, in a few seconds the I2C bus freezes. Even if I reset the Arduino, the motors stay running and the initialization of the MPU fails (it involves pumpung ~2K across the I2C bus and verifying the data reading it back. The read-back does not match, which tells me that I2C is still unstable).

I tried putting 0.1 uF capacitors across the motors, it does not help. I tried running motors on their own w/o connecting them to the controller - that does not reproduce the issue, so I think this rules out the RF interference. I don't have an osciloscope, and I am no tsure how I would use it to diagnise this issue anyway.

Could someone suggest what would be a good next step? I donot know what else I can do...

Update: The puctures of the setup.

Overall: enter image description here

As you can see, there are three shields. The bottom is Arduino Uno equivalent, the middle is the AdaFruit Motor Shiield V2. The top is MPU 6050 with two 4.7K pull-up resistors.

Motor Shield: Motor Shield

MPU 6050:

enter image description here

The connections on th elogical boards are plain to see, an I will try to add some schematics later.


Thanks everyvbody for the responses and comments.

I decided to try these steps in the following order:

  1. Change the layout by flipping the Arduino around. This will get my motor wires to be maybe 1.5cm long and vertical, so the opportunity for the interference is minmized.
  2. Use shielded cable for the motor battery wires.
  3. Change the pull-up resistors to below 2K.

Will see if any of it helps.

Also, as promised, the schematics. The most important part is the motor shield:

Motor Shield

It does have its own 10K pull-up resistors.


Items 1 and 2 done, very little improvement.

Here is what the system looks like now:

enter image description here

Note that the wires fromthe motors are vertical and as short as I can make them.

The shielded cable for motor power is grounded at the battery end to the "-" terminal of the battery.

As an "extra", I added 2 more capacitors to each motor as described here in the "Three-capacitor filter" section.

Will try item 3 later.

Update! I've given this puzzle to a more experienced friend. He went ahead and added a huge capacitor to the battery that feeds the motors (2500 microfarads). The problem stopped.

My question now is: why??? The current from that battery should never be anywhere near the control board...

  • 3
    \$\begingroup\$ Related question: electronics.stackexchange.com/questions/173085/… \$\endgroup\$
    – ErikR
    Commented May 30, 2021 at 21:40
  • 2
    \$\begingroup\$ Without any details, the usual suspects are: poor layout, lack of ground plane, insufficient decoupling. \$\endgroup\$
    – winny
    Commented May 30, 2021 at 21:57
  • 2
    \$\begingroup\$ and even more so: very insufficient power supply. \$\endgroup\$ Commented May 30, 2021 at 22:01
  • 2
    \$\begingroup\$ @MarcusMüller During testing, the Arduino and the shields are supplied with USB. Can that be insufficient? \$\endgroup\$
    – user132018
    Commented May 30, 2021 at 22:16
  • 2
    \$\begingroup\$ of course it can. \$\endgroup\$ Commented May 30, 2021 at 22:18

2 Answers 2

  • Both Cables must be at least twisted pairs.

  • Motor cable ought to be shielded.

  • Ground current must not be shared on the same wire.

  • Motor cable must at right angles to I2C.

  • Lower pullup R to 1k if not already.

  • Show block diagram of all physical connections and earth ground.

  • add grounds if unsure, incl. earth gnd

  • Report all changes in question with cause/effects


The I2C uses 4.7K pull-up resistors for 5v voltage.

Lower that to 1.5kΩ or even less. It will give you much better noise immunity.

  • \$\begingroup\$ I am afraid to burn out the I2C cirquits in the ICs... Is it safe to push 3.3ma there? The spec says minimum 3ma, so that's the only guarantee I have... \$\endgroup\$
    – user132018
    Commented May 31, 2021 at 1:00
  • \$\begingroup\$ 3mA sink current is typical for I²C. Expect no problems unless you double that. \$\endgroup\$
    – Janka
    Commented May 31, 2021 at 14:17
  • \$\begingroup\$ I2C drivers are nominally MOS current sinks, and they won't sink more than 30-40mA in the best case, usually less. As long as you don't go over 50% of the absolute maximum pin current allowed on SCL and SDA of each bus participants, you're good. 3.3mA is nothing much. 5mA should be fine, but again: easy to check. Datasheet, Absolute Maximum section, look for maximum current allowed on GPIO pins in general, or SCL/SDA pins specifically if provided. It's not a fix for bad motor circuitry design, but will at least get you a step ahead. \$\endgroup\$ Commented Mar 28, 2022 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.