# How to regulate 5V 3A to 3.3V for ESP32 and level up 3.3V to 5V on a PCB?

I'm making my first custom PCB with an ESP32-WROOM-32E. I am following this tutorial for the ESP32 part. My project requires a 5V 3A power supply but the ESP32 only takes 3.3V.

The tutorial uses an LM1117. I've done some research but can't find out how much current it can take. From what I understand it turns the volts into heat, right? Does that apply for current as well? Is the LM1117 the right one for my situation? If the the input current is the same as the output current, will the LED blow up or only take as much as it needs?

Later on in the project I'll need to level up the 3.3V from a GPIO pin (which sends fast data) to 5V. How can I do this? I'm pretty new to real electronics.

The linear regulator burns the extra voltage as heat. Example:

ESP32 draws maximum 240mA. Let's use 300mA instead, assuming the ESP32 will draw a bit of extra currents to light LEDs, etc.

At this maximum current, the dropout voltage across the regulator is 5V-3.3V=1.7V, and 300mA is passing through it. P=VI, so this corresponds to 1.7V*0.3A=0.5W dissipated in the regulator.

Note the "3A" in your "5V 3A" power supply is only the maximum current it can provide. This has no influence on the dissipation of your regulator, which depends only on dropout voltage and how much current the load draws.

Of course at lower current it will burn less power.

0.5W means SMD SOT-89 or SOT-223 packages are adequate, with a bit of copper area to cool the tab. In thru-hole, a TO-220 without a heat sink will work fine. A TO-92 regulator burning 0.5W would be quite toasty, and a SOT-23 would smoke.

LM1117 requires an output cap with "ESR between 0.3 Ω to 22 Ω" according to the datasheet, so you have to use an electrolytic cap, say 100µF. The reason for the capacitance is mostly to get an ESR that's low enough to get good transient response. General purpose caps all cost pretty much the same below a few hundred µF anyway.

Usually I use LDL1117, this one works fine with 10µF ceramic surface mount cap, so it makes for a smaller footprint solution. It has a nice fast transient response, and much lower quiescent current than LM1117 too.

I'll need to level up the 3.3V from a GPIO pin (which sends fast data) to 5V.

You can use a 74HCT logic gate or buffer to translate logic levels from 3V3 to 5V. If you power it from 5V, it will output 5V logic levels, and it will correctly interpret 3V3 logic levels on its inputs. You can check "Vih" in the datasheet, which is the minimum voltage that is guaranteed to register a 1 level on the input, on 74HCT it is around 2V, so no problem to read a 3V3 logic level.

This is not the case for 74HC logic gates, which need 3.5V on the input to reliably register a high logic level when powered from 5V. Usually 74HC will work, because 3.5V is only the limit, so most chips will read 3V3 as a logic high... but it's not guaranteed, and the threshold depends on temperature, so it will probably stop working when it gets too hot or too cold.

• Most older 74 series will work as well, like 74LS. But HC and HCT are more common to find these days. May 11 at 14:30
• Yeah but 74LS is a power hog even when idle, quite obsolete... May 11 at 14:35

I think LM1117 is enough to drive your ESP32. The maximum output should be around 2.5W.

To protect your LED, simply check the maximum allowed current of your LED and calculate the corresponding R3. Normally I'll take the resistor above 500R, but 300 should be OK.

To covert 3.3V to 5V, you may need a boost converter. Check TI TPS611XX series. Bunches of options there.

• About 3.3V -> 5V, the OP talks about a GPIO (a signal). I think that boost converter is inappropriate. May 11 at 8:14
• Yep, simply use a 74HCT as advised in another answer. May 11 at 8:54

The linear regulator burns excessive power as P = V * I, so it burns off the extra voltage (while the current stays the same), but the power dissipated is that burnt voltage times the current that goes through it. It's a good idea to estimate how much it would heat up with your load, although if it's far from max spec, you should be safe.

