Introduction: Remote Relay Using Particle Photon

Particle (formally Spark) have released their new line of affordable WiFi enabled microcontroller platforms: The Photon. This is the successor to the Spark Core and measures in at a tiny 37mm x 21mm footprint. I have created a few garden watering devices using Raspberry Pi, Arduino, and Spark Core. This time I will create just a remote relay and enable it using IFTTT.

You must claim your Photon before using it. The process is so simple that Particle has create an iPhone and Android application for it.

Step 1: Required Items

The parts list is pretty straightforward:

I've sourced my relay modules from Banggood.com but you'll be able to find similar parts from eBay and many other sources. I've chosen to use an 8 relay module and will use all eight digital pins on the Photon.

Step 2: Prepare the Firmware

In the setup for the firmware, I define a Particle Cloud function named "parse". The intent is that I can send messages to my Photon coded with either "ENABLE" or "DISABLE" followed by a pin number that relates to the digital pins on the Photon. So sending "ENABLE1" will set D1 to HIGH and sending "DISABLE1" will set D1 to LOW.

The "parse" function simply extracts the pin number from the command message and issues the appropriate digitalWrite operation.

Step 3: Connecting With IFTTT

It couldn't be easier to control your remote relay than using IFTTT. There is a channel in IFTTT that will allow you to connect directly to your Photon and exposes the "parse" function. You can create a recipe in a few minutes that will enable or disable a relay port.

It is possible to create an IFTTT recipe to enable/disable a relay pin based on time of day, day of week or any other date/time combination. You can also react to Github, Twitter or even Life360 events. There are many channels that you can use to control your Photon.

It is even possible to use your Photon as a source of information such as creating Particle Cloud variables for sensors such as soil, humidity, or gas.

I have created a recipe that IF "time of day is 6am" THEN "use the parse function and send ENABLE7 on my Photon". The cool thing about D7 is that the Photon also has an LED on it so you can quickly ensure that it is working properly.

Comments

author
Gtmize made it!(author)2016-12-15

I've been unable to find a Particle / AmazonAlexa pairing ... maybe you're aware of one so in your case .. Alexa would announce status of garage door

author
Umbra55 made it!(author)2015-07-21

Thanks for
the instructable. Could you tell us which relay you bought from Banggood.com

author
vipercmd made it!(author)2015-07-21

Thanks! The input voltage is the important consideration when purchasing a relay module.  Since the Pi/Arduino/Photon can only deliver 3.3-5V for output, you'll want a relay that can switch at that low voltage.

For my lawn/garden project I need to take into account that I have poor water pressure so I can only run one sprinkler at a time. With 6 sprinkler heads I used this 8 relay module.

The office plant watering solution used a 4 relay module.  I should note that I used a ULN2803 to invert the HIGH/LOW logic from the Spark to the relay so that it would not turn on the water pump while the Spark was booting up.

author
tower23 made it!(author)2016-10-05

I thought the photon had a maximum ouput of 3.3V. How was it able to power the relay that is 5V? (disclaimer: I am just learning about this and apologies if it is a stupid question)

author
BartY2 made it!(author)2016-11-11

Best to use a transistor or MOSFET from the output pin and use that to drive the relay. These output pins can't provide much current.

author
anelexus made it!(author)2016-01-15

This is great !!

I use it with IFTTT and the Amazon Echo (Alexa).

Do you think It's possible to add the same function from A0 to A5 or this is limited from D0 to D7?

Thanks a lot :)

author
Umbra55 made it!(author)2015-08-08

Could you add a wiring scheme using the 8 relay
module? Next to the power supply, relay module and the photon, does it require any
additional resistors, flyback diode etc?

author
vipercmd made it!(author)2015-08-10

It really isn't more complicated than hooking wires directly from the Photon to the relay module as the module contains everything that will protect your Photon. The 4-relay module I have sitting on my desk even has optocouplers between the input pins (which are connected to the Photon) and the relay components. This means that the Photon is even more protected since there is no direct electrical signal between the relay components and the input pins.

The relay module will also have male headers so you just need a female-female wire and connect the two together. The input power and ground on the relay module can be provided by the Photon.

I have included a Frizing image of connecting the Photon to the relay module. The image has a Spark Core but the pin layout to the Photon is identical.

Photon to Relay Module.png

About This Instructable

14,424views

30favorites

License:

More by vipercmd:15 Minute Caramel Apple Dessert Functional Art Using Recycled MaterialsCutting Glass Bottles
Add instructable to: