Introduction: Alexa Smart Lamp With ESP8266
This Instructable guides you along with me in upgrading a vintage lamp with voice-control using an ESP8266 microntroller and Amazon Echo/Alexa. The Arduino code emulates a Belkin WeMo device using the fauxmoESP library, which makes setup a breeze.
Please note: This project code has been invalidated by the fauxmoESP library's change to emulate the Philips Hue protocol instead of Belkin WeMo. If you update it to work with the new version of the library, please let me know!
For a full primer on the Arduino ESP8266 workflow, check out my free Instructables Internet of Things Class, and check out Paige's Lamps Class for more lighting inspiration and know-how. If you're new to Arduino, we have an intro class for that, too.
This project uses AC electricity, which could harm you or start a fire-- don't leave this project connected to power unattended, and if you don't know what you're doing, work under the supervision of someone who does.
For this project, you will need:
- Amazon Echo (and Alexa app)
- Lamp (mine is 60W)
- Computer running Arduino software with ESP8266 support installed
- Adafruit Feather Huzzah ESP8266 microcontroller board
- Adafruit Power Relay FeatherWing
- Extension cord
- USB power adapter (at least 1A, I used one from an iPhone)
- USB cable (microB)
- Toggle switch and wire (optional)
- Third hand tool (optional)
- Tweezers (optional)
- Heat shrink tubing
- Heat gun (or lighter/hair dryer)
- Wire strippers
- Flush diagonal cutters
- Wire nuts
- Soldering iron and solder
For my particular wooden lamp base:
- Wood chisel and mallet
- Vice
- Hacksaw
- Metal file
- Drill/press with forstner bits
- Sander wth 220 grit paper
- Wood finish (with gloves, brush, etc.- read package instructions)
In addition to ESP8266 board support, you should install the following Arduino libraries (search in library manager or manually place folder in Arduino/libraries):
I learned about this method from this Adafruit tutorial: Easy Alexa (Echo) Control of your ESP8266 Huzzah, which has plenty more useful info about using this code in your own projects.
To keep up with what I'm working on, follow me on YouTube, Instagram, Twitter, Pinterest, and subscribe to my newsletter. As an Amazon Associate I earn from qualifying purchases you make using my affiliate links.
Step 1: Connect Relay
To control the AC portion of the circuit, I'm using a Power Relay FeatherWing-- just interrupt the hot lamp wire and plug the stripped ends into the Normally Open and Common screw terminals. Remember, if you don't know AC, find someone who does to supervise. My lamp had a switch along the cord, so I just removed it and used the wire that the switch had been controlling.
Don't forget to bridge one of the jumpers on the underside of the board, corresponding with the microcontroller pin you'll use on the ESP8266. I followed the setup tutorial for the Power Relay FeatherWing and bridged the jumper shown to control the relay with pin 13 on my Feather Huzzah ESP8266.
I always build a breadboard prototype of these types of circuits first, even if the ultimate goal is to get everything to fit in the wooden base of the lamp.
Step 2: Program Microcontroller & Test
The Arduino code for this project uses the example sketch for the fauxmoESP library, which emulates a Belkin WeMo device. Consequently, configuring your homebrew is exactly the same as the commercial device, which is a breeze in the Alexa app. For natural speech's sake, I've named my device "the light."
I decided later to add a power override switch so the lamp could be controlled independently of the voice commands. That's why it's not in the breadboard photos here, but appears later during the wood step. You don't strictly need the button to test the code, so you're all good either way. Watch the video embedded in Step 1 to see me explain how the button code works! Download the code from this step and plug in your own wifi network name and password, and customize the name of your device.
Attachments
Step 3: Chisel Wood Base to Fit Components
After confirming that everything works, it's time to tackle the woodworking portion of this project. This lamp is held together by a threaded rod, which is easy to shorten with a saw or rotary tool cutoff wheel, then filed smooth so the adjuster flange can still be screwed on. I chiseled out the wood base to accomodate my components.
I sanded the wood base to remove any dings from messing with it, and finished it with some wood stain.
Step 4: Use It!
It feels natural to say "Alexa, turn the light on," so I felt extra clever in naming my smart light. To have multiple devices on the same network, you could tell them apart by naming them "the hallway light" or "the nightlight," for example. Is this really any better than purchasing a WeMo switch? If you've read this far in the Instructable, surely we can agree that it's just more fun to build your own, especially with the custom vintage lamp upgrade and all-in-one design.
What smart home projects do you have under your thinking cap? Let me know what you're working on in the comments below.

