i2c does not need usually conversion, because its an
open-drain bus, practically all modern
5V devices understand
3V3 logic. In either case, it is safe to use without any converters in most cases. However, the open drain configuration requires pullup resistors.
The operating voltage of
i2c bus is set by a pullup resistor. Proper pullups are critical.
Since either device communicates fine on its own, this is likely the cause of your issues. The internal pull-up of raspberry pi will struggle with more devices on the bus.
simulate this circuit – Schematic created using CircuitLab
The reason this scheme works with
5V devices is that I2C does not use
logic 1= HIGH,
logic 0 = LOW but is an open-drain bus. Which means
logic 0 = LOW
logic 1 = X
i2c pins will drive to
logic 0, but only "float" the line for
logic 1, with the voltage set by the pull-up resistor attached to the bus.
5V logic is generally sensitive to
3.3V inputs, but this is not always the case, you should always verify with the datasheet of the touch screen, or test empirically. There is a very high probability it will be fine.
The very first CMOS logic devices had high thresholds for 5V, they have been superseded, occasionally you find one in the wild. Most 5V CMOS input devices made in the last 20 years are sensitive enough to respond to
As a slave device there should be never be a condition where the touch screen drives the Bus HIGH, sometimes devices are wonky and terribly designed, so you may want to check. To protect the bus you can insert zener diodes that would clamp the voltage to 3.3V, as shown in the schematic.
NOTE These diodes are required in the opposite configuration with a
5V master with
3V3 slave. Because, for example, there is a good chance that a
5V arduino will drive the bus because of a software bug or mis-wiring and destroy a
3V3 sensor. So in this case the zener clamps are critical to protect your devices.
Using BUS translators can be problematic with an open-drain bus. You have to be careful with selecting an appropriate device that is open-drain outputs and not active drive. There are translator and bus coupler IC's that are
i2c aware or have an open-drain topology, but they must be explicitly picked.
i2c uses a simple method to detect bus contention. Since
logic 0 = LOW and
logic 1 = X,
logic 0 "beats"
logic 1. If two devices try to communicate on the bus at the exact same time, the first one who tries to write a
logic 1 to the bus while the other writes
logic 0, will detect that the bus did not change (
logic 0 wins in rochambeau) and stop transmitting. If a bus translator is driving
logic 1 = 1 and some device tries to use
logic 0 = 0, this will cause a short circuit.
If you absolutely have to bridge an isolation barrier, or communicate with multiple devices at different voltage level, you are better off using an i2c extender IC over a simplex active bus like SPI, which can be safely bridged with simple one-directional translators (even opto-isolators will work for low speeds)