Alexa Smart Lamp With ESP8266

by bekathwia in Circuits > Wireless

48917 Views, 197 Favorites, 0 Comments

Alexa Smart Lamp With ESP8266

Smart Lamp with ESP8266 & Amazon Echo // Becky Stern
amazon-alexa-esp8266-lamp-becky-stern-00.jpg
amazon-alexa-esp8266-lamp-becky-stern-01.jpg

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:

For my particular wooden lamp base:

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.

Connect Relay

amazon-alexa-esp8266-lamp-becky-stern-03.jpg
amazon-alexa-esp8266-lamp-becky-stern-04.jpg
amazon-alexa-esp8266-lamp-becky-stern-05.jpg
amazon-alexa-esp8266-lamp-becky-stern-12.jpg

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.

Program Microcontroller & Test

amazon-alexa-esp8266-lamp-becky-stern-02.jpg
amazon-alexa-esp8266-lamp-becky-stern-06.jpg
amazon-alexa-esp8266-lamp-becky-stern-13.jpg

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.

Chisel Wood Base to Fit Components

amazon-alexa-esp8266-lamp-becky-stern-11.jpg
amazon-alexa-esp8266-lamp-becky-stern-07.jpg
amazon-alexa-esp8266-lamp-becky-stern-08.jpg
amazon-alexa-esp8266-lamp-becky-stern-09.jpg

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.

Use It!

amazon-alexa-esp8266-lamp-becky-stern-10.jpg

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.