I like Internet of Things. I like automation in general. One issue I have with most outlet control systems is that you only have the choice of a per outlet solution, like zwave through smart things or a DIY solution using something like a particle photon and a relay bank. The problem with the particle photon and a relay bank is that everything must be within a close proximity to the relay bank, as they must be individually wired to the relay bank and a power source. This can make for a mess, to say the least.
So this is my solution. I am making a way to control multiple outlets using wireless with a preexisting product that inexpensively makes 3 outlets RF wireless. We will hack the controller and make it controllable using a particle photon with a relay.
Here are the materials I used to make this
- Clear top waterproof project box -- Amazon - $14.21 (did not need to be this hefty, this is just what i had on hand
- small double sided prototype board
- various wires
- IFTTT Account
- Micro USB Cable
- USB Power Supply
The Particle and the Relay
So wiring this up is really easy. The relay has a 5v pin in 1 through 8 and a ground pin. Easy right? Ground and voltage on the relay go to Vcc and GND on the particle photon. The signal pins need to be wired to the digital pins on the photon. It really does not matter which digital pin goes to which signal pin, but, I would recommend putting 1 to 1 and 2 to 2, and so on and so forth. I did not do this and had to create a "map" of sorts to make sure I would not get any more confused.
The Wireless Outlet Remote
As for the remote control, you need to solder wires to the back of the circuit board for the remote. The easiest way to make sure that you are soldering to the correct leads is to short 2 of the pins on the back of each button until the intended action happens. For example, set it up and then short two of the pins on the "on" button for one of the outlets. When the outlet turns on, then those are the two leads that you need to solder to. These leads will go into the normally open and common ports for a relay. Each switch (1 on, 1 off, 2 on, 2 off, 3 on, 3 off) will need its own relay. If you were able to find a remote with a push once to turn on and push again to turn off type of remote, then you would only need a single relay per outlet.
I'm not going to go through the entire setup of a particle photon, as I have gone into detail as to how to set it up and program is in another tutorial located here.
Needless to say, after the photon is set up you will have to go to the website build.particle.io to program the Photon. I have included the code in a .ino file above. The code is really simple, it uses a "parse" command, meaning that it is waiting for a command. The command specified is "ENABLE" followed by the digital pin that you want to trigger. The delay in the code makes it so that the relay does not stay on. It emulates a key press, or in this case a remote button press. So, for example if relay 1 is hooked to Digital pin 1 on the Photon, then the command ENABLE 1 will pull the pin high for 200 milliseconds and then put it back low, effectively resetting it.
IFTTT is a website that allows you to create "recipes" that automate things. We will make a recipe to make it so when we tell Alexa "trigger turn on xxxxx" it will tell particle to trigger the function we created. Sign up / in to www.ifttt.com and create a new applet with Alexa as the "if" and particle as the "that". Make sure when you are creating the applet and it asks for the function for the Particle, you type "ENABLE" and then the pin #, so for D7 type "ENABLE7" and for D6 type "ENABLE6". Remember, you will have to create two separate recipes for each digital pin.
All I did is drill a hole in the case and cram it in there, and pray that it still worked, lol. Not that bad, but almost. This is always the hardest part for me. I always get the project running perfect, and by the time I'm done, I will need a 55 gallon drum to use as my project box. Make sure to take the extra time to keep your wires short enough so that you can fit it into your intended project box.
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!