This article will serve as a general purpose getting started guide for ControlEverything relay controllers with a Particle Photon module installed.
In this guide we will cover basic setup and configuration to get your controller and Photon module out of the box and working. This guide does not replace documentation provided by Particle which I highly recommend you check out here.
To start get your ControlEverything relay controller out of the packaging and on your bench/desk. Make sure you do not sit the controller on any conductive surfaces including the anti-static bag which the board ships in. Next install the Particle Photon module into the relay controller. There will be a very obvious socket where the Photon module installs. Make sure the USB connection of the Photon module faces the same direction as the I2C expansion port on the board. If the board you are installing the module in is an Electron board or IOT mother board just make sure the Photon is installed at the very end of the socket nearest the edge of the board with all pins of the Photon module installed in pins in the socket, there should be no pins hanging out of the socket.
Once the module is installed supply power to the board using a regulated 12VDC power supply source. This power supply may be connected to the 2.1mm barrel connector on the board(center pin positive) or to the two power supply screw terminals. Once power is applied you should see a power LED on the relay board and the LED on the Photon module should begin blinking a deep blue color. At this point you have your hardware setup and are ready for the next step.
Install the Particle App on your Smart Phone or Tablet
On your phone’s app store search for Particle. You are looking for the Particle app by Spark Labs, Inc. Install the app on your phone or tablet. For setup purposes you will need to make sure your phone or tablet has Internet connection through either a cellular connection or WiFi. You will also need to be within close range of the Photon relay controller. The Photon relay controller will also need to be powered up and within range of the WiFi network you want to associate it with.
The app is quite intuitive and will walk you through the process of setting up the controller. It will also allow you to create a Particle account if you do not already have one. Follow the instructions in the app to associate your Photon module with the WiFi network and with your Particle account.
Flashing relay control firmware to Photon module.
At this point the stock Photon module is running what they call the Tinker app, at least that is the case at the time this article was written. We however cannot control the on board relays with this firmware running on the Photon module so we need to flash the appropriate firmware to the controller.
Open your favorite web browser on your computer and go to https://build.particle.io When prompted sign with your Particle account credentials. This site is referred to as the Build IDE Through this site we can flash firmware to the controller and even modify it if we so wish. Take a moment to get familiar with the interface here. The icon buttons on the left will allow you to navigate to different utilities on the Build IDE.
First we need to make sure the Photon module installed in the relay controller is online and ready to be flashed. Click the devices icon on the left(looks like a target). Here you should see your Photon module listed. If you have more than one module make sure it is selected(indicated by a star). Also make sure there is a breathing Cyan colored indicator next to the module listed there which indicates that it is online and is ready to be flashed.
Next we need to load up the correct firmware to flash to the module. We have already written the firmware needed to flash to the controller. Click on the Libraries icon on the left side of the screen(looks like a ribbon). Under community libraries we will enter a search to pull up the correct library. Search for NCDNumberOfRelaysOnBoardRelay Replace NumberOfRelaysOnBoard in this text with the actual number of relays on your board. So if you have 1 relay on your board you would search NCD1Relay Once you find the library there click to select it. You will see some code come up in the window to the right, there may be several tabs. Under examples on the left click on CloudControl.cpp, then press the Use This Example button on the left. This will load the correct firmware to Build.
The last thing left to do is to flash the firmware. Just click the Flash button on the left(Looks like a lightning bolt). You will see text at the bottom of the screen indicating what is going on and you can watch the LED on the Photon module. If it flashes Magenta then you know the Firmware is being flashed and everything is good. At this point initial setup of the controller is complete so we can actually do something with it.
Initial use and testing
There are several ways to go about testing your relay controller. For now however lets go over how all of this works.
The firmware you just flashed to the controller has a function called controlRelay. We pass arguments to this function indicating what we want the relay controller to do. If you have 1 relay on your controller then valid arguments to pass to the function are(ON OFF Momentary and Toggle). If there is more than 1 relay on the controller then the functions are (#ON #OFF #Momentary #Toggle replacing the # with the relay number on the board to direct that command to). In addition to these functions on multi relay boards there is also turnOnAllRelays, turnOffAllRelays, setAllRelayStatus, setBankStatus, etc. We will not get too much into the specifics of all these commands in this guide. However you can read through the CloudControl.cpp code to get a better understanding of what can be done with these function calls.
So now we know the controller has a function available and we know what arguments are to be passed to those functions. Now the question is how do we pass these arguments to the functions. The answer is there are several ways to do this. What really needs to happen is we need to tell the Particle Cloud Server that we want to call a function on a specific device on our account and we want to pass X as the argument(X being the arguments we just covered previously. Now you can create your own custom application to do this, you can use mobicle.io, you can use the Particle App on your phone(supports calling functions on the iOS app right now but not sure about the Android app), you can use IFTTT, and multiple other methods. To keep things simple at the moment lets use Mobicle. In your web browser head over to http://mobicle.io When prompted sign in with your Particle account. You will see a list of your devices now, click on the Photon module installed in the relay board. You will now see a screen where it exposes all functions that controller has available. Click on controlRelay and a box will pop up where you can enter an argument. Lets just turn on the first relay. If you only have 1 relay on the board then just type ON, if you have more than 1 relay on your controller then enter 1ON, then click send or ok. The first relay on the board should turn on, you can now pass OFF or 1OFF to turn the relay back off.
Your controller is now setup and ready for use. Use it just as it is with off the shelf apps, customize the firmware in the board, or even develop your own control app.