ESP8266 WIFI relay

The ESP8266 relay project started off as an attempt to control a relay with the ESP8266 from a wireless interface, such as a web browser. The idea can easily be achieved with a few different modules which are available from eBay relatively inexpensively. I however usually don’t like the idea of assembling several modules to form a project.

At my parents house, there is a water fountain with a pump in the backyard. I decided I’d create a wireless switch for them that they would be able to access with their smartphones to switch the pump in the fountain on and off. To start out, I assembled a few modules together, and also created one. The ESP8266 modules run on 3.3V DC, and I had some SMPS (switch mode power supply) modules around that convert mains voltage (120VAC) into 5VDC. Next, a relay module from eBay was obtained which was capable of switching with 3.3v signals. The final module I created in Kicad, and etched into a single sided PCB. This module simply contained a header for the ESP8266, 3.3V linear regulator, a transistor to switch the relay with and headers to power and interface with the relay module. I housed the three modules in a plastic electrical outlet box.


The setup worked, but was packed in the housing pretty tightly. Every time I had to open the enclosure I was worried about messing up the wiring or bending something that shouldn’t be bent, or even shorting something against something else. This jumble of modules spawned the idea for a single board that would combine them all, thereby simplifying the project, making things more compact, and also enabling with ease, the creation, and deployment of additional WIFI switches.


The schematic was not too difficult, simply the product of the modules together, or at least two of them. I designed the board to still use the SMPS module, as a kind of daughter board. Trying to design a SMPS onto this board would have been quite a challenge. The relay, and ESP8266(header) were combined into one board. Because there are two GPIOs on this ESP8266 board, I pinned the other out, with the ability to use a One Wire sensor, or other configuration if desired. In practice, a push button or, on off switch was coded for, and proved the most practical for my applications. The design went through a few revisions, one to correct a footprint bug, and the other to minimize the total footprint, or size of the board; the idea being, that the whole thing should fit in a common household electrical box.


The final product turned out pretty nicely, although there are some changes that I’d like to make regarding how the board can be powered. As the board is currently designed to only be powered with the SMPS, I’d like to also build in a powering scheme for USB, as well as one for use with lower voltages, both of the latter cases not requiring the module.

Github Code

Leave a Reply

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