How to build your own Alexa voice activated IoT smart lamp for less than $35

Spending $200 on a smart lamp is not very smart when you can build one yourself with a simple and cost effective DIY project

Darian Johnson
A Cloud Guru
4 min readMay 11, 2017

--

A major manufacturer recently announced a smart lamp that will setup you back about $200. While GE’s lamp is cool, neither my budget (nor my wife) supports a purchase of that size — so I set out to design and build a “smarter lamp” for the more budget conscious consumers.

In order to compete with GE, the design of my smart lamp needed to include voice activation by Alexa. Since my wife wanted the ability to control the lamp using a standard switch, the design also needed to be practical and functional.

To meet my needs, the smart lamp had account for state — regardless of whether a voice or a physical switch was used for power.

The Smart Lamp Prototype

The smart lamp is designed to be activated by both voice and switch

To build the solution, $35 was spent to purchase the required components.

For a full description of the process for building the smart lamp and the code to control the device, check out my project on Hackster.io.

Step 1 — Designing the Physical Switch Control

For the initial prototype of a physical switch control, I used a push button. The controlling code, written in Python, simply waits to see if the button fires. When fired, the relay pin is set to High or Low depending on its current state.

Step 2 — Designing the Alexa Voice Control

The Alexa solution required two components; an Alexa skill, and a Python script that would take a command from the Alexa Skill and change the state of the relay pin.

Amazon has a specific API created for Smart Home skills which do not require the user to say the skill name to invoke. There is a great five- part tutorial on their blog with very clear instructions — I created my first draft of the skill within 30 minutes of starting.

Once my base skill was completed, I updated the code for use with my lamp prototype. The Smart Home Skill must provide Alexa with a list of smart devices — typically this device code resides with a device’s manufacturer. Since I was building my own, I hard-coded the device information:

AWS IoT Setup
The following AWS IoT developers guide explains the process for creating a AWS IoT “thing” to receive and route the messages. The key part of the process is creating the certificates which you’ll need to download and install on your LinkIt development board.

The Smart Home Skill also provides the ability to control the device, so I used AWS IoT to send MQTT messages to the device. I then created a script on the LinkIt development board that waited for an MQTT message, and set the relay pin start to High or Low based on the message.

Enabling the Alexa Skill
Before I could use skill, I had to enable it using my Alexa app and perform device discovery. Once that was complete, I was able to control my prototype via button and voice.

Prototype of the smart lamp being activated by both voice and switch controls

Building the Final Solution

Once I confirmed the code was in working condition, I moved ahead to build a more robust solution.

Wire the Switch and Run the Wires
I decided to go with a pole style floor lamp which allowed me to snake the switch wires from the top of the lamp to the base. I had to drill two small holes in the back of the lamp to install the button, and then use heat wrap to cover the wires.

Solder the IoT Device to a Protoboard
Full disclosure — I haven’t soldered anything since my senior year in college and I barely passed by circuits 101 class. While my final solution was never going to be pretty…. it works. I’d recommend reviewing the intro to soldering course by Alexa Glow on Hasckster.io.

Connect the Relay and Assemble the Device
I cut the power cord to the lamp, soldered the ends, connected them to the relay, and then connected the relay to the LinkIt Duo. Once connected, I placed the LinkIt and relay inside the plastic project box.

Finishing Touches
The final steps of the process involved the creation of two services on the LinkIt board designed to automatically start the button and MQTT Python programs on reboot.

While the finished product might look like like a “dumb” lamp, I’d like to consider it a “smarter lamp” — built for total price of $35.

The finished product is a Smart Lamp controlled by voice and switch for about $35

Darian Johnson is a technology consultant with deep experience implementing complex software architectures and leading large-scale software delivery programs. He currently works for Accenture as a member of their Amazon Web Services practice.

Darian has always enjoyed researching new technologies, so he eagerly used the tools and templates provided by the Alexa team to learn about skill development. His first skill combined his passion for fitness with his interest in machine learning. His Mystic Mirror skill won second place in Alexa’s Internet of Voice challenge on Hackster.io.

--

--

Darian Johnson
A Cloud Guru

I’m a Technology Architect. A Husband. A Dad. A Maker. A Music Lover. A Fitness Enthusiast. A Christian. Opinions/posts my own and do not represent my employer.