A very easy logic level converter to translate I2C signals from, say, a 5 V Arduino to a 3.3 V slave device.
I2C logic level converter
The Arduino and Basic Stamp are 5 V devices, but many modern devices — sensors, displays, flash cards and the like — are 3.3 V only and require level conversion to protect them from higher voltage signals.
Level shifting for the I2C communication protocol uses a FET design following the NXP application note. This board should work with high voltages up to 10 V and low voltages down to 1.8 V.
For ease of prototyping I used 2N7000 N-channel MOSFETs on strip board, and tried 2.2 K pull up resistors in the hope that they would allow slightly transfer rates than 10 K resistors used in the equivalent Adafruit PCB.
Layout
An online stripboard editor was used to create the schematic and layout, which are documented in a github repository.
The design fits on 6 strips x 8 holes. I used a slightly wider board to make room for colour coded loops of wire next to the right angle pin headers. The SDA and SCL lines are marked brown and grey. The low voltage can be supplied on either side of the board (blue line).
The grounds on the two devices also need to be joined. This can be accomplished on the board with a simple change to the design.
Demo
Here, the 5 V SCL and SDA pins on an Arduino Uno are connected to the 3.3 V I2C lines from a hacked voltmeter LED display. The converter works. :)
Materials
- 2x 2N7000
- 4x 2.2 KΩ resistor
- 0.1" pitch right angle header
- small piece of stripboard
- hook up wire
- solder
- soldering iron
Resources
- NXP application note
- Datasheet for 2N7000 N-channel MOSFET
- Online stripboard editor
- Github repository
11 comments:
I think that your schematic should show better the routing to the headers (the 3pin vs the 4pin).
Unfortunately the stripboard editor that I used has no symbol for pin headers, but the Eagle schematic in the Github repository should clarify things. The colour coding in the schematic is the same as the stripboard layout, by the way.
Nice!
Im planning to make a 2-side board version of this in eagle - ill let you know after i finish it
Cool! Why not fork the github repository and post the link?
Nice, will this circuit work for the RPi? I think the RPi i2c bus operates at 3.3v and my sensor operates at 5v.
It should work, the conversion is bidirectional. You will need to supply 5V to the sensor and connect the sensor and RPi grounds.
Thanks, cant wait to try it out
Think your schematic and circuit are wrong. R3 should be pulling up the 3.3V SCL line on Q2 Source pin, not on the Drain pin.
The layout is correct but the schematic needs to be rearranged.
Brilliant! This is the exact thing I need!
Thanks for your work! Could you elaborate why there are 4 pins on one side and 3 pins on the other?
Post a Comment