Introduction: Smart Home Controller With Sensorflare and Spark Core of Particle: Control Your Power Devices With Sensorflare

Hi everyone! This instructable shows you how you can control your smart devices using Sensorflare and Particle core. The possibilities are many...You can use Particle core - a little Wi-Fi development board in order to connect your hardware (e.g sensors, actuators) to the Internet. Then, using the Sensorflare platform you can control and observe your devices adding the missing intelligence to your daily.

Here you can find an example that control remotely from Sensorflare 4 different electrical appliance at a time. At the end of this example, you will have the enough knowledge to include your own functionalities on your core and controlled it with Sensorflare.

Step 1: List of Elements:

Step 2: Hardware Connection

  • With the 4 Relay shield you can control 4 lines of 250Vac until 10A each one. Four 3-port screw block terminal are available on the board to introduce 3 250Vac lines for each relay (one 250Vac line input that can be connected with 2 outputs). Each relay position is controlled through a control input.
  • For example, you can connect and switch on/off remotely your desk lamp!
  • Encloses the device in a ready box or design your own one to print using a 3D printer.

Step 3: Paricle Core: Claim of Core, WiFi and Particle's Cloud Connection

  • You have to create an account on Particle in order to reclaim your core.The easiest way to add a device is via the iOS or Android app. Follow the steps that are indicated on Particle to add successfully the core to your account - easy future connection to your specific WiFi and Particles’ cloud connection.

Step 4: Particle's Web IDE: API Access Token

  • Go to the Particle's Web IDE and log in with the account that you have created before through your telephone application.

  • Now you are connected to the Web IDE of Particle. Your API key on Particle cloud is necessary for include your core on Sensorflare platform. Follow the instruction to access this information on the Particle's Web IDE.

Step 5: Upload the Code to Connect Your Particle Core Project in Sensorflare Platform

  • To include our Particle Core project on Sensorflare platform the “sensorflare.h” library will be used. A manual of how to use the library can be found on GitHub.

  • Go to "library" on Particle's WEB IDE and find the Sensorflare library on "Community Libraries".

  • Select the file "sensorflare-publish.ino" and click "use this example".

  • Flash the program on your core.

Step 6: Description of the Code

Variable declaration:

First of all it is included the library in the way that has been described before. As a result the next line is include in the code.

#include "sensorflare/sensorflare.h"

For every digital pin that we want to use as Digital Output Pin and we want to control remotely through Sensorflare platform is being declared a “DigitalOut” object. For this specific example are declared 4 objects and named outputPin1, outputPin2, outputPin3 and outputPin4 and associated with the pin D0, D1, D2 and D3 respectively.

SensorFlare::DigitalOut outputPin1(D0);
SensorFlare::DigitalOut outputPin3(D2);
SensorFlare::DigitalOut outputPin4(D3);


The setup function is only running one and is generally used to initialize variables, pin modes and functions. It is necessary to call the method “begin()” of every object that has been defined before. This method makes the corresponding initialize and begin the remote control of the pins through Sensorflare.

void setup() {
// Call the begin() functions for every object of the classes "DigitalOut" and 
//"PWMout" to be wired up correct and available.

Step 7: Setup Sensorflare to Communicate With You Particle's Core

  • First you need to connect to Sensorflare and visit the Connected Accounts page to enable communication between Sensorflare and your Particle core.
  • Click the "Add new account" button and select Particle option.

Step 8: Include Your API Access Token

  • Introduce your API access token that you have found on the Step 4

Step 9: Choose the Specific Core Output Functionalities

  • All your Particle devices that has been uploaded to Particle cloud will be listed here. Select the specific one that you want to be remote control with Sensorflare.

  • Select the Digital pins that you want switch on/off remotely. The Digital pins D0, D1,D2 and D3 will be controlled remotely on this example.

  • Select the output pins in which you have connected an element that will be remotely controlled by a PWM signal. Any PWM pin will be controlled remotely on this example.

Step 10: Control Your Switches Using Sensorflare

  • Switch on/off until 4 power devices over Sensorflare! The specific actuators that have been connected on each relay will be Power remotely by click ON on the specific button.
  • The image corresponds with a System state in which the electrical appliances that are connected on the first and second Relays are Power On and the ones that are connected to Relay 3 and Relay 4 are Power Off.