Introduction: Smart Wi-Fi Switch

This is something that has happened to me very often, and I find it very annoying when I come and lay down on my bed and then realize that I forgot to turn off the light, and the light switch is on the other side of the room, and I have to get up and turn off the lights. So I decided I would build a Smart Wi-Fi Switch so that I could ask a voice assistant like Google Assistant to turn off the lights. This way, I won't have to get out of bed again to turn off the lights. This is also useful when I am reading a book before going to bed because now I don't have to get up to turn off the lights.

Step 1: Supplies

The components needed to make this project are:

Step 2: IR Sensor Wiring

Connect the IR Sensor as the following:

ESP8266 >> IR Sensor

GND >> GND

3V >> VCC

D6 >> OUT

Step 3: Servo Motor Wiring

Connect the Servo Motor as the following:

ESP8266 >> Servo Motor

GND >> GND

3V >> VCC

D5 >> Signal

Step 4: Setting Up Adafruit (Step 1)

For the servo to turn the lights on and off over Wi-Fi you will have to set up an online service that the ESP8266 can connect to. A free online server I am using is Adafruit.IO.

Step 5: Setting Up Adafruit (Step 2)

Step 6: Setting Up Adafruit (Step 3)

Step 7: Setting Up Adafruit (Step 4)

Step 8: Setting Up Adafruit (Step 5)

Step 9: Setting Up Adafruit (Step 6)

Step 10: Setting Up Adafruit (Step 7)

Step 11: Uploading the Code

You will have to make some changes to the code for it to work properly. Start off by entering your network SSID, and password. Go back to Adafruit and click on "My Key." Copy your username and authentication key onto the sketch. Make sure you have the correct board and processor selected before you upload the sketch.

For more information about this, please visit my Patreon: https://www.patreon.com/acedinventor

Step 12: Testing Online Server

If everything is working properly you should be able to turn the switch on and off on your phone and the servo should rotate up and down.

Step 13: Setting Up Google Assistant (Step 1)

Now if everything is working properly you can head over to IFTTT, to connect Adafruit to Google Assistant. This way you don't have to touch your phone to turn the lights on or off.

Step 14: Setting Up Google Assistant (Step 2)

Step 15: Setting Up Google Assistant (Step 3)

Step 16: Setting Up Google Assistant (Step 4)

Step 17: Setting Up Google Assistant (Step 5)

Step 18: Setting Up Google Assistant (Step 6)

Step 19: Setting Up Google Assistant (Step 7)

Step 20: Setting Up Google Assistant (Step 8)

Step 21: Setting Up Google Assistant (Step 9)

Step 22: Setting Up Google Assistant (Step 10)

Step 23: Building the Housing

The last step in this project is to make the housing and mount it onto the light switch.

Step 24: Testing Complete Project

To test the project start off by signing in to Google Assistant with the account you used for IFTTT. Now you can ask Google Assistant to turn the lights on or off for you. The lights will be able to turn on or off from anywhere in the world as long as the ESP8266 and your phone has connection to the internet.