Introduction: Alexa Smart Lamp With ESP8266

Picture of 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.

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:

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.

Step 1: Connect Relay

Picture of 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

Picture of 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.

Step 3: Chisel Wood Base to Fit Components

Picture of 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!

Picture of 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.


AlanW125 made it! (author)2018-01-15


I've tried everything and Alexa has not seen the device, could you help me? Because I don't know what I'm doing wrong.

mharmon12 (author)2018-01-04


Just wow!

Your series of classes; Arduino Class, Internet
of Things Class and now Alexa Smart Lamp with ESP8266 build on one
another and save me a lot of time in getting my projects up and running.

I certainly have benefited from your hard work and attention to detail.

If anyone is struggling with this then I suggest they go back and take the
classes which I've listed, because the lessons learned there will make this
lesson much easier to follow and complete successfully.

Thank you yet again for your zeal and heart for doing this work!

Willsonspocket (author)2017-12-29

Hi Beka thanks for the tutorial it was great! I have a question which I hope you can help me with.
For the switch I would like to use a normal latching on off switch like a wall switch, with this code it does work but it seems once in the cycle it requires the switch to be pressed twice to turn on or off the light, I'm currently struggling to work through the code to find a solution, could you help, was your switch a latching on off switch?
Kind regards, Karl

arallsopp (author)Willsonspocket2018-01-02

The approach I took was to use the switch as an input and monitor voltage changes, rather than absolute on/off states. That way you can turn the lamp off via Alexa or Wifi, and still toggle power states when the switch is moved. I went a step further and used an inline rocker on a 3 way flex, with the spare wire being used to connect a signal to ground. That way, the aesthetic of the lamp is retained, the operation is faithful, and the smarts are all hidden away.

dlcomm (author)2017-12-13

Works well with the echo plus and the dot but the Alexa app says "device not responding" and does not pick the current state. Any ideas?

KIRANA4 (author)2017-11-06

Users/kk/Downloads/fauxmoESP-lamp-becky-stern/fauxmoESP-lamp-becky-stern.ino:3:25: fatal error: <fauxmoESP.h>: No such file or directory

#include "<fauxmoESP.h>"


compilation terminated.

exit status 1

Error compiling for board NodeMCU 0.9 (ESP-12 Module).

bekathwia (author)KIRANA42017-11-06

it looks like you haven't installed the fauxmo library, or put it in the incorrect place. Please check out the links in the intro to my beginner Arduino and Internet of things classes for a walkthrough detailing library installation.

KIRANA4 (author)bekathwia2017-11-06

im aware af doing that .. maybe its not the correct library

is it version 1 library what u were using ?

bekathwia (author)KIRANA42017-11-06

Your error message indicates that Arduino can't find the library file, which should be located in Arduino/libraries/fauxmoESP or installed through the library manager (screenshot attached). The version of the library being different would not cause this error (but FWIW I've got 2.1.0 installed, code compiles fine).

KIRANA4 (author)bekathwia2017-11-06

is this the same one ?

bekathwia (author)KIRANA42017-11-06

Yep that's the one!

KIRANA4 (author)bekathwia2017-11-06

well still not happening

could you please forward me the libraries to my email when you are free ?

bekathwia (author)KIRANA42017-11-06

Nope, that's not how this works. You must put your library in the proper location for Arduino to find it-- me emailing it to you won't help if you don't know where to put it. Here's a tutorial with more info:

KIRANA4 (author)bekathwia2017-11-06

thanx let me have a look!

KIRANA4 (author)2017-11-06

could not compile.

bekathwia (author)KIRANA42017-11-06

it looks like you haven't installed the fauxmo library, or put it in the incorrect place. Please check out the links in the intro to my beginner Arduino and Internet of things classes for a walkthrough detailing library installation.

CaptClaude (author)2017-10-31

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...

JeffM15 (author)2017-09-13

Awesome!. Enjoy watching you make instructables.

AlexanderR (author)2017-08-31

Is possible this’s work with Siri?

LeeC93 (author)2017-08-10

Great project, I may try it when I buy a echo.

I am wondering if my Alexa on my fire stick TV can switch it on and off.

The next question is possibly change out the button to a touch detection.

I did a touch plate on an Arduino Uno or my Nano several years ago, not sure where that code is today, new PC. but that is a metal lamp or just add a plate over the back where your switch is at.


kilgore64 (author)2017-08-01

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!

Danny Lu (author)2017-07-19

I got the adafruit esp 8266 board, set everything up, and uploaded the program. But the echo dot is just not discovering it. Since it's a WeMo emulator, do I have to enable the WeMo skill? If so I don't have a WeMo switch, is there any way around it? (It only lets me enable the skill if I have a WeMo switch)

bekathwia (author)Danny Lu2017-07-22

The device does ultimately show up as a WeMo Switch, but I did not have to enable the WeMo skill to get it to show up in the app.

Before jumping to the app side, you might want to confirm that your ESP8266 is successfully joining your wifi (did you update the username and password in the sketch?). Resetting your board while the Serial Monitor is open should help you determine if it's just a network connection thing.

Danny Lu (author)bekathwia2017-07-22

The wifi is connected, in the end it says "STATION Mode, SSID: REBA, IP address:".

But whenever I try to discover devices it doesn't show anything. I'm using the Echo Dot. I'm thinking it's a new update that made it not connectable.

bekathwia (author)Danny Lu2017-07-23

It's hubris to assume because it's not working, it must be because of somebody else-- there are a lot of little twiddly things involved in troubleshooting IoT projects. Don't give up! I made this project one week ago and just checked-- I'm able to discover the device running this code again and again on my android device. Here are some more things to try:

-Is your Dot registered in your Alexa app? The app establishes the bridge between the voice commands and the ESP8266. If your house is anything like mine, there was some initial confusion about whose Amazon account was really connected to the Dot.

-Is your Alexa app up to date? Can you access Smart Home>Devices>Discover? Try resetting the ESP8266 during the app's discover process, and restarting your phone.

-Oh, and make sure your phone is on the same wifi network as the ESP8266.

If any of these solve the problem, please let me know and I'll add some troubleshooting info to the project-- as I mentioned, I didn't have any trouble discovering the device, a week ago or today.

Danny Lu (author)Danny Lu2017-07-22

I'm also using the second generation Echo Dot.

JohnZ1 (author)2017-07-18

Is there a way to do this without Adafruit's overpriced components?

bekathwia (author)JohnZ12017-07-18

Sure, use any ESP8266 microcontroller and relay you like! Pin configurations will vary. I like the easy plug and play nature of the Feather boards, and Adafruit's reliable board quality and customer support.

adillbeck (author)JohnZ12017-07-18

Yes. I'm currently working on a project that uses an ESP8266-01 from China ($2) that will do the same thing for a pool pump. The Adafruit board looks nice, and makes it so you don't really have to do any soldering, but at $16 it's still just an ESP8266. If you want to just plug it together, upload the sketch, and have a working project then this solution is pretty good.

Helder4u (author)2017-07-18

nice :)

About This Instructable




Bio: Becky Stern is a content creator at Autodesk/Instructables. She has authored hundreds of tutorials about everything from wearable electronics to knitting. Before joining Instructables ... More »
More by bekathwia:Tips for Moving in New York CityBecky's Top Projects 2017Making Studio Fall 2017
Add instructable to: