Add an imageDelete this imageWith poor lighting in some rooms in the apartment, Christmas lights were added to supplement the main lighting. This means that when you want good lighting, you have to get up and plug in lights. Sometimes you're just too lazy get get off your couch and plug in the lights. Enter the Alexa controlled photons, a DIY way to integrate lighting into your home. Using an Amazon Echo Dot and some Particle Photons, you can make all the lights in your house turn on without even leaving the couch.
Wiring:
The breadboard that came with the photon was used for this project but the wires could also be soldered for a more permanent solution. To wire the relay, the photon's 3v3, GND, and digital output pins will be used. The relay has three places to wire into; constant power, ground, and signal. Our particular relay required the 3v3 pin to be used for constant power because the photons 5v output pin would lock the relay. So attach the 3v3 to the relay's constant power, the ground to ground, and the output pin to the relay's signal.
Now to the outlet's wiring. NOTE!!!! If you are not comfortable with mains wiring please have someone who is help you with this project. This can be dangerous and burn your house down, so be careful!!!! Cut the extension cord and trim the ends to length to fit in the relay's terminals. The neutral wire from the extension cord will go straight to the outlet. The hot wire will go to the common terminal on the relay and a second small piece of wire will pass from the relay's normally open terminal to the outlet's hot terminal. Be careful the hot and neutral wires will not interchange in this project. The hot wire must go through the relay.
Simply package up this wiring in any form you please. We used a standard double din wall outlet box as a quick solution.
Coding:
Next up is writing the code for the photons to communicate with Alexa and each other and configuring "If This Then That" (IFTTT) integrations. An IFTTT integration was used to publish "on" and "off" Particle.publish statements. These statements are then subscribed to by each photon. The "myhandler" function then tells the photon what to do when the "on" and "off" data is seen. One of the IFTTT statements is shown below.
This has inputs for the phrase that will trigger Alexa as well as what IFTTT should send in response to this phrase. Four of these IFTTT statements were used with two for each room corresponding to "on" and "off."
Now to ingrate the Blynk app. This consists of three parts. First include the Blynk library in your project. Then add in the Blynk.begin(blynkAuth); to the void setup and Blynk.run(); //Starts Blynk App Control in the void loop.
Please see of full guide on the setting up of the Blynk app as it has far more features than what can be noted in this short guide. Two buttons were then setup in the app, one for the kitchen and one for the living room. The kitchen button will connect directly to the pin which controls the relay in the kitchen. Now the button for the living room is slightly more complex. Since the relay for the living room is connected to the other photon we chose to connect these through the publish statement already sent by IFTTT. This avoided making a second Blynk app to connect to the photon in the living room. So the Blynk app was set to control a digital output pin that is then read by the code. When this is pin turned on with the Blynk app, the particle then reads the pin and publishes a statement based on the pins output.
Data Logging:
To graph the data a second set of ITFFF statements was setup. This time the IFTTT subscribes to publish events coming from the kitchen photon. These statements will then trigger the IFTTT to write the name of the published event, time, and output of the published event to a google sheet when can then be used to graph as shown. Both the data from the kitchen and living room were ran through the kitchen photon in order to create two way communication between the photons, a requirement for this project. However, the IFTTT statements could be setup to read the individual photon's data directly from that photon.
Comments