Bi-Directional Level Shifter
On your circuit 5v was the most common voltage for electronic components, everything was 5v, and a lot still is now. USB is still a 5v protocol, and many microcontrollers are still 5v. As electronics have become more efficient and smaller however, their power consumption has also gone down, so now we see many 3.3v devices. The trouble is that often there is now a mixture of these different voltage levels on a circuit, so when different voltage devices want to communicate signals need to be stepped down with resistors. This was fine, as generally it was the 5v microcontroller having its output voltage stepped down to a lower voltage, but there were issues.
Resistor solutions work one way, i.e. when you need to lower the voltage level of a signal. But when the problem is reversed such that the voltage of your signal is not enough to trigger an input so that you need to step it up, then resistors are no good. The solution to stepping down and stepping up a voltage is to use a Bi-directional level shifter.
A level shifter will change the voltage level according to the circuits’ power lines. E.g. for us the level shifter will change between 3.3v and 5v.
It’s a very simple set up that uses any old MOSFET and two resistors. The schematic is below.
I used the general purpose 2N7000 MOSFET, but I had used some 3A power MOSFET’s while I was waiting for the 2N7000’s to arrive! Note that the Gate is always connected to the LOWER voltage.
Any devices that share a signal line but are on two different voltages can use this set up. The 10K resistors on either side, I have found to work well with serial data. Another application of a level shifter would be with two I2C devices working on different voltages. The resistors would then take the values of the corresponding pull-up resistor for the I2C line, usually 4.7K on the 5v side and 3.3K on the 3.3v side; this will provide a suitable current of 1mA. Be careful here, don’t have two sets of pull-up resistors on the same line, if you already have them installed somewhere else then don’t include them again.