Create your own Alexa capable switch for under $10
This has been tested with a NodeMCU v1.0 (USB based dev kit) as well as a LinkNode R4 (serial with 4 relays)
- Install the Arduino software
- Add ESP8266 board support to Arduino by adding
http://arduino.esp8266.com/stable/package_esp8266com_index.json
to the Arduino app preferences Additional Boards Manager URLs - Add TimeLib library to Arduino by downloading latest zip and adding that download to Arduino using Sketch > Include Library > Add .ZIP library
- Add WiFiManager library to Arduino by using Sketch > Include Library > Manage Librarys then searching for WiFiManager by tzapu and pressing Install
- Open the esp8266-multi-wemo.ino file in Arduino and Sketch > Verify/Compile
If you have no errors you are ready to proceed!
Flashing the boards varies a little primarily because the ESP8266 doesn't include USB communication but rather uses a UART interface. Here's the two I've used;
The NodeMCU includes a SiLabs SI2102 USB chip to handle the UART communication with the ESP8266. Install the SiLabs USB to UART driver compatible with this board
Choose the following settings from the Tools menu in Arduino:
- Board "NodeMCU 1.0 (ESP-12E Module)"
- CPU Frequency "80 Mhz"
- Flash Size "4M (3M SPIFFS)"
- Upload Speed "460800" (Lower this if you get errors)
- Port "/dev/cu.SLAB_USBtoUART" (Mac, Windows will be different)
This board does not include a USB to UART converter so you'll need a suitable cable and the appropriate drivers. I used the Adafruit 954 the older model of which uses a chip by Prolific and it's own drivers. Newer versions of this cable use the SiLabs chipset and drivers described in the NodeMCU section above.
Choose the following settings from the Tools menu in Arduino:
- Board "Generic ESP8266 Module"
- CPU Frequency "80 Mhz"
- Flash Size "4M (3M SPIFFS)"
- Upload Speed "115200" (Lower this if you get errors)
- Port "/dev/tty.usbserial" (Mac, Windows will be different)
Note that the generic board doesn't include device-specific pinouts so you'll need to find out what IO pins are wired to what and make appropriate changes to the source code by adding a section to the top of the source after the #includes for each pin.
const int D1 = 13;
Based on code by Kakopappa
Subsequently added:
- WiFi Manager support and SoftAP mode to avoid hard-coded WiFi credentials
- NTP time-server support and necessary changes to headers
- Various code refactorings