I'd like to interface an MPU-9150 sensor with an ATmega128 using I2C. The Atmega operates at 5V while the sensor chip operates at 3.3V.

How can I find out if the two can work together? I'm not very used to reading data sheets and don't know what to look for.

i2c is an open collector setup. The pins of a device should only pull the line low, or release them (set them as high-impedence inputs for example), allowing the i2c pullup resistors to pull the line up to VCC. VCC can be anything within the devices specs. In this case, a 3.3v pullup will work with the sensor, and at (AVR VCC 5v * 0.6) = 3v is higher than the minimum Logic High for the AVR. You just need to make sure that the pull-ups are only connected to 3.3v, so all others should be cut out/removed or in the case of internal pull-ups, disabled.

The Sensor module you link to already has external pull-up resistors tied to it's VCC (so assuming 3.3v). You just need to disable any internal pull-ups on the AVR or i2c library you are using (if you are using one).

Edit: Here is how it would hook up. The LD1117 is just a standard 3.3v regulator.


simulate this circuit – Schematic created using CircuitLab

Alternatively, you can do bi-directional mosfet or transistor for level shifting, or dedicated i2c level shifters.

How do I get an Arduino (5 V) and MPR121 (3.3 V) to talk? and I2C 3.3 to 5.0 V conversion have more info as well.

  • I didn't realise that. So I could power the AVR completely with 3.3V, and then it would have 3.3V on the output pins and there would be no problem? – Andreas Jun 19 '13 at 6:01
  • @Andreas Ha. Well, you could. AVRs can run at 3.3v, but not at full speed (I believe). What I mean is that you would power the AVR with 5v like normal, but that it only needs to see ATLEAST 3V on one of it's pins to register as a logic High signal. The i2c sensor and pullup resistors would be tied to the 3.3v power supply for the sensor module, and it will work. – Passerby Jun 19 '13 at 19:10
  • @Andreas I added a simple schematic of how it would be wired. The Sensor Module already has the resistors, so all you need to make sure is that there is none on the AVR side connected to the i2c pins and 5v. – Passerby Jun 19 '13 at 19:24

From the datasheet for the ATmega128: ATmega128 datasheet

enter image description here

The input High Voltage can be a minimum of 0.6 of Vcc. If you have your ATmega128 running at 5V, the minimum HIGH input is 3V.

If you want to be safe, try googling "3.3V to 5V level shifter" and you'll get lots of resources for creating circuits to use.

  • Thanks! What about the other direction? The MPU-9150 seems to have a max VLOGIC of VDD which is max 3.465V, if I'm reading the data sheet correctly. – Andreas Jun 19 '13 at 5:30
  • Ah, I guessed the sensor would be one directional. In that case, a level shifter will be necessary. – Nick Williams Jun 19 '13 at 13:06
  • What do you mean by one-directional? I thought all I2C was necessarily bidirectional? – Andreas Jun 19 '13 at 13:11
  • It is; you should use the level shifter idea that myself and others have suggested. – Nick Williams Jun 19 '13 at 13:17

The standard solution is to use a level shifter, for your case the txs0102 seems to be the best fit.

Another option is to simply operate at 3V3 (i.e. your pullup resistor would be connected to 3V3 then), since it is enough for the ATMega to detect a high level.

In such case I'd recommend a lower-than-usual pullup to be sure; 1K for instance.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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