The Amazon Echo is a great piece of kit! I love the idea of voice activated devices!
I wanted to make my own Alexa operated lamp, but keep the manual switch as an option.
I searched the web and found a WEMO emulator, which, having looked at other options, this seems the most simple way of getting Alexa to operate any device!
**** IMPORTANT NOTE: RESPECT MAINS ELECTRICITY - IT WILL KILL YOU ****
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: The Harware
The component count is minimal thanks to the ESP2866-12e which does all of the work!
All of the components came from eBay.
1 x ESP2866 -12e (or any ESP8266 with at least 2 GPIO ports)
1 x 5v power supply
1 x 5v relay. I found these very small relays with 5v coil & 250v 3 Amp contacts on eBay
1 x 5v to 3v3 step down
1 x opto coupler (4N35 or equivalent)
1 x momentary action push to make switch
1 x suitable project box
The image shows a resistor which was not required!
Step 2: Putting It Together
I wanted the project to live in a compact enclosure so it wouldnt look too unsightly.
It simply replaces the lamps original switch with a relay and a 'soft' switch!
Its important to ensure that the mains side (the bit that will kill you) is installed as securely & safely as possible - I used a 'choc block' connector for safety and ease.
The relay coil connectors are pretty close together so take care when wiring. Keep the exposed 5v coil wires and mains connections as short as possible.
The mains feeds the 5v power supply. The neutral side of the mains goes direct to the lamp, whereas the live side goes via the normally open contacts of the relay.
The switch is wired one side to ground and the other to GPIO13 of the ESP8266. Any input will do but check the data sheet as some pins are multiplexed.
GPIO15 is wired to 0v !! I have a piece of wire attached to Reset & another to GPIO0. These are used for uploading the sketch and can be removed when complete.
Note that the ESP8266 devices operate at 3.3v
GPIO4 (again any GPIO will do) is used to set / reset the relay via an opto coupler. I used the opto coupler to minimise current drain on the ESP8266.and allow the 3.3v to switch the 5v relay coil.
I used double sided sticky pads to keep the components in place.
I drilled a couple of 2mm holes at each end of the enclosure for air flow. Not sure if it was nrcessary as very little heat is generated, but it made me feel better :-)
Step 3: The Sotfware
I downloaded the following from GitHub.
The files are all in one directory and the only file which needs modifying is the .ino file.
It shows how to operate multiple switches and is a great piece of software.
I used the Arduino IDE to upload the sketch to the ESP. There are lots of articles on the web of how this is done, just Google - Using Arduino IDE to program ESP8266. Its pretty straight forward and only has to be set up once.,
Note: To upload the sketch I used a standard FTDI usb to serial convertor. GPIO15 must be grounded - I have this permanently wired to 0v, GPIO0 must be held to 0v during reset. After reset, GPIO0 can be left floating. The sketch should now upload.
The parts in the sketch which need modifying are repalcing your routers SSID & Password and the the command you would like Alexa to respond to. Search for 'table lamp' and replace it with a command of your choice, e.g. 'bedside light' or 'ceiling fan'.
The software interacts with Alexa and switches GPIO4 high or low with the the commands table lamp on and table lamp off respectively. It also sets flags - rl1 and isr_ran.
Flag rl1 is used so the software knows the current state of the lamp in order for it to be toggled on or off via Alexa or the switch.
The switch generates an interrupt when GPIO13 is grounded. The interrupts are disabled, GPIO4 is toggled and flag rl1 is set / reset accordingly. Flag isr_ran is used in the main loop to re-enable interrupts after a short delay - this prevents switch bounce!
Imortant note :Ensure your choice of relay has capable contact ratings to deal with the device you are switching.
Runner Up in the
Voice Activated Challenge