I’m very new to this and I’m for some answers. I have a 1 channel relay with the Photon. I loaded the CloudControl code on to it and I’m able to push functions to it.
Is there a way to remotely see what the current state of the relay is? I’m using http://mobicle.io/ to control it. Thanks for the help!
So the most straightforward way is to publish an event or a variable to particle. Something like Particle.publish(‘relayStatus’, relayController.readRelayStatus());
int triggerRelay(String command);
bool tripped[7];
int debugTrips[7];
int minTrips = 5;
int relayStatus; //New Line!!
/* This function is called once at start up ----------------------------------*/
void setup()
{
Particle.function("controlRelay", triggerRelay);
Particle.variable("relayStatus", relayStatus); //New Line!!
Serial.begin(115200);
relayController.setAddress(0,0,0);
}
/* This function loops forever --------------------------------------------*/
void loop()
{
int status = relayController.readAllInputs();
relayStatus = relayController.readRelayStatus(); //New Line!!
int a = 0;
There are 3 new lines that are commented, just add those and you should see a new variable show up in Mobicle, it will be 1 when the relay is on, and 0 otherwise.