ESP-01S – Wi-fi Relay module for light remote control

In this tutorial, we will learn how to build a wi-fi switch, and use it remotely. If you want to remotely control the lights in your house or sun blinds, just have to copy this wifi switch and increase the number of switchs. You can have access to schematics, PCB and firmware in this GitHub.
You can also see other project like this one, that are more advanced, like: BH OnOfre or sonoff.

Parts Required

ESP-01S Relay module

Figure 1

This WiFi relay based on ESP-01/ 01S WiFi module, we can use one GPIO of ESP-01/ 01S to control the relay by low level. It’s easy to make your smart switch to any device by your phone anywhere with this smart relay.


  • Working voltage: DC 5V-12V
  • Working current: ≥250mA
  • Communication: ESP01 or ESP 01S
  • WiFi module Transmission distance: the maximum transmission distance is 400m (open environment, mobile phone equipped with WiFi module)
  • Load: 10A/ 250VAC, 10A/ 30VDC, 10A/ 30VDC, 10A/ 28VDC
  • Size: 37 x 25mm

Blynk Android app

There are a lot of android aplications for IOT. We will use blynk APP. Other application for desktop can be used, but we will keep it android for now.

Blynk is a hardware-agnostic IoT platform with white-label mobile apps, private clouds, device management, data analytics, and machine learning. You should check their Website to know more about Blynk.

Figure 2

So to install and configure the app, you must follow the tutorial in their website. However if you follow the blynk tutorial, you will end up using the server. The server is a good option because, is safe, continuous and fast. Although server is currently providing 2.000 of energy, which limit your Dashboard. To solve this problem, you can use public free blynk servers, from this GitHub. Remember that this servers are unreliable and can have intermittent shutdown. I will use the second server, but you can use any of them.

To change the server for the, in the login in page of the app, when choosing the server, you need to click on the “3 dots” botton and copy the server name and App port, as shown in figure 2.

Figure 3

Affter making the instructions above, you will receive an email with a token. We will use that token in the code for access to the server. To beggin, creat a new project and name it as you desire. In this tutorial, it will be “Wifi Switch”.

Figure 4

Below the project name, you need to especify the hardware. Choose the ESP8266 option.

Figura 5

In the project settigs menu, you can insert more devices. Each device will be an individual ESP-01S WiFi module, then the blynk app will generate an especific token for each one. We need the tokens, to futue use in the code.

Figure 6

Go to main screen again. Swipe the main screen to the left to open the widgets menu, and insert a button. Press the button to open the button settigns, and choose the device, the output pin in the device and the operation mode. Create one or more buttons, for each device you have.

Figure 7

When you are choosing the output pin in the device, choose the virtual pin V0, to be equal to the code.

Figure 8

For now on, we just have to program our devices and connect them with the blynk app, and we are fine.


Figure 9

Connect the DC output of the HI-LINK Power Supply to the 2 Pin Screw Terminal and connect the input to AC mains. Be carefull, connect everything unpluged from the mains!! This is enouthg to power the board and start programing. The 3 Pin Screw Terminal are the relay pins, and must be the switch to your lamp or device.

A Proto-board can be used to mount and solder the parts. However, it is very good, if we use a PCB software design to build a PCB for this project. In this case, Eagle was selected. You can use other softwares like, Altium, Kicad or more. The final product is a small and compact PCB, that fit inside de wall socket. The Top and bottom layers can be seen in figure 10.

Figure 10


We will use a library from Blynk Git-Hub, to make the communication with Blynk app. If you do not know how to instal a library or use the library manager in arduino IDE, you can check Installing Additional Arduino Libraries.

Remember, that to be able to program the ESP-01/01S we need a FTDI Converter. If you use the FTDI mentioned above, just need to plug directly like figurxxxx.

Figure 11

Copy the main sketch bellow to your Arduino IDE project and save it. Use the Serial Monitor to debug.

2 thoughts on “ESP-01S – Wi-fi Relay module for light remote control

  1. Hello Ricardo
    Thank your for this nice tutorial.
    We use 220V power supply with two lines each one is 110V. there is no neutral or negative.
    When connected to relay, shall I connect one line from ac power supply to COM in relay and the other line to light bulb then to NO in relay.

    Is this correct?


Leave a Reply

Your email address will not be published. Required fields are marked *