Home Automation WiFi Light Switch With ESP-01 and Relay Module With Push Button

Introduction: Home Automation WiFi Light Switch With ESP-01 and Relay Module With Push Button

So in the Previous instructions we programmed a ESP-01 with Tasmota using a ESP Flasher and connected the ESP-01 to our wifi networks.

Now we can start programming it to turn on/off a light switch using WiFi or the push button.

For the electrical work, please consider getting an electrician. Please do not attempt opening a light switch or attempt to do any of the following.

Danger: Playing with electrical outlets and switches can kill you. please consider getting a professional to do these installations for you.

Step 1: Relay Module

You can obtain a relay module from anywhere. here is a link to the Amazon seller:

Relay Module for ESP-01

  • These units operate with 5v - 9v DC and able to control loads up to 10A at 125VAC. please note that ESP-01 module on the other hand should be operated at 3.3V only. Any higher voltage will kill the little guy. This relay module has the voltage regulator built-in to supply the ESP-01 with solid 3.3v from the 5v that is supplied at the double terminals on board.
  • It has a reset switch.
  • It has a nice 8pin female connector for the ESP-01
  • the relay 3 conductor terminal can operate in Normal Open (NO) or Normal Close (NC) as it is marked on the back of the circuit board. The CO is the common port.

Step 2: Adding the Esp-01

Once the already programmed ESP-)1 is inserted into the relay module:

  • power up the unit using an external 5V-9V power supply.
  • You will need to know the IP address of this unit connected to your home WiFi
  • You can find this IP address by looking at your wireless router client list
  • Or you can use a network scanner and scan your wifi network for new IP addressees.
  • If you are not figure out, check the MAC address of your devices.
  • If this is the first ESP-01 module on your network, its MAC address have the 5C:CF:7F as the first 3 octet.

Step 3: Accessing and ESP-01 With Browser

Once you found the IP address of your ESP, launch your browser and type http:// and enter the IP address right after that (No Spaces).

You should see the page like in the picture.

Click on the "Configuration"

Step 4: Changing the Configuration

Now click the Configure Module.

From the drop down, go to the bottom of the list and choose the Generic (18) from the list and click save.

The unit will restart you should get back to the Main Menu.

Once again choose "Configure Module" and then add:

  • Relay1 (21) for the GPIO0 (D3)
  • Also add Button1 (17) to GPIO2 (D4)

The relay is already connected to the ESP-01 on the Relay Module.

we will be adding a push button switch to GPIO0 so we can power on and off the light either using the wifi or the push button. You can turn on the light with the push button and turn it off with wifi or the other way around.

Step 5: Testing the ESP-01 Via WiFi

Now you should be able to get back to the main menu and see the toggle button.

You should be able to hear the relay switch on and off when the toggle button is pressed.

Sometimes you have to change the way the relay is configured based on if you are using the NC or NO connections.

I personally, like to have relay always in the off more (The light is off)

so for that I connect a multi-meter to NO and CO ports and make sure the ESP is powered off

If after the ESP-01 is powered up, you noticed that your NO relay connection does not match the on screen switch position (ON or OFF), you can change the Relay1(21) in the configuration to Relay1i(29) in your configuration screen.

Step 6: Making the Box and Power Adapter

So lets get the following for your project. Please feel free to google for the bargains as the prices are not the same every where. I mainly added the link to the place you can buy it strictly for the information on the item itself. you are not obligated and encouraged to google for the best prices. (Of Course you knew that).

  • Blank single gang switch plate. You will need to drill a hole at the very center of it big enough for the push button switch.
    1 Gang Blank Adapter

Step 7: Now Lets Connect Them All Together

  • Connect output of the 125/5v dc module to Relay Module DC contact terminals
    Please note the Positive and negative on the Step-Down Module and on the Relay Module
  • Connect the + and - of the push button to the Step-Down Module

  • Connect on side of the momentary push button to GND, Negative

  • Connect the other side of the Bush button to GPIO2 on the back of the ESP-01.
    I used a small soldering iron and made that connections. See above picture for the location of the GPIO2
    The red arrow shoes the GPIO2 port.

  • Solder two wires for the input power to the DC adapter module.
  • Add two pieces of electrical wires to the NO and CO of the relay Module
  • Pack all the pieces into the printed box using the pictures provided.

NOTE:

I am not going to illustrate the connections to the light switch here. Please get a professional to install it for you.

If you have any questions on that, please contact me and I will share my diagrams with you.

Peace.

Be the First to Share

    Recommendations

    • Tinkercad Student Design Contest

      Tinkercad Student Design Contest
    • Organization Contest

      Organization Contest
    • Lamps and Lighting Contest

      Lamps and Lighting Contest

    Comments