The most effecient way to convert 5v into 3,3v and 3,3v to 5v(I meant for I2C/SPI)?

In ESP32, according to my previous question, it is not a good idea to have 5V in GPIO.
So I have a question: what should I use to reduce 5V to 3,3v and 3,3v to 5v*?
I am asking about digit, analog pins and PWM, when for I/O you have 5v.
Searching, I found some variants:
1.resistor, but in this case what to do when I want to make 5v from 3,3?
2.Convertor:https://aliexpress.ru/item/32404824354.html?sku_id=12000040252179604
I think in real we have more solutions and some may be more effecient, if yes - write
Update:
*I was thinking about I2C and SPI

Look for level converter...

You are talking about two different things. Your first question is

what should I use to reduce 5V to 3,3v?

I normally use a Voltage regulator AMS1117-3.3
Your second question is

and 3,3v to 5v?

That requires a boost converter. I don;t remember ever needing that so I don't have a part handy.

The Aliexpress item you found is a level converter. It is Bidirectional which means it can convert 3.3 to 5 and 5 to 3.3 HOWEVER, you must have a power supply for the 3.3V and the 5V.

1 Like

@sonofcy OP asks about logic level on GPIO

what are the 5 V sensors/actuators you what to connect to 3.3 V io?

the linked logic level converter will work both ways for TTL and PWM.
for analog input a voltage divider is usually used

1 Like

@kirilllanskoy
There is no one solution that fits all cases, so the most efficient will depend on the application.
Resistors might be OK for a slow speed digital signal but probably won't work for high speed SPI.

Level shifter ICs can be the best solution if you use the correct IC for the application.
The common level shifter that uses the BS138 MOSFET works well for open collector circuits like I2C.

Most 74LVC series ICs can be used as level shifters to go from 5V to 3.3V, e.g. 74LVC1G17
Many AHC type IC can also be used as 5V to 3.3V level shifter, e.g. 74AHC126, 74AHC244

1 Like

Yes and I answered, but he also asked two other questions.

@kirilllanskoy
See post#6
I see you have changed your post after I have already answered.
So are you now asking for bi-directional and unidirectional translation and what do you mean by efficient, size, power, number of parts, easy of construction etc?

@jim-p, @sonofcy, @Juraj, Ok, I understand and it was really helpful :raised_hands:, when I was saying about 3,3V to 5V, I was thinking about I2C
Update: and SPI also

For I2C this is the most common. You will see may different versions on sparkfun, amazon, aliexpress

1 Like

Thank you, and also can you answer about SPI interface?

This is the easiest to use solution for SPI since it will work up to 20MHz but the connecting wires must be kept short.

The I2C level shifter will not work at the higher data rates

bidirectional logic level converter

@jim-p, @sonofcy, @Juraj Thank you for the answers! I would like to understand how to find out how many volts a particular module gives to the board. For example, Neo6M, Ky-038, OLED display, ultrasonic sensor, etc. Since the knowledge gained from this question cannot be applied without knowing when to use it (although you can always put a converter, but with a resistor it will not work :)).

You need to read the data sheet or product description. Note that some devices that run on 5V may still require 3.3V I/O signals, so you need to carefully read the data sheets.

although you can always put a converter

if both I/O s are the same voltage you cannot

Sensors like Neo6M OLED etc do NOT give power to a board, they use power.
Their datasheets will tell you what they need.

but with a resistor it will not work :)).

^^ that makes no sense

Don't change you post after many people have already replied since it invalidates everyones comments.

I meant the voltage for input on board from these modules

According to the NEO-6M datasheet, it uses 3.3V, Ky-038 - there was no information about this, as in the ultrasonic sensor, it only talks about the power supply, which can be 3.3-5V and 5V respectively.

Hello, My answer is sort of part of the question as well. Since I have issues with boards running 5V and sensors running on 3v3. So I was thinking to use a voltage divider R1= 1K, R2 = 2K. That should provide an output voltage of 3.33V And I believe the output impedance is low enough so you can connect stuff to this power supply (technical parameters are acceptable). Would that be ok?