The 1117 parts (of various manufacturers and various letters before the number) are very common 5V->3.3V regulators, they are even on Arduino boards. 1117 should be enough to power ESP32. If you don't need to power much else apart from ESP32 with 3.3V (a few low consumption devices are also ok in addition to ESP32), it will be totally enough. LM1117 can output up to 800mA as per this datasheet. The other 1117 parts are in the same ballpark.

Now, regarding 3.3V and 5V logic levels.

In this facebook post the CEO of Espressif confirms that ESP32 pins are 5V-tolerant, which means they're OK if you send 5V into them, it's within spec. ESP32 can't output 5V because it's powered from 3.3V, but it can take 5V as inputs and be cool about it. Therefore, in order to talk to 5V devices, I see three possible solutions:

1. Use 5V parts that support 3.3V logic. For example, Arduino (Atmega328p) that works from 5V, still sees 3.3V as "1". A part that registers 3.0V or lower as 1 should work with 3.3V ESP32 without a problem. It could be possible to find other parts and devices that work from 5V, but will have no problem accepting 3.3V logic inputs, while outputting 5V back to ESP32 (which is also not a problem). But it could be hard to find parts that do exactly what you want, depends on what exactly you're looking for.

2. Use a logic level shifter device - a device (IC, can be a module, pretty cheap) that exists specifically to convert logic levels. There are unidirectional and bidirectional converters in terms of direction of the signal. Modules are very easy to use.

3. Use external pullups on your 5V datalines and configure ESP32 pins as "open drain" outputs rather than "push-pull" outputs, which will make pins either actively pull the line low for 0, or not drive it at all (be kinda like input, high impedance instead of outputting high) for 1, and the pullup will pull the lines high to 5V.

• Well, shouldn't you be able to find out if pins are 5V tolerant by RTFM rather than some Facebook post? May 11 at 8:38
• @Lundin I researched it. They (Espressif) had that information about 5V-tolerance in the datasheet, but removed it from there because people started to power ESP32 with 5V and burn it. Besides, it's the CEO of the company that makes ESP32. There are many more sources that confirm this.
– Ilya
May 11 at 8:41
• That probably says more about the typical clientele using these parts than it says about ESP32 :) That is, a lot of their customers are likely of the Arduino zombie variety. May 11 at 8:51
• @Lundin I don't believe it's correct to make such statements. Nobody was born with knowledge. I do embedded with STM32 now, but my first commercial device was on Arduino chip in Arduino IDE, and it does the job at an acceptable level, given it was designed and finished within 5 months after I learned about what a transistor is. And if the tool does the job, why overcomplicate things. Nobody is born an expert and not everybody needs to be an expert to do what they need. Anyway, this is going off-topic.
– Ilya
May 11 at 8:56
• From what we see on sites such as this one, Arduino rather seems to block people from learning proper design, both in terms of hardware and software. Instead they end up with some blurry belief that Arduino is actually a valid platform for system design and not just a hobbyist/student board for learning purposes. Companies like Phoenix Contact are even designing plastic housing for the purpose of holding stuff like Arduino or Rasp Pi in place in industrial applications. Which in turn means that there are vast amounts of quacks requesting such products from them. It's all a very scary trend. May 11 at 9:13

In addition to what's already been said - yes linear regulators do produce a whole lot of heat, they have poor efficiency compared to switching regulators. Going from 5V to 3.3V isn't a big step though, so there won't be much heat.

To address "Is the LM1117 the right one for my situation?" Linear regulators have one advantage still: they give a very clean output voltage. Whereas switching regulators are difficult to design without the internal switching frequency causing EMI or noise.

Therefore it is very common design to first have a switching regulator generate a 5V from some higher voltage, for example like a battery or external 12/24V supply. And then you add a linear regulator from 5V to a very clean 3.3V, in order to power the sensitive RF parts of your design. The most careful designs also separate general 3.3V for microcontrollers etc from 3.3V to the RF parts specifically.

In case of ESP32, it appears to be a SoC mixing MCU and wireless peripherals on the same chip. Since it does have various RF parts, it should ideally be supplied from a linear regulator.