Sensorflare library to include your Spark Core device from Particle on Sensorflare platform.
This class describes the elements that will be controlled with digital output. Every object is then associated with the specific pin that will be remote control.
- SensorFlare::DigitalOut ObjectName (DigitalPin): It is the constructor of the DigitalOut class. Instance an object of the DigitalOut class called ObjectName and assigned it the pin DigitalPin. DigitalPin must be referenced as are named on the Spark Core board (D0, D1, D2, D3, D4, D5, D6 or D7) in which is connected the specific actuator that want to be remote controlled.
- ObjectName.begin(): The “begin()” method must be called on the setup() function in order to start to control remotely the specific digital pin as output.
This class defines the output elements that will be controlled remotely by a PWM signal. A parameter from 0 to 255 chose the duty cycle of the signal output.
- SensorFlare::PWMOut ObjectName(PWMOutput): It is the constructor of the PWMOut class. Will be instanced and object of the PWMOut class called ObjectName for each PWM output that is used and assigned it the corresponding pin PWMPin . PWMPin must be one of the pins that provides this functionality on Spark Core board and namely with the typically name on the board (A0, A1, A4, A5, A6, A7, D0 or D1) in which is connected the specific PWM actuator that want to be remote controlled.
- ObjectName.begin():The begin method must be called on setup() function in order to start to control remotely the specific output pin with a PWM signal.
This class is used to publish variables on Sensorflare platform. The maximum number of this core variables that can be observe on Sensorflare is 10.
- SensorFlare::VarPublish ObjectName("VariableName"):It is the default constructor of the VarPublish class. Instance an object, called ObjectName, for each variable that will be published on Sensorflare platform with the name VariableName.The name is limited to 12 characters. The variable will be public on the cloud which means that another Spark Core user can access it.
- SensorFlare::VarPublish ObjectName("VariableName",”PRIVATE”):It is a second constructor of the VarPublish class. Instance and object called ObjectName for each variable that will be published on the Sensorflare platform with the name VariableName.The name is limited to 12 characters. The variable will be private upload on the cloud which means that only the user can access it.Two kinds of variables can be published: int or float.
- ObjectName.begin(Variable): The begin(Variable) method must be called on setup() function in order to start to observe remotely the specific Variable on Sensorflare with the name that has been chosen before "VariableName".Two kinds of variables can be published: int or float.
- ObjectName.Publish(Variable, period):The Publish method will publish the specific Variable every period time. Must be called on loop() function in order to publish every time the new Variable value.Only must be publish the variables later of call the corresponding begin(Variable) method.
Include the Sensorflare library
#include "sensorflare.h"Initialize objects from the library: One object of the class "PWMOut" is initialized for every PWM output that will be remote control
SensorFlare::PWMOut pwm(A0);Call the begin() method of the object on the setup() function to initialize the element.
void setup() {
pwm.begin();
}Include the Sensorflare library
#include "sensorflare.h"Initialize objects from the library: One object of the class "DigitalOut" is initialized for every digital output that will be remote control. DO, D1, D2 and D3 will be the remote control digital pins in this case.
SensorFlare::DigitalOut outputPin1(D0);
SensorFlare::DigitalOut outputPin2(D1);
SensorFlare::DigitalOut outputPin3(D2);
SensorFlare::DigitalOut outputPin4(D3);Call the begin() method on the setup() functions for every object of the class "DigitalOut" to be wired up correct and available the remote control fuctionality.
void setup() {
...
outputPin1.begin();
outputPin2.begin();
outputPin3.begin();
outputPin4.begin();
...
}Include the Sensorflare library.
#include "sensorflare.h"Initialize objects from the library: One object of the class "VarPublish" is initialized for every variable that will be published in order to access remotly from Sensorflare. Both methods initialized the variable that will be published as PUBLIC.
SensorFlare::VarPublish varTem("temperature");
SensorFlare::VarPublish varPir("pir","PUBLIC");For initialized the variable that will be published as PRIVATE.
SensorFlare::VarPublish varLight("light","PRIVATE");Declare the variables that we will want to publish.
float temperature;
int light;
int status;Call the begin(Variable) method on the setup() functions for every object of the class "VarPublish" to be select the specific Variable as remote observe from Sensorflare.
void setup() {
...
varTem.begin(temperature);
varLight.begin(light);
varPir.begin(status);
...
}The Publish(Variable,period) method will be called on loop() function for every object that represent each variable which want to be published by associated the respective Variable and a Period on seconds.
void loop() {
...
//Publish the variable at the called method time
varPir.Publish(status,0);
//Publish the variables every 15 seconds.
varTem.Publish(temperature,15);
varLight.Publish(light,15);
}