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
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.
*** ANOTHER SAFETY RELATED TOPIC - PLEASE READ ***
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 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.
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.
DO A QUICK TEST WITHOUT THE PHP SCRIPT HASSLE ...
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">