I am designing a pcb which should receive various types of sensors. The microcontroller is an ESP32 and the external input are RJ11 linked to I2C GPIOs of the uC. I have already planned a LevelShifter (considering that the voltage of ESP32's GPIOs are limited to around 3.3v) so that the ESP32 can receive sensors with 5v outputs. The problem is that I want to use the same GPIOS connected to the output of the LevelShifter to take into account 3.3v sensors that could be could be connected to the RJ11 port. For this I thought of using jumpers to either connect the output of the RJ11 port (sensor) directly to the I2C GPIOs of the ESP32 if the sensor is a 3.3v type. On the other side the jumpers are to be placed so that the I2C GPIOs of the ESP32 are connected to the output of the Level Shifter. Here is what I tried below. I suppose if the sensor is 3.3v type I cannot connect it to the LevelShifter. Is this right ? Is there any risk that the floating pins will disturb the communication between uC and sensor through the chosen "way"? Do you have better solution to suggest me for this case? Sorry for my English.
Look into cd74HC4050. Power it from 3.3V to get 3.3V outputs.
Inputs will be shifted to 3.3V levels.
https://www.ti.com/lit/ds/symlink/cd74hc4049.pdf?
They have a modified input protection structure that enables these parts to be used as logic level translators which convert high-level logic to a low level logic while operating off the low-level logic supply. For example, 15-V input pulse levels can be down-converted to 0-V to 5-V logic levels. The modified input protection structure protects the input from negative electrostatic discharge. These parts also can be used as simple buffers or inverters without level translation.
Just 48 cents (USD) from the reputable suppliers (Digikey, Mouser). I'd give one a try.
As Crossroads already stated, the cd74HC4050 (or CD4050BE) can accept up to 20V power supply .
Converting one level to another is simply done by powering the chip with the desired OUTPUT voltage, (i.e. 3.3V)
The chip can accept inputs greater than supply voltage. If you have 3.3V, 5V ,12V and 15V signals you want to
shift to 3.3V, power the chip with 3.3V and connect each of the inputs of the different voltages to different gates
and all outputs will be 3.3V. This chip has been around probably since the 70's or 80's.
IIRC the 4050 is not bidirectional.
It is simple to use the single transistor per line for the bidirectional level shifting used for I2C. It will work with any voltage on the other side provided it is greater than the supply of your ESP.
The device that is connected to has to be able to drive 2mA to be able to change direction. Not all devices can do that.
This is the right way. Look how they do it and linked app notes. You can use a BJT with a current limiting resistor for Base if you cannot get a MOSFET with low enough threshold.
Thanks you for these answers.
CrossRoads and raschemmel, cd74HC4050 is really a nice ic I didn't know before. Unfortunately it looks like it is not bidirectional so I cannot use it for I2C and UART maybe for other applications I'll remind to use for trigerring load for example.
Smajdalf, About the BSS130 is it sure (as showed in the shematic below) that if I send a 3.3v throught the "TX-5v" pin a normal signal will be received at the "TX-3.3v" pin in the other side.
If yes, how does it works?
Looks like the fet is always on
You connect the "5V" pull-up to the supply voltage of the sensor used (either 5V or 3V3).
The FET is on only when either side is LOW.
Smajdalf:
You connect the "5V" pull-up to the supply voltage of the sensor used (either 5V or 3V3).The FET is on only when either side is LOW.
Hi,
No I can isolate the power supply from the sensor and setting its value using jumpers.
My problem is with the output voltages. Because I want all the voltages between 3.3v and 5v (3.3v included) sent from the "High Level" side to be found on the "Low Level" side in 3.3v. In fact If I feed the sensor on the same line as the "pull-up" of 5v while I have a 3.3v sensor it could damage it.
So I wonder if the previous assembly (with "pull-up" at 5v and isolated sensor power supply) can make it possible to obtain 3.3v on the "Low Level" side if we send 3.3v in the "High Level" side.
Thanks in advance
I don't that's true.
If you test it on a breadboard and connect it as shown with 5V pullup on high side and 3.3V pullup on low side
and connect the high side input to 5V, and measure
the voltage on the 3.3V side I think it will be 3.3V
on the low side.
Try it.
The "high voltage side" pull-up should go to supply voltage of the sensor.
If you test it on a breadboard (WITHOUT ANY SENSORS) and connect it as shown,
with 5V pullup on high side
and 3.3V pullup on low side
and connect a 5V input to HIGH side input, and measure the voltage on the 3.3V side OUTPUT I think it will be 3.3V