When the low side (3.3V) device transmits a '1' (3.3V), the MOSFET is tied high (off), and the high side sees 5V through the R2 pull-up resistor. When the low side transmits a '0' (0V), the MOSFET source pin is grounded and the MOSFET is switched on and the high side is pulled down to 0V.
High Side Control
When the high side transmits a '0' (0V) the MOSFET substrate diode conducts pulling the lowside down to approx 0.7V,
this is also low enough to turn the MOSFET on, further pulling the low side down.
When the high side transmits a '1' (5V) the MOSFET source pin is pulled up to 3.3V and the MOSFET is OFF.
Note This works with I2C and other open collector type gates
If you dont have access to the 3.3V supply (maybe the 3.3V voltage regulator is on a breakout board)
you can simply tie the gate to 3.3V via a simple voltage divider
Since the outer resistors and the drawing are bus resistors which hold the bus level at HIGH level when no device is pulling it done to LOW, this is state one.
So if both lines, left and right are not low, no current is allowed to flow from both transistor bases.
So no amplified current is flowing.
This is state 1.
At state 2 the left 3.3V-side is pulled to LOW.
Following this the lower transistor will have a current flowing from base to emitter.
According to the basics of the transistor there is current allowed to flow between collector and emitter and the right side receives a LOW as well.
State 3 is described by polling LOW on the right side. T
his happens like state 2 but instead the upper transistor is made conductive.
The outer most resistors are pull-up resistors for the I2C bus.
A device that pulls a line down, has to pull down the current through both resistors (on the 3.3V side, and on the 5V side)
and also the current through the base of the transistor.
Typical values for the resistors 10k for all of them.
Warning:
There are some disadvantages with these 4 transistors.
If a line is pulled low, a current from the base to the emittor will turn that transistor on.
But the other transistor will leak current from the base to the collector.
That current will reduce the current in the first transistor.
I have build this circuit and it is doing well, but it doesn't meet the full I2C specifications