I want to connect an ADXL345 accelerometer and a HMC5883L magnetometer to the 5V I2C bus of a Mega1280 based board. I’ve used the ADXL345 by using 4k7 resistors between the I2C pins and 3,3V in the past. It worked but I think it would be better to make a logic level converter. I found the following pdf which shows a circuit how to make this. http://www.nxp.com/documents/application_note/AN10441.pdf (see page 4) I happen to have a couple of 2N7000 N-channel mosfets. Are these suitable for this application? (datasheet: http://www.fairchildsemi.com/ds/2N/2N7000.pdf )
Officially the 2N7000's need 4.5V at the gate to turn on fully but they'll probably be on strong enough at 3.3V to work with I2C. I think your circuit will work. Though I don't think the MOSFET's are necessary at all since the ATmega accepts 3.3V signals as logic high and you can just directly pull-up the I2C signals to 3.3V and disable the pullups inside the ATmega to 5V.
-- The Flexible MIDI Shield: MIDI IN/OUT, stacking headers, your choice of I/O pins
Ok thanks for the confirmation, I'll give it a try :)
As others have noted, the resistor approach can work. However, I prefer using dedicated translator chips like the pca series for i2c or a ixb series for SPI level shifting. While resistor divider bridges usually work, it's chips like these that remove one more worry from the circuit. This is especially relevant with faster devices like some SD cards.
Another approach (more chips) uses two 10k resistors and a BSS138 Fet to enable bidirectional. communications. See here. I've used this circuit in SPI communications but prefer the IXB approach - simpler to implement, uses less overall board space.
Yes, I have seen those IC's. They are a nice solution, but only available in a surface mount package. To difficult for me to solder myself ;) Sparkfun sells this http://www.sparkfun.com/products/8745 , based on 2 BSS138 fets. It's cheap but I'm in the EU, the shipping will be more expensive then the board itself. I've just put the 2 2N7000's and ADXL345 on a breadboard, and it works.
I prefer the TXS series from TI such as these (http://dsscircuits.com/i2c-level-converter.html) . It takes the pullup resistors out of the equation.
Working Is Winning!