esp8266 basic iot light
My home hall light switch is hidden behind the cabinet and far from the door.
It\'s hard to turn on the lights when I get home, or turn off the lights when I leave.
So I want to control the lights remotely.
Before that, here are some concerns about the remote switch: After evaluating those concerns, I still want a remote light switch, so I went to the next step.
For security reasons, you should turn off and double check no AC current before accessing any AC wires.
As with many remote receivers, the ESP8266 requires a DC current to work, so I need an AC/DC converter.
In some cases, however, the switch socket may only have a live wire, but there is no neutral wire.
In this case, it cannot provide DC current in the socket.
After checking, there are both live wires and neutral wires in the socket, and we can proceed to the next step.
There are many cheap remote control light switches on the market, but I think it is very easy to jam other home remote control channels.
WiFi connecting to my own AP using an encrypted signal should be good enough.
There are many more firmware that support ESP8266: NodeMCU, Arduino, MicroPython, ESP8266 Basic. . .
ESP8266 Basic has a really nice feature that all programs can work in webbase once I flash through the firmware.
This means I can hide the board in the socket and do not need to take it out and re-program. (
Except for upgraded firmware: P)
ESP8266 firmware reference.
: Some hot glue and transparent tape are needed for insulation. I need to connect the extra screw junction box connector, squeeze my assembly inside, access the AC/DC converter and wire the 5v power supply so I need to remove the switch socket first.
If you are using ESP-
Also, here is the connection reference: ESP-
07 after flashing ESP8266 BASIC, remember to remove the GPIO0 connection and reset (simply re-plug the USB)for testing.
Ref: remove the io0 connection and reset (simply re-plug the USB)
, You can search for WiFi AP named ESP by mobile or laptop.
Connect to ap esp and turn on the URL to connect it to home WiFi AP: I want the light switch to be controlled via the physical switch and webbase interface, so, I have written a simple switching logic to change the output of the GPIO.
Here is my sample code to edit, paste and save to ESP8266 BASIC :(
ESP will restart after saving)
Here is the summary of the connection: 5v to 3.
3 v dc/DC converter
If you are using ESP-
01. Some points that need attention.
Connecting a pnjunction transistor to a GPIO results in a side effect that will pull the pin down. ESP-
01 only gpo0, gpo2, Tx (GPIO1)and Rx(GPIO3)
When you turn on the power supply, you will enter the flashing mode by pulling the GPIO0 or gpo2;
Connecting 2N2222 to Tx also fails to start normally.
Hopefully it can still be connected to the GP3. everything works fine.
Seal all AC connected parts using hot glue and then cover the DC/DC converter and ESP board with some clear tape.
Squeeze all the components onto the socket and re-
Assembly switch socket.
I want the light to be controlled by the relay connected by the physical switch and the ESP, so it needs a series switch and relay.
Make sure your mobile connection home WiFi: this ESP8266 base light is actually connected to the home LAN only, not the Internet, however, if you have set up your home VPN, it still has remote control over the light outside the home.