This is a super simple project but provides a good introduction to the ESP8266 and Lua. A "Hello World" of Wi-Fi projects.
- Flash the nodeMCU firmware to your ESP8266. In order for this project to work, you will need the PWM, HTTP and WiFi modules enabled. The firmware in the documents section has everything you need.
- Butcher your lack-luster battery powered christmas lights as explained in "the circuit" below. I stuck all my components on a bit of proto board.
- Upload the lua script and HTML page to your ESP8266. I use ESPlorer to handle this side of things. Set your baud rate to 115200 when using the firmware.
- Plug in the module and connect to the Wi-Fi access point.
- Navigate to 192.168.4.1 (the default IP address served up by nodeMCU in AP mode).
- Make christmas lights flash!
As an optional extra, I installed my lights inside an Altoids tin (of course) and attached a second string of lights. If you go down this route, make sure you protect any wires from shorting on the case.
Super simple! Hook up pin 1 of the nodemcu to a mosfet transistor and put this between the fairy lights and the ground pin. That's all there is to it! If you have no emotional attachments to the lights, just chop the wires off where they enter the battery pack and solder them to the correct ESP pins.
Still confused? Here's a hand drawn gloomy circuit schematic.
This is the more interesting part of the project and a more detailed explanation is in the project logs below. However, here are a few things I learnt:
- NodeMCU has a low buffer limit which restricts the amount of HTML you can dump in a single file;
- It is possible to monitor the results of an HTML form input pretty easily (although this was frustrating to start with as I couldn't work out where in the payload they were found).
A reasonably straightforward HTML form with four sliders for the different settings: