Honestly, I just got my new Particle Photon 2 in the mail and wanted to build something! I was also decorating my house for Christmas and needed an outdoor timer for my lights.
There are lots of manual timers and set-and-forget timers for Christmas lights, and there are wifi connected timers for indoor use. But I couldn't find any outdoor/weatherproof timers I could control from my phone.
So this seemed like the perfect excuse, I mean weekend project!
Materials- Particle Photon 2 - Particle's latest board that includes Dual-band Wi-Fi
- Mini 120 VAC to 5 VDC power supply
- Single Channel Relay board that controls 10A 250 VAC load with a 5 VDC control circuit
- Weatherproof electrical box, connectors, and cover
- 120 VAC Duplex Electrical Outlet
- PCB board, terminals, cables...
1. Solder a screw terminal to the power supply for 120v lines.
2. Solder the Photon 2 directly to the PCB board. Normally, I would have used headers, but the outlet box is a tight squeeze and I needed all the room I could spare.
3. Add pins for power (VUSB), ground (GND), and D2 for output to the relay. I used the VUSB pin for VCC per the Photon 2 Data Sheet:
4. Upload the firmware (see below) and test the Particle Photon and relay board before going any further.
5. Mount the Particle Photon 2 into the outlet box using double-sided tape, and connect the power supply and relay board with jumpers.
6. Carefully arrange the relay board and power supply into the outlet box using double-sided tape.
7. Wire in the outlet and attach it to the box.
8. Attach the outdoor outlet cover plate.
9. Deploy it for real-time testing.
I wanted to be able to turn the plugs on and off with my phone manually, and also set a daily timer for unattended cycling. I thought it would be nice to get a text whenever the lights turned on (not off because I'll be sleeping).
I decided to use IFTTT (If This Then That) for these functions.
Particle provides general instructions here: https://docs.particle.io/integrations/community-integrations/ifttt/
Manual ControlI used Button widgets so I could turn the lights on and off manually from my iPhone. IFTTT lets you create a Button Applet that calls a Particle function via a Webhook.
1. Click "Create a new Applet"
2. Click the Add button on the "If This" panel and search for the Button widget.
3. Choose the "Button press" event.
4. Now click the Add button on the "Then That" panel and search for Webhooks.
5. Choose the "Make a web request" event.
6. Fill in the following parameters:
- URL: https://api.particle.io/v1/devices/your_device_id/LIGHTS_ON
- Method: POST
- Content Type: application/json
- Additional Headers: Authorization: Bearer your_access_token
- Body: leave empty
NOTE: Your URL will contain your Particle device id and your Particle function name (if you used something other than LIGHTS_ON).
NOTE: Follow this link to get your Particle Access Token https://docs.particle.io/reference/cloud-apis/access-tokens/
7. Click Continue, enter an Event Name and click Finish. Your Event Names can be anything you want and do not have to match your event names in Particle Cloud. I used "Lights On".
8. Then, create another Applet for "Lights Off." Everything will be the same except for the event name and Webhook URL. I used "LIGHTS_OFF"
9. Using the IFTTT iPhone or Android app, you can enable Button Widgets on your phone to turn your lights on and off.
I want my lights to turn on at 5:00 PM and off at midnight. So, I created two more applets almost identical to the manual ones above called "Auto Lights On" and "Auto Lights Off." The only difference in these Applets is I chose the Date & Time Widget instead of the Button Widget. Everything else is the same including all the Webhook parameters.
I also wanted to get a text message when my lights turn automatically, so I know things are working even when I'm not home. Or maybe I just thought it would be cool to try this feature out. So I added another "Then" item to my "Auto Lights On" Applet.
1. By clicking the "+" button below the "Then" panel, you can add another activity.
2. Search for sms
Several options come up, but I chose the first one, SMS. It allows you to receive up to 100 texts per month for free. I only need one per day.
3. Choose "Send me an SMS". The service will send a text message to the phone number setup in your IFTTT profile.
4. Enter the text you want in your message and click "Create action."
TestingConclusionThe project was fun to build and a success! My Christmas lights turn on and off per the schedule and I can override from my phone when desired.
I realize the Photon 2 is overkill for this little project, but it was a good way for me to jump in and build something with it. I bought two more Photon 2's and plan to build something more worthy of this powerful little gem very soon!
So, stay tuned...
Comments