The ESP32 Microcontroller measures the light in the living room as well as the corresponding time and sends an HTTP POST request to an IFTTT webhook service that then turns a WeMo Smart Plug on/off. The process is overriden from 11:00pm to 9:00am.
There are two ESP32 circuit diagrams that reflect the testing and the final deployment circuits. The difference between the two being the presence of an LED that represents the HTTP request being sent. Here you can see the final version of the circuit:
- Host Device = Windows 10 desktop running Windows Subsystem for Linux (v1) with Ubuntu 18.04.4 LTS
- Embedded Code IDE = Arduino IDE (v1.8.13)
- Host Code IDE = VSCode (v1.50.0)
- ESP32 (Affordable microcontroller with bluetooth and WiFi networking capabilities)
- WeMo Smart Plug (Network-controlled current relay that interfaces with IFTTT)
- Photoresistor (Simple and cheap light dependent resistor)
- Jumper Wires
- Small Breadboard
- 5V DC Power supply (Standard 5V DC power supply with micro-USB connection for ESP32)
- Resistors (Specifically 10kΩ and 100Ω, present in many electronic kits)
- LED
To replicate this project, follow these steps:
-
git clone https://github.com/alemorm/SmartLight.git ~/
-
Write the name of your network within the double quotes next to
wifiName
in the fileauth.keys_template
and rename it toauth.keys
-
Write the password of your network within the double quotes next to
wifiKey
in the newly renamedauth.keys
file -
Create an IFTTT account
-
Connect a Webhook service to your account
- Click on Documentation after you added the webhook and copy the key value within the double quotes next to the
iftttKey
in theauth.keys
file
- Click on Documentation after you added the webhook and copy the key value within the double quotes next to the
-
Connect a WeMo smart plug to your account
-
Create the following IFTTT applet:
- If This -> Search and select Webhooks
- Under event name write
lamp_on
- Under event name write
- Then That -> Search and select WeMo Smart Plug
- Select the
Turn on
action
- Select the
- If This -> Search and select Webhooks
-
Create the second following IFTTT applet:
- If This -> Search and select Webhooks
- Under event name write
lamp_off
- Under event name write
- Then That -> Search and select WeMo Smart Plug
- Select the
Turn off
action
- Select the
- If This -> Search and select Webhooks
-
-
Download and install the Arduino IDE (can be any PC/Mac/Linux OS version):
-
Open the Arduino IDE and follow this quick tutorial to add the ESP32
- This specific project used the NodeMCU-32S variant of the ESP32 but make sure to check which ESP32 variant you are using
-
Follow this additional quick tutorial to add the Arduino ESP32 filesystem uploader plugin tool to the Arduino IDE that lets you add files to the ESP32 using the SPIFFS filesystem:
- Once the tool has been configured, make sure to select Tools>ESP32 Sketch Data Upload to upload the
auth.keys
file to the ESP32
- Once the tool has been configured, make sure to select Tools>ESP32 Sketch Data Upload to upload the
-
Then, follow this circuit schematic to set up the testing light-sensing circuit.
- Once the Arduino IDE has been configured to use the ESP32S, open the
TimeLightClient
source file on the Arduino IDE and upload the code to the board (making sure the debug_var is set to 1 to see the serial output).- Once the code is done compiling and uploading, open the Serial Monitor under Tools>Serial Monitor and monitor the light and date/time values.