NCD1Relay + Particle


#1

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!


#2

So the most straightforward way is to publish an event or a variable to particle. Something like Particle.publish(‘relayStatus’, relayController.readRelayStatus());


#3

Hi there @oraclerouter ,
if you want to monitor your relay from your Android phone you may want to check this project out:


Cheers,
Gustavo.


#4

@jacob
No sure if this is asking for too much but would you walk me through this? how can i adjust the CloudControl code to publish the event?


#5
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.


#6

@Trey
Perfect! Really appreciate it!