GY-521 logic levels on I2C bus.

Please correct me if any of the below is wrong:

  • The GY-521 contains a 3.3V regulator and can be operated from 5V.
  • The I2C outputs are open collector and a pullup resistor determines the logic '1' voltage.
  • The schematic for GY-521 is: GY-521, showing pullups to 3.3V
  • By default Wire.begin() enables Arduino's internal pullup resistors on SDA, SCL

My GY-521 actually uses 2.2K pullup resistors which seems low.

So should the Arduino's internal pullup resistors be disabled after Wire.begin() ?

If the internal pullups are enabled will this help to achieve correct logic levels for a 5V Arduino ?

Is leaving them enabled any danger to the MPU6050 or the 3.3V regulator on the GY-521 ?

My GY-521 actually uses 2.2K pullup resistors which seems low.

That's OK for 3.3V.

So should the Arduino's internal pullup resistors be disabled after Wire.begin() ?

No, the internal pull-ups are so weak, that shouldn't be necessary.

If the internal pullups are enabled will this help to achieve correct logic levels for a 5V Arduino ?

No really, but a 3.3V level should be OK. Just keep the wiring between the Arduino and the GY-521 as short as possible. Additional capacitance could ruin the voltage rise and you must decrease the I2C speed to get a valid result.

Is leaving them enabled any danger to the MPU6050 or the 3.3V regulator on the GY-521 ?

No. The voltage will increase only slightly, definitely inside the MPU6050 specs.

You are playing the game of sometimes maybe (sometimes it will work sometimes it won't) You need to do a voltage translation, all units on the I2C bus need to be at there logic voltage levels. Rough rule of thumb with CMOS the logic low is VCC * 0.4 and a logic 1 is VCC * 0.6, this gives you about a 0.02 volt window, guess what happens if you get noise or a power supply droop. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

@pylon thanks very much for addressing all my questions. You have cleared up my doubts.

@gilshultz How do you get 0.02V window ? 0.6*5V = 3V. The pullup is to 3.3V, so I might expect under 0.3V headroom, but not only 0.02V. I checked the specs for the ATmega328P used in the nano. The graph on page 372 shows logic 1 at Vcc=5V to be around 2.7V. That being said I still do not rule out I2C connection problems as the root of my misery !

I wish the designers of the GY-521 had thought to leave an adjustable 'link' for connecting the on-board pullup resistors to 3.3V or 5V (since both are available on the board). Open collector/open drain outputs are ideal for connecting devices with different logic levels.

That being said I still do not rule out I2C connection problems as the root of my misery !

You didn't write yet, that you have problems with your setup. Describe in details what your problems are. Does an I2C scanner see the sensor?

From Chinese suppliers sometimes you get fake chips, so if the offer was very cheap you might have got a bad one.