Sunday, 16 December 2012

RaspberryPi I2C Level Shifter

A small project, but vital when you're experimenting with the RaspberryPi because the RPi's General Purpose Input Output (GPIO) pins operate at 3.3v rather than 5v.  There are several ways around this and I'm using a ULN2003 chip at the moment to play with the GPIO in output mode, but for I2C bus experiments, the ports are bi-directional, so the level-shifter needs to work both ways too.

The circuit is a novel application of a MOSFET, in this case a BSS144 to provide a bi-directional level-shift circuit.  I'd used the same approach once before to connect a 3.3v serial USB module to a PIC microcontroller operating at 5v TTL levels, which worked fine, but I wanted a design for a reproducible and reusable module that can be plugged into a breadboard.


The only problem with the design (for me) is that the BSS144 is a tiny surface-mount component and is easy to lose so a fine-tipped soldering iron, a good magnifier and pair of tweezers are the order of the day.


This is my stripboard design, viewed from the copper strip side ('bottom') of the board.  It could be made a bit smaller, but as it is a prototype, I left an extra track at the top and bottom and an extra column of holes at each side.  The connections for the I2C buses are made with gold-plated pin strips (in this case salvaged from a broken satellite receiver).  The GND connections are really not necessary and are there for the sake of consistency, but do not need to be connected.


As you can see, the BSS144 MOSFETs are very small and a minimum of heat should be applied to solder them to the board.  The copper strips under the two MOSFETs are cut with a sharp knife rather than using a pin drill.


This is the finished and tested module using extra long pin strips salvaged from a broken satellite receiver.  I'm going to put some heat-shrink sleeve over the two resistors so they can be safely folded flat to the board and then insulate the top and bottom of the module with insulating tape and finally put a sticker on to label the connections for easy reference.

I'll probably make a couple more of these as I can see them becoming very handy.


No comments:

Post a Comment