Electric Imp to Control 8 Electrical Lights Using Internet




Introduction: Electric Imp to Control 8 Electrical Lights Using Internet

This project uses the new (and super cool) Electric Imp.  You can remote control 120VAC electrical devices over WiFi, via the internet Imp Cloud.  The Imp sends a serial string of bits to a "Serial to Parallel" digital output chip (made by Texas Instruments).

Basically, the 'gist' of the project:  You send the Imp a value (0-255 decimal or FF Hex) and it sends that stream of bits out of the UART serial port (pins 1 and 2).  The TI chip can only receive bits, so Imp pin 2 (RX) is not used.  The TI chip converts that serial input into 8 digital outputs.  Electronically, it can turn ON or OFF any of the Solid State Relays.

The TI chip is addressable, 0-7 using 3 bits.  That means you could technically have up to 8 of them in a line to drive 64 digital outputs.  The scope of this Instructable does not include extending outputs beyond one chip.  Also, the TI chip only receives serial bits and does not send any data back.  For bi-directional UART, you would need to use a different method.

I selected this TI chip because it doesn't need a clock.  It synchronizes automatically based on the timing of the first start bit.  This makes the circuit super simple and easy for anyone to construct.  No oscilloscope or logic analyzers needed.

This Instructable does not describe how to commission an Imp.  You'll need to view the Electric Imp website (www.electricimp.com) to learn how to register, login, commission, and create an account for your imp.

If this is your first encounter with the Imp ... please see this Instructable first:

The main parts:
Everything except the solid state relays can be built for under $100USD.

- Plastic box that can withstand outdoor weather. 
Use plastic because of the imp inside ... WiFi reception.
I used an old cheap plastic toolbox. Waterproof, w/carry handle.

- Electric Imp
Sparkfun Cat No. WRL-11395  (approx $30USD)

- April Electric Imp breakout board
Sparkfun Cat No. BOB-11400  (approx $13USD)

- TI (Texas Instruments) Serial to Parallel chip: 
Mouser Electronics Cat No. 595-SN74LV8153N (approx $2USD)

- Blank project board for soldering parts onto
Mouser Electronics Cat No.  782-T030081 (approx $5.50USD)

- 7805 5VDC Voltage Regulator
Mouser Electronics Cat No. 595-UA7805CKCT (less than $1USD)

- Solid State Relays (SSR)
3-32VDC input ... 120-240VAC output
These are expensive, but you can find used ones on Ebay

- Misc LED, resistors and capacitors, solder, hookup wire

Step 1: Demonstration Video

The video above shows what it does.   I have made a webpage that uses the JQuery Mobile framework (see step 6).  In this video I'm using my Kindle as the browser, but it could have been a smartphone.

Here is the project hooked to my Christmas lights outside my house. It's hard to focus in the dark, but you can get the idea of how it is working.

Step 2: The Schematic

This project has 120VAC, exposed, inside the box.  Do not open and work on this with power applied!  You can do all of the Imp board testing (low voltage) on your bench, before you assemble the solid state relays.

Very easy to wire and solder using the Project Board (designed for Arduino, but great for all projects).

I used a 6VDC wall-wart for my power supply.  Plugged that into a cord-end inside the box.   This allows me to test/troubleshoot all of the low-voltage components without applying 120VAC to the solid state relays.

The board is just laying on the inside of the plastic red box with the Imp pointed up for best WiFi reception.  The reception from the router inside my house to the Imp outside is about 100ft.  My house also has steel siding.

Step 3: The Completed Circuit Board

This is what my final board looks like.  It only uses Imp pins 1 and 9.  That leaves extra pins you can use for other things.  That TI chip is addressable (3 bits), so you could expand this to more digital outputs.  The scope of that is not discussed on this instructable.

Those extra Imp pins (5,7,8,9) could be used for inputs coming from some external switches back to the imp.  You cannot use pin 2 because that is reserved for UART12 (serial port, pins 1 and 2).  I don't use it here because the TI chip cannot send back any data.

Step 4: Inside Showing Solid State Relays Mounted to Box.


Solid state relays are mounted to side of box.  I use these for light strings and low current draw devices.  If used for high amperage purposes, those relays would need to be mounted on a heat-sink of some kind .... not plastic.

