Learn ESP32, ESP8266, Arduino, and Raspberry Pi

Basics project 081h ESP8266 ESP-01 module and HLK-PM03 – Powering with Mains ESP8266 Web Server

Basics: Project 081h

Project name: ESP8266 ESP-01 module , HLK-PM03 – Powering with Mains ESP8266 Web Server

Tags: Arduino, ESP8266 ESP-01 module, ESP, ESP8266, WI FI module, ESP-01, Hi-Link, HLK-PM01, powering with mains, HLK-PM03, HLK-PM12


Attachments: sketch

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1. Arduino IDE ( you can download it from here  )

2. ESP8266 ESP-01 WI FI module 1pc


3. Hi-Link HLK-PM03 1pc


4. 3.3 VDC Relay Module 1pc

5. Terminal block with 2 connectors 2 pcs

6. Terminal block with 3 connectors 1 pc

7. Electrolytic capacitor 10uF 25V 1pc

8. Electrolytic capacitor 22uF 25V 1pc

9. Glass Slow Blow fuse 200 mA 1pc

slow blow fuse

10. Thermal Fuse 72ºC 1 pc

thermal fuse

11. Fuse Quick (Fast) Blow 630 mA 1 pc

fast blow fuse

12. Varistor 1pc


13. Stripboard (Prototyping Circuit Board )

14. Electrical wires 1.5 mm and jumper cables

electrical wires 1.5 mm

15. USB to TTL serial converter 1 pc


16.USB mini cable 1 pc (optional)


17. Any voltage regulator LD1117V33, AMS1117 3.3 V or 78R33 (to get 3.3V) or  1 pc


We will learn how to use ESP8266 ESP-01 WiFi module and HLK-PM03 to power up with Mains the ESP8266 Web Server.

The ESP8266 ESP-01 are cheap Wi-Fi modules perfectly suited for DIY projects in the Internet of Things (IoT) and Home Automation fields. Using them with a 3.3 VDC relay module allows you to control any AC electronics appliances over Wi-Fi. It very dificult to find a suitable compact power supply for the ESP8266 ESP-01 Wi-Fi module if you want to power the relay and the ESP8266 ESP-01 Wi-Fi module using the same power supply. There is a good solution to power them from mains voltage using the AC/DC converter Hi-Link HLK-PM03 for 3.3 VDC (or Hi-Link HLK-PM01 model for 5V).

Understanding the Hi-Link

The Hi-Link produces the small AC/DC converter modules:

We are going to use the small module Hi-Link HLK-PM-03 3W that can supply 3.3 VDC from either 120VAC or 230VAC, this makes it perfect for small projects that needs a 3.3 VDC supply from mains.


This very compact power of Hi-Link is made on a circuit board soldering and can convert 230V AC to 3.3V DC (up to 1000mA).


  • Input voltage (AC pins): 100 – 240V AC (recommended), 90 – 264V AC (maximum)
  • Output Voltage (+Vo and -Vo pins): 3.3V DC
  • Maximum output current: 1000mA (continuous)
  • Voltage control: ±0.2%
  • Load regulation: ±0.5%
  • Exit ripple: <70mV
  • Dimensions: 34 x 20 x 15mm

Understanding the slow blow fuse and fast blow fuse

Slow-Blow Fuses. Slow blow (time delay) fuses have built-in time delay features that prevent them from blowing during intermittent current surges (large motors, air conditioners and dryers). Time delay fuses blow under constant or repeated current overload conditions. If the fuse marked T500mAL250V. That means that the fuse is slow acting rated at current of 500 mA for voltages up to 250 V.

slow blow fuse

Fast-Acting (Quick blow) Fuses. Regular and fast-acting fuses blow instantaneously–they protect lighting, electronic and other household circuits. Equipment on these circuits is sensitive to current surges. For example, the fuse marked as F0.63AL250V. That means that it’s a fast fuse rated at 0.65 A up to voltage of 250 V.

fast blow fuse

The marking will be somewhere on the case of the fuse. On glass tube fuses, it’s usually engraved (sometimes very badly) on the metal part of the body. There is no good way to non-destructively detect what type of fuse a fuse is if it is unmarked. In addition to that, there are also FF fuses which are very fast, TT which are very slow and M fuses which are supposed to be medium.

Slow blow is made to take short spikes and not blow the fuse. Fast blow will blow the fuse on the short spikes. You can use fast blow instead of slow blow but not the other way around. But if you use fast blow expect to change a fuse once in a while if you get an electrical spike

Undestanding varistor

A varistor is an electronic component with an electrical resistance that varies with the applied voltage. Also known as a voltage-dependent resistor (VDR), it has a nonlinear, non-ohmic current–voltage characteristic that is similar to that of a diode. In contrast to a diode however, it has the same characteristic for both directions of traversing current. Traditionally, varistors were indeed constructed by connecting two rectifiers, such as the copper-oxide or germanium-oxide rectifier in anti-parallel configuration. At low voltage the varistor has a high electrical resistance which decreases as the voltage is raised. Modern varistors are primarily based on sintered ceramic metal-oxide materials which exhibit directional behavior only on a microscopic scale. This type is commonly known as the metal-oxide varistor (MOV). Varistors are used as control or compensation elements in circuits either to provide optimal operating conditions or to protect against excessive transient voltages. When used as protection devices, they shunt the current created by the excessive voltage away from sensitive components when triggered. The name varistor is a portmanteau of varying resistor. The term is only used for non-ohmic varying resistors. Variable resistors, such as the potentiometer and the rheostat, have ohmic characteristics.

