The ESP32 may be a low power chip when compared with other WiFi or networking chipsets in the domain. But in conventional terms, ESP32 is not exactly a low power chip. It can draw large spikes of current when transmitting data over WiFi and the average power consumption can be very high if you are running both cores at a high speed. This makes powering the ESP32 from AC mains a very difficult task if you are looking to make a compact ESP32 device. Smart AC mains switching devices or home automation systems that integrate easily into existing switch boards or sockets can be a challenge to design. This is where ESP32 AC mains power supply design strategies become important.
In this article, we explore some options of powering the ESP32 from mains that we have used for our clients’ projects before. We also include some options that we have tried and ruled out because they do not work.
1. An USB power supply
Probably the easiest and cheapest way to run simple projects off of the mains. If you have built an ESP32 gateway or some other similar project that can ship with a separate USB power supply… by all means, go for it!
USB power supplies are inexpensive and easily available anywhere, should your end user need a replacement.
2. A capacitive AC-DC power supply
This is one of the simplest circuits that you can design to switch AC down to low voltage DC without any transformers or ICs. However, there is a major limitation with circuits of this type. We have completed ruled out the use of this circuit to power the ESP32 from AC mains.
Here are the reasons why this will NOT work too well for the ESP32:
- The dissipation in the inrush limiting resistor (R1) produces a lot of heat for current output higher than 20-30mA.
- This circuit cannot supply peak current demands of the ESP32. The load transients that ESP32 causes when transmitting will almost certainly make the ESP32 reset if this circuit is used to power it.
- The output current depends on the input voltage, which might make it tricky to balance heat in the resistor with the output current and input voltage variations.
That being said, this power supply arrangement is very useful for a whole host of other circuits that draw less than 20mA when operational.
Also, a potential area worth exploring is the use of a super capacitor to store enough energy to turn the ESP32 on at times (if your application works in that way).
3. Certified AC-DC converter modules
There are a variety of AC-DC converter modules available that will do the trick if you wish to integrate the ESP32 power supply on the application PCB itself.
Most of these modules are compact, insulated and certified to meet various safety and EM emission standards. They can make your product robust, while saving you from the worry of failure. One of the downsides of these modules is their cost. They can be very expensive and sometimes the increased cost of using them can take away all the benefits a low cost WiFi SoC like the ESP32 presents.
Another problem with the modules is their form factor, which you have little control over.
Running the ESP32 off of these modules may not be very straight-forward either. You need proper decoupling and board design to make sure you are not destabilizing the SMPS module by drawing large spikes of current from it directly.
Many modules also have limits on the maximum capacitance they can handle at the output.
A minimum current draw is often required for output regulation to match datasheet specifications.
4. Discrete SMPS modules
There is a huge market for SMPS modules that are built down to a price and mount as through hole modules on to your PCB.
These modules can be extremely useful in powering the ESP32 without killing your budget. There are many modules that come with decent safety measures and will perform well enough to support the ESP32 at its highest power consumption.
Note that if you buy modules like this, it is highly recommended that you get modules that have an SMPS switching controller IC on them. A transistor based simple design might be good enough, but we have found that most of them are unable to support the load spikes and wake-up current of the ESP32 (deep sleep to active mode current surge). They caused the ESP32 to reset randomly at times, especially when operating at extreme temperatures.
Also, the use of poor quality high voltage electrolytic caps combined with lack of spike protection/filtering pretty much ensure that these will eventually fail rather quickly.
5. Custom SMPS power supply
This is the most flexible option with all the advantages in terms of design. If you build a good SMPS design into your application PCB, you can have complete control over the form factor, reliability and BoM cost for the module. You have full flexibility on a lot of fronts:
- A custom SMPS supplies all voltage levels you need, eliminating additional cost of local LDOs and buck converters.
- Safety features can be tailored to include spike suppression, high voltage shutdown and low voltage warning to the MCU.
- Output protection can be customized as needed.
- Noise and voltage regulation specs can be adjusted as needed by the load.
- PCB space distribution can be very well-planned. The height of the design can be optimized as well.
The only downside is that the design needs to be developed and tested along with the rest of the product.
Need help powering your ESP32 design?
We can help you with custom SMPS design for ESP32 applications and we specialize in building extremely small, compact and versatile power supply solutions for IoT products.
If you feel that our services could be of value to you, feel free to start a live chat session or contact us here!