Participated in the
Home Improvement Contest 2017
51 Comments
Question 5 months ago on Step 4
Hello Bekathwia,
I build your project wtih a nodemcu and when i start it, i see that is connect to my network with a IP adress. When i open my Alexa app and try to find the device then i can not find it ?? what am i doing wrong ? in the app i add a device and choose for other and let the app surge for it.
Peter Jochems
Question 3 years ago
Hi Becky,
When I attempt to compile your program (I have the correct libraries in the correct places) the compile baulks at "fauxmo.onMessage(callback);"
and the error is "class fauxmoESP' has no member named 'debug_onMsg"
Any thoughts? Also my alexa can not "see" the esp8266
Thank you and Merry Christmas
David
Answer 2 years ago
Go to the following link:
https://bitbucket.org/xoseperez/fauxmoesp/src/mast...
You need to write the onSetState function in the setup function as in this example.
Please note, you will need to replace your code with the code from the example or your code will not behave properly.
Also, make sure to delete the original on call function,
This will resolve your error.
Reply 2 years ago
Thank you.
Excellent response.
I have moved on from this now although I checked the links and installed on a spare 8266 and all works.
Keep up the good work
D6
Question 4 years ago on Step 2
Hello Becky Everything looks fine except that the Arduino compiler throws an error "'class fauxmoESP' has no member named 'onMessage'". Does that mean that the library has changed since you put this tutorial together? Can you offer any advice?
Steve
Answer 2 years ago
Go to the following link:
https://bitbucket.org/xoseperez/fauxmoesp/src/mast...
You need to write the onSetState function in the setup function as in this example.
Please note, you will need to replace your code with the code from the example or your code will not behave properly.
Also, make sure to delete the original on call function,
This will resolve your error.
Answer 4 years ago
HMM having same error....
Reply 4 years ago
Hi I think fauxmoESP has changed as I think it now emulates a Philips Hue and there is some changes you have to make if you are using alexa gen3
3 years ago
Hey Becky, may you help me out with the code hat may work with the Alexa Gen3. The given code is not working with this kind of devices. Please !
Best regards , Rafael . May-2019
4 years ago
Hi from India Becky, I am amazed to see you so good with electronics and circuits.
You are certainly a inspiration for our next gen.
I flashed your code on a D1-Mini board, and it connected fine to my Wi-Fi but Echo Dot (v3) is unable to discover the device.
Here's the serial output.
----------------------------------
FauxMo demo sketch
After connection, ask Alexa/Echo to 'turn <my light> on' or 'off'
[WIFI] Connecting to 4G-Tower ..........................
[WIFI] STATION Mode, SSID: 4G-Tower, IP address: 192.168.1.45
off
----------------------------------
I am able to ping that board from my Laptop but Alexa is not ready to discover it !!
Anything I may be missing ??
Question 4 years ago on Step 2
as the wemos d1 is acting as a webserver can it serve any other information like sensor data from the gpio pin.
Not sending it to the echo necessarily. could receive it on a browser.
Question 5 years ago
Can someone confirm if this still works?
Because I can't find the devices
Answer 4 years ago
are you still having problems.
Are you using echo gen3?
Answer 5 years ago
I re-setup my device five days ago, and it works great. I'm on Android FWIW. Did you double check these things:
Is your mobile device on the same wifi network as your circuit?
Can you verify with the Serial Monitor that your device is successfully joining your wifi network?
Question 4 years ago on Step 2
Hello, nice great project, I create this project and works!. I would like to know that if there is any type of easy step for Google assistance.
5 years ago
Ms. Stern, you are the Bomb and I truly enjoy your work. How do I say this without sounding like a sexist pig? There should be WomanMakers like you (and LadyAda) to inspire our Daughters and Sons (and us).
On and off is good, but I want to see Alexa/Echo control Neopixels...
Reply 5 years ago
To answer your question sincerely, just remove all the gender nonsense and leave it at "you are the bomb," no qualifiers needed. And thank you.
It's easy to control NeoPixels with this, take a look at the Arduino code and you'll see where it activates the relay currently can be swapped with pixel code.
Reply 5 years ago
You are the bomb. I know the joy of teaching what you are good at and love. I do it too. Thanks.
5 years ago
Another reason to roll-your-own might be reliability. In reading all the comments on Amazon it seems that quite a few people (12%) think the Belkin WEMO Smart Plugs are junk due to bad experiences and failures. This reminds me of 20 years ago when I bought a bunch of X-10 modules and controllers. I loved them at first but one-by-one they bit the dust. I've been reluctant to buy this kind of technology since. Thanks for the Instructable!
Reply 5 years ago
oh man, x-10, really bringing me back!