Level shifters are a fact of life for hobbyists working with different logic voltages in the same system. Many systems run on 3.3V, while many others run on 5V, so interfacing 3.3V logic with 5V logic is a very common problem. Lots of solutions exist. Two obvious ones are sold by Sparkfun – this level shifter has a wide range of inputs and outputs, useful for connecting, say, 1.8V logic to 5V logic. It’s also bidirectional, meaning it will try to sense which of its pins is being driven and which to drive so that it can be a drop in solution for bidirectional protocols such as, say I2C. Making that decision, however, can be tricky, and there’s no one-size-fits-all solution for bidirectional converters. It’s also, by virtue of being tricky, expensive. That shifter sells for $7. There are simpler solutions as well. This converter sells for $2, though has several disadvantages. Each of its channels is unidirectional, meaning an input drives an output. That’s fine for UART, but it’s much trickier to hook that converter up in an I2C system.
Two dollars is pretty cheap, but it’s still not the cheapest it could be. All I need is translation on a UART line, and I happen to have a mess of one particular chip on hand that’ll do just that without complaining. The ON semi MC74VHC1GT126, available at Mouser, certainly doesn’t have a glamorous name, but it’ll take TTL inputs or <.8V and >2V and translate them to CMOS outputs of <.1VCC and >.8VCC. VCC can be anywhere from 3 to 5.5V, and the TTL input can be as high as 7V regardless of VCC, making it the perfect choice to translate 2.5V or 3.3V levels to 3.3V or 5V levels, without any external parts (though bypass caps are probably desirable, testing shall determine!).
I whipped together the board you see above to take care of this problem for me. Coming in at a whopping 40 cents for the PCB and 32 cents for the two ICs in small quantities, this 72-cent level shifter is just about the cheapest and most robust UART targeted converter I know of. In fact, it’s so cheap, I think I’m going to make a version for SPI as well.
Grab the schematic and updates over at the Github repo, or, probably smarter, wait for me to get back the run of 12 I just sent out to OSH Park and test them.