More and more interesting devices seem to be using 3.3V rather than the usual 5V that micro-controllers run at. I find that level conversion circuitry often clutters the rest of the circuit and has to be tweaked for the characteristics of the device being interfaced with. This posting details the research for and construction of a reusable, plug-n-play power drop and bi-directional level converter for use in prototyping.

By far the easiest solution is to also run the micro-controller at 3.3V, but this can affect maximum frequency of the device and can complicate interfacing with USB. The alternative is to use a small regulator to down shift the 5V to 3.3V supply voltage (if not using an Arduino like board which has one built in) and an ad-hoc level conversion circuit for the logic lines.

Power Conversion

The Circuit below uses a Microchip MCP1700 LDO Voltage Regulator, which is fairly cheap, and available in a number of output voltages and case styles, the device can provide upto 250mA, but unless cooled I wouldn't draw more than 10s of mA through it - particularly in the SOT23-3 style case (see here for more).

Logic Level Conversion

Techniques for converting the digital logic levels depends on whether the line is unidirectal - like SPI - where one side of each line always acts as the output, or bi-directional - like I2C - where both sides can drive the line.
Obviously, a unidirectional converter is much simpler and the specific technique depends on whether we're shifting up or down (if the driving line is the low or high level respectively).

Unidirectional Level Conversion: Low-to-High

Connecting a 3.3V digital output pin to a 5V input pin is often straightforward. Most devices are fairly tolerant to the minimum voltage that they will accept as a digital high value. Most Atmel microcontrollers, for example, accept anything above 0.6Vcc as high, so the 3.3V device must output a level above 3V (0.65V).

The electrical characteristics section of both devices datasheets needs to be checked (for example). Note, that the voltage out of many devices will drop if the load current is increased. Most digital devices draw less than 1Î¼A but it may become an issue if the line is also driving something else. For example, the datasheet of the Color Nokia Knock-Off LCD sold by SparkFun states that the minimum value possible for a high level is the supply voltage - 0.4V = 2.9Volts. Although this is a minimum and the device is likely to output an acceptably high value this isn't a kind of error that will be easy to debug in a finished system.

Unidirectional Level Conversion: High-to-Low

Converting 5V to 3.3V is more interesting. Many devices can accept higher voltage inputs than their supply voltages or an external clamping diode and current limiting resistor can be used to provide the same, alternatively a simple voltage dividers can be used - (see SparkFun Sensor Interfacing Tutorial) again this will rely on the characteristics of the circuit and devices being used.

There are also some off the shelf IC bidirectional level converters available, although most appear to be for a set direction (all high to low or all low to high), for example:

HCF40109 - A single 16 pin DIP that can shift 4 lines in one direction.

Bidirectional Conversion

Bidirectional Level conversion is more complex, as either end of the line can be driving the circuit. There are also some bidirectional IC level shifters available, for example the Maxim Range of level shifters look interesting but these don't yet appear to be very cheaply priced in small quantities.

The circuit below shows a bidirectional voltage shifter that first appeared in an Application Note by Herman Schutte at Philips. The technique is unique in that it uses a single MOSFET transistor, is bi-directional, and can work with a fairly large range of voltages.

The resistors are only required if the lines are open-collector (not connected to GND or +V), which is not the case on the 5V side if connected to an AVR output pin or an input pin with the internal pull up resistor enabled). But adding does no harm and allows the circuit to be used in other situations.

Below is a prototype soldered onto vero board, the power shift is electrically separate from the level shifters allowing an external 3.3V to be used if available.
.

The soldered SMD components aren't pretty but usable until a PCB version is ready.

Checkout phatIO an IO device that looks like a USB filesystem
Set a pin to 5V by saving "1" to its control file, set it back to 0V by saving "0".
Control LCD and LED displays by writing the data to display to a file.
Communicate with TWI, and SPI and other devices by writing data to a file.
Videos, reference and more at phatIO