I'm using lamp extension cords not rated for more than 5 strings of typical incandescent lights (or 200 Watts total).  If you plan on switching higher current loads, consult with an experienced electrician for proper instruction.  Also realize that all of these circuits go into one power cord and one household outlet.  Use care not to overload an outlet, and never bypass safety devices such as fuses and circuit breakers. 

Also notice that the extension cords do not have grounding.  Again, use some common sense and wisdom in determining what types of things you will be switching with this project.  With the proper construction and proper relays, this could be used to switch high-amperage devices.

Step 5: The 'agent' and 'device' Files for the Electric Imp IDE

This Instructable does not describe how to commission an Imp.  You'll need to view the Electric Imp website (www.electricimp.com) to learn how to register, login, commission, and create an account for your imp.

This text file shows the listing for the imp code ... Code for the "Agent", and code for the "Device".

Step 6: Send Switch Presses to Imp Using Web Page.

To see a working example of the web page user control panel (shown above) goto:

1) You can view the demo on your smartphone and see how the slide switches work.
2) You can view the HTML source to see the JQuery and scripts (using your browser, view HTML source).
3) The actual PHP script that POST's value to the imp is shown in the image above.

With my Imp code, I use a website that utilizes JQuery and/or JQuery Mobile to send a momentary switch press to the imp.  Press ON,  Press OFF.  You can use any type of web page you wish, and your javascripting or HTML5 is whatever you want it to be.  I'm using PHP server-side scripting to POST the value(s) to the Imp.  You may prefer Perl, or some other server-side method.

The purpose of the PHP script for POST is to hide the imp agent URL from the user.  If you code the POST using JQuery, the user will be able to see the URL in the HTML source.  With PHP (server-side), that URL is kept secret.

The Imp code (text file in step 3) has comments within that describe what I'm doing.

Basically, the 'gist' of the project:  You send the Imp a value (0-255 decimal or 00-FF Hex) and it sends that stream of bits out of the UART serial port (pins 1 and 2).  The TI chip can only receive bits, so Imp pin 2 (RX) is not used.

From the button or switch change on the webpage to the actual light turning on or off takes about 1 second, depending on how fast the internet is for you.  That speed includes your connection speed (DSL, broadband, etc).  1 second seems fast, but in this industry, "about 1 second" is not instant, and it's not predictable, so keep that in mind if timing is critical.

I will be using this project over the Christmas season to let people stopping in front of my house log-in and control my lights.


To test it out with a 'minimalist' HTML script, copy this test script and upload to your website.  Put in your own Agent ID.  Enter values such as,  01,02,04,08,10,20,40,80  ... those are the 8 bits for the respective relays.

"test.html"  ... a super simple HTML script to test your completed circuit ....

<form action="https://agent.electricimp.com/nH58i4tGp5ur/" method="post">
Value: <input type="text" name="data">
<input type="submit" name="submit" value="Submit">

Be the First to Share


    • Build a Tool Contest

      Build a Tool Contest
    • Sculpt & Carve Challenge

      Sculpt & Carve Challenge
    • First Time Author Contest

      First Time Author Contest



    8 years ago on Introduction

    Hi, nice instructable!
    Fyi, there is a cool software for iOS and Android where you can build a custom UI which let you customize buttons/ switches/ sliders etc. for http APIs. It's called NetIO: http://netio.davideickhoff.de
    I also use this software to control wireless outlets and a ElectricImp Moodlamp.


    Reply 8 years ago on Introduction

    There is also a free app that is made just for the Imp:

    I'm really into online apps and server-side scripting. PHP and Perl.
    But it's nice to get a list of more options. The more, the better.


    8 years ago on Introduction

    You could in theory connect the IT chip to the Hill320 (Computerchristmas.com) and have 320 outputs for each eight bits of output from the ITchip that is 8x320=2560 outputs! Then you need a plugin for Vixen 2.0.


    Reply 8 years ago on Introduction

    The limitations to the TI chip is speed. 24Kbps is the limit. So with the imp UART12, I have the baud rate set at the standard 19200. I will only be using 8 different displays in my front yard ... and even with that, I have to do a lot of work. Extension cords, wiring strings, etc.

    As of yet, there is no 'project page' on the actual Imp website. That's why I am using Instructables. I'm hoping that anyone viewing the various Imp projects here will spark other ideas. Thanks for suggesting other uses. That's what make it so fun.


    Awesome! Update this come december, I would love to see it in action.


    Reply 8 years ago on Introduction

    I will try to get a demo video in place before the end of Oct.