this is how an I2C signal should look like on a scope?

Hello everybody,

I am putting together a small arduino-controlled boat project.
I have been struggling with a problem for a few months (!) now. The whole thing 'freezes', more or less regularly, when I start motor control in PWM. I ran a small debug session and found out that is the digital compass (LSM303) giving me trouble. it gets stuck while retrieving compass data.
Again, this only happens while i run the motors. no problem when motors are off.

After spending a lot of time trying to troubleshoot this, I went and borrowed an old oscilloscope to see what was going on.
I am connected to the LSM303 (whose breakout board, I understand, has a built-in logic level converter) directly from my 5V Arduino Mega 2560 board.
Analyzing the SDA/SCL signals, SCL looks fine (nice square waves at the right levels 0-5V), but SDA looks a bit scary, as you can see in the image:

Please note that here the motors are off. I was simply running the sample sketch to retrieve continuosly data from the compass. The high levels have all those ripples that I was not expecting. This scope is very old and has some issues. the selection is supposed to be .2V per div while in the end it is like 2V per div. So it is a big ripple.

  • Now, is this an OK I2C data signal?
    (this is my main question, but if you want you can read further and help me troubleshooting the damn thing)

When the motors are on, the PWM dirtens the power supply quite a bit, like in the following image, that shows 7.2V unregulated and 5V regulated power supply (used to power arduino and all logic electronics):

so I thought that this ripple, on top of the dirty I2c signal, kills communication between compass and arduino.

so I went ahead and used a separate battery for supplying power to the arduino Mega, compass, gps, etc.., while the original battery gives power to the motors only. the result is as follows:

(this is the 'logic' battery, unregulated and regulated). not perfect, but much better. But still hangs in the tests. Damn! I thought I figured it out...
So, desperate and clueless.

What do you guys think?

Check - Gammon Forum : Electronics : Microprocessors : I2C - Two-Wire Peripheral Interface - for Arduino - has some nice pictures too

Absolute Max: "Vdd Supply voltage -0.3 to 4.8 V"
"Vin, Input voltage on any control pin (SCL, SDA) -0.3 to Vdd_IO +0.3 V"

Could be the noise is just more than the chip can handle.

Boy am I glad I stumbled into your post!!
I seem to fight a similar issue (see my post here SOLVED - Need help with DIY Segway project - Robotics - Arduino Forum).
Need to study the link provided above by robtillaart since it contains info on how to change the data rate of the I2C communication.
I would appreciate any feedback on possible interference between PWM motor controllers (in my case Orion Robo Claw 2/15A) and the I2C IMU-6 Degree-of-Freedom sensor.

thanks guys.
CrossRoads: good point. I believe this is possibly what is happening. It is hard for me to verify what exactly reaches the LSM303 chip, as I've integrated it into the boat structure now and it is a bit of a pain to take it out to see what happens after the logic level converters/voltage regulators on the breakout board.

robtillart: thanks, those look like perfect wave shapes in fact. I was trying to figure out why mine looks so irregular instead. And with this scope it is impossible for me to know whether it is the sensor or arduino that puts out all those ripples. And why. all the other equipment are turned off.

irobot: i think I had good results in a couple of tests I did some weeks ago putting a passive RC filter on the main power supply before supplying power to Arduino and sensors. the problem is that I kept on frying resistors since I only had 1/4W components. Anyway I am waiting for some 5W resistors and see if they can keep the load and the problem is fixed this way. Also I believe the issue becomes more critical when the battery level is low..

those look like perfect wave shapes in fact.

Because they are from a logic analyser, they always look good until you use a scope and see the real thing.

That SDA trace you have looks just fine to me, some crap but 2-300mV of noise at the top end will have no affect.


thanks a lot for your input, Rob!


It looks like I solved my prob at the end.
Apparently yes, it was a bad case of electric interpherence, I fixed with a good old passive RC low pass filter on the power line. The only trick is that the 1-Ohm resistor must be rated 5w in my application. C is a 100uF electrolitic. No more issues, and I even produced a little video of my happy boat on the lake:

by the way, a link that may be useful to others about electric decoupling: