Introduction: Particle Photon World Wide Light Switch

Ever wish you could turn the lights at your office on from your house with the flick of a switch? That's what this Instructable is all about. We will use a simple switch to remotely turn a relay on over the Internet, and even better, its super easy!

Replace the simple switch with anything that generates a contact closure like a motion detector, float switch, PIR, etc.

We will be turning a light bulb on and off in this example but since the relay on the receiver is just a simple relay capable of switching 10 amps at 120VAC or 24VDC you can use it to turn almost anything on or off. It can also be used to generate a dry contact closure for things like a PLC, Thermostat, etc.

Step 1: What You Need

Qty 2 Particle Relay Controllers

Qty 2 12VDC Power supplies to power Relay controllers(Optional with Relay Controllers).

Qty 2 Particle Photon/Spark Core modules. These are included with Relay Controllers.

Qty 1 Simple switch.

Qty 1 Light Bulb and AC power source to light it.

Step 2: Associate Particle Modules With a Particle Account

In order to gain access to the internet and communicate to each other the Particle modules need to be connected to your WiFi network and will need to be associated with your account.

To Start install the Particle Photon Modules into the Relay controllers. You may want to put an identifier sticker on the boards at this point so you can tell them apart later.

Use your 12VDC power supply to power up one of the controllers. Now proceed through the steps to associate them with your Particle account as explained here: that you do not have to connect a USB cable since the module is powered by the 12VDC power supply. Be sure to name the device something that makes since like switch or remote.

Now power down that controller and proceed through the same steps to associate your second controller with your account giving it a different descriptive name.

Once the controllers are setup on your account power them both up. Make sure the LEDs on both modules are breathing cyan, this means they are connected to the cloud and ready to go. Time to flash some code!

Step 3: Flash Some Code already has an example library that will work perfectly for the board that has the switch input. All we need to do is write a very simple application into the board that will provide the relay output to switch the light.

We will do all of this through's fantastic WEB based IDE for writing and flashing the code into the module. Go to to start.

Input Board Code

From the devices menu on the left(looks like a target) select the board which is your switch input.

Now from the Libraries menu on the left(looks like a ribbon) type in NCD1RELAY under Community Libraries. Once that comes up in the code view window click on the CloudControl.cpp tab to select it. Then click the USE THIS EXAMPLE button. Now you should see a tab in the code view window that says CloudControl.ino If so just click the flash button on the left(looks like a lightning bolt). The LED on your switch input board will flash magenta and then will re associate with your WiFi network. That board is flashed and ready to go.

Relay Output Board Code

The Relay output board needs a little code to get going, but dont worry, it's really easy.

From the devices menu on the left select the board which is your relay output board(connects to the light bulb).

From the Libraries menu search for NCD1RELAY again. In the Code View Window select the Loop_Test.cpp tab and click the USE THIS EXAMPLE button. Once the Editor is done forking you should a see loop-test.ino tab in your Code View Window. We will make some modifications to this file. Just paste this code into the the Code View Window:

/* Includes ------------------------------------------------------------------*/
#include "NCD1Relay/NCD1Relay.h"


NCD1Relay relayController;

/* This function is called once at start up ----------------------------------*/

void setup() {



Particle.subscribe("Input_1", myHandler, MY_DEVICES);


/* This function loops forever --------------------------------------------*/ void loop() {


void myHandler(const char *event, const char *data) {

String command(data);








Step 4: Wire It Up

The boards are flashed with our brilliant code. Now all that's left is to wire them up to our switch and to the light.

Input Board Wiring

The input board is pretty simple. Just connect your switch to the GP2 terminal and one of the GND terminals.

Relay Board Wiring

For the relay board you will connect your AC source hot leg to the COM terminal of the relay and the Light bulb AC hot leg to the NO terminal of the relay. Then just connect the neutral leg of your AC source directly to the neutral leg of the light bulb.

Step 5: Test It Out

Close the input on the transmitter board with your button or switch and watch how magically the light bulb at the other end turns on. How cool is that!?

Now just think of what this could be used for! The possibilities are endless!


tomatoskins (author)2015-11-10

Such a cool project! Just like you said, the possibilities of this project are endless!



Thinking about this even further it could be possible to use multiple input boards to trigger the same receiver. Or you could use a multi input board to trigger multiple receivers. It's almost crazy how far you could go with this! Really cool stuff.