Hi all,
I am new to this whole IoT world, but I purchased a 2-Channel High-Power Relay Controller Shield + 6 GPIO with IoT Interface plus a Photon so I can remotely turn on and off my compressor and dust collector in my wood shop. I have it all working with custom code I wrote for the particle. I control it from IFTT and my Echo calling the custom functions I wrote. This is works great. BUT, I really want to add a Key Fob or remote, because turning OFF the dust collector is difficult, because I am usually far from the Echo, and it gets loud in the shop.
I am coming up a bit clueless on how to setup a remote. What do I need to purchase, and what are the basic steps to get started ?
Also, I want to put the Relay in an enclosure, but would love to add 2 LEDs to the outside that come in with the relays. I assume I would add code to control two of the GPIO pins, but I can’t seem to get that to work. They all seem to always be +5V.
// This #include statement was automatically added by the Particle IDE.
#include <NCD2Relay.h>
NCD2Relay relayController;int led1 = D0;
int led2 = D7;
int onValue=1;
int offValue=0;void setup() {
Serial.begin(115200);
relayController.setAddress(0,0,0);Particle.publish("Controller","Started",60,PUBLIC); Particle.variable("compressorOn", &offValue, INT); Particle.variable("dustOn", &offValue, INT); Particle.function("turnOnComp",turnOnComp); Particle.function("turnOffComp",turnOffComp); Particle.function("turnOnDust",turnOnDust); Particle.function("turnOffDust",turnOffDust); Particle.function("turnOffAll",turnOffAll); turnOffComp("off"); turnOffDust("off"); pinMode(D0, OUTPUT); pinMode(D5, OUTPUT);
}
void loop() {
}int turnOnComp(String command) {
relayController.turnOnRelay(1);
Particle.publish(“Compressor”,“ON”,60,PUBLIC);
Particle.variable(“compressorOn”, &onValue);
digitalWrite(D0, HIGH);return 1;
}
int turnOffComp(String command) {
relayController.turnOffRelay(1);
Particle.publish(“Compressor”,“OFF”,0,PUBLIC);
Particle.variable(“compressorOn”, &offValue);
digitalWrite(D0, LOW);
return 0;
}
int turnOnDust(String command) {
Particle.publish(“Dust Collector”,“ON”,60,PUBLIC);
relayController.turnOnRelay(2);
digitalWrite(D5, HIGH);
Particle.variable(“dustOn”, &onValue);
return 1;
}int turnOffDust(String command) {
Particle.publish(“Dust Collector”,“OFF”,60,PUBLIC);
relayController.turnOffRelay(2);
Particle.variable(“dustOn”, &offValue);
digitalWrite(D5, LOW);
return 0;
}int turnOffAll(String command) {
turnOffComp(“off”);
turnOffDust(“off”);
return 0;
}
}
Thanks,
Mark