Understanding the USB to TTL converter

You can read more about them here.

Understanding the ESP8266 WI FI module

You can read more about it here.

Signals and connections of the ESP8266 ESP-01 WI FI module

TXD (TX, TXO or UTXD) – transmit pin. Connected to Arduino Uno pin 1.

RXD (RX, RXI or URXD) – receive pin. Connected to Arduino Uno pin 0.

VCC (3V3 or 3.3V)- power supply pin (3-3.6V). Connected to 3.3V DC 1A and more external power supply. The current required for the ESP-01 during Wi-Fi operation vary from 250mA to 750mA.

RST (RESET) – reset pin. Keep it on high (3.3V) for normal operation. Put it on 0V to reset the chip.

CH_PD (CHIP_EN or EN) – Chip enable. Keep it on high (3.3V) for normal operation.

GND – Ground. Connected to Arduino board GND pin

GPIO0, GPIO2 (IO0, IO2) – General Purpose Input Output pins. 


To power the ESP8266 ESP-01 Wi-Fi module from mains voltage, we will be using the HLK-PM03 to provide 3.3V to the VCC pin. If you need 5V to power ESP8266 ESP-12E module or ESP32 development board through the VIN pin, you can use the HLK-PM01 and works the same way.

You can attach the HLK-PM03 directly to the ESP8266 ESP-01 Wi-Fi module VCC pin. We advise to add a protection circuit with a thermal fuse and quick-blow fuses. We also suggest to add capacitors to the HLK-PM03 output in order to smooth the voltage peaks and prevent unexpected resets or unstable behavior powering the ESP8266 ESP-01 Wi-Fi module and to add a varistor to protect the circuit from voltage peaks across the mains input.

For testing purposes, we’ve soldered the circuit on a prototype board.

The thermal fuse used in the circuit is a 72ºC fuse. It means you need to be very careful when soldering it as the heat from the soldering iron can cause it to blow. To learn more about how to solder thermal fuses, we recommend taking a look here.


The J1 and J2 terminal blocks are connected, you should connect mains voltage to them.

The 3.3V and GND after the capacitors will power the ESP8266 ESP-01 WiFi module.

We’ve also added a three terminal block connected to the ESP8266 ESP-01 WiFi module to get access to 3.3V, GND and GPIO 2 to control the 3.3 VDC relay module.

Step by Step instruction

1.Programming (uploading sketch) to ESP8266 ESP-01 module

You can read more about it here.

2. Adding ESP8266 platform to Arduino IDE

The Arduino environment has to be set up to make it compatible with the ESP8266 ESP-12E module. We are using PC with Windows 7 OS.Download and install the Arduino IDE. You can download it here 

Open Arduino IDE. 

Open the Preferences window from the Arduino IDE. Go to File -> Preferences.


Enter into Additional Board Manager URLs field and click the “OK” button. If you already have a URL in there, and want to keep it, you can separate multiple URLs by placing a comma between them. (Arduino 1.6.5 added an expanded text box, separate links in here by line.)


Open Boards manager. Go to Tools -> Board -> Boards Manager…


There should be a couple new entries in addition to the standard Arduino boards. Look for esp8266. or scroll down to the ESP8266 entry (usually at the bottom). Select the ESP8266 entry. When you click it an install option will appear. Select the latest version and click install


The board definitions and tools for the ESP8266 include a whole new set of gcc, g++, and other reasonably large, compiled binaries, so it may take a few minutes to download and install (the archived file is ~110MB). Once the installation has completed, an Arduino-blue “INSTALLED” will appear next to the entry.


Choose your ESP8266 board. Go to Tools -> Board -> Generic ESP8266 Module


You will see Generic ESP8266 Module on the bottom of the Serial Monitor window.

3. Uploading sketch to ESP8266 ESP-12E development board

Do wiring.

Open Arduino IDE.

Plug your USB to TTL converter with DTR Pin or without DTR Pin or ESP01 programmer UART into your PC USB port.

Choose your ESP8266 board. Go to Tools -> Board -> Generic ESP8266 Module

Select the correct com port.

Modify (with your SSID, password), verify and upload the sketch to your ESP8266 ESP-01 module. AT commands will not work after that. You need to Flash the firmware to enable them again.

After uploading the code, open the Serial Monitor to get the ESP8266 ESP-01 Wi-Fi module IP address. You’ll need it to access the web server (We have .


After uploading the code to your ESP8266 ESP-01 WiFi module and getting the IP address, place it in the circuit and apply power to the circuit. Warning: don’t touch the circuit while it is connected to mains voltage!

Open any browser from a device (PC, cell phone, tablet) that is connected to the same router that your ESP8266 ESP-01 module is.

Type the IP address (for example we had which you have seen in Arduino IDE serial monitor and press Enter button.


You should be able to control the 3.3 VDC relay remotely on your local network now (we have it connected to GPIO 2).


We learnt how to use ESP8266 ESP-01 Wi-Fi module and HLK-PM03 to power up with Mains the HiLink Web Server. If you want to use the circuit in a final application, we recommend to place it inside a proper box enclosure.


  • ESP8266WiFi library included in Arduino IDE.

Project resources:

  • See attachments on the begining of this project description

Check for more DIY projects on and!

If you are looking for high quality PCBs PCBWay is the best choice: