DigitalPin randomly goes high

Hey guys, i’m really new to this environment but really interested in this…

got a few Particle Photons to play with, one of them i have plans of using to use IFTTT and the Do button to open my gate.

I used a really straightforward code:

//The pin you want to control, in this case I'm blinking the on-board blue LED on digital pin 0
int led = D0;
//This function is called after the Photon has started 
void setup(){
    //We set the pin mode to output
    pinMode(led, OUTPUT);
    //We "Subscribe" to our IFTTT event called button so that we get events for it 
    Particle.subscribe("button", myHandler);
}
//The program loop, not sure if this has to be here for the program to run or not
void loop() {
}
//The function that handles the event from IFTTT
void myHandler(const char *event, const char *data){
    // We'll turn the LED on
    digitalWrite(led, HIGH);
    
    // We'll leave it on for 1 second...
    delay(1000);
    
    // Then we'll turn it off...
    digitalWrite(led, LOW);
}

3.3 and gnd both pinout to the relay and then D0 to signal on relay which then triggers the remote…

all of this works, however i’m having an issue where intermittently or should i say randomly D0 goes high and sends signal to relay… now of course this is all just in testing phase so it doesn’t open gate and i’ve gone as far as to completely disconnect the relay and change the code from D0 to D7 so that i can monitor the status of the digital pin by using the onboard led, yet still randomly it comes on…

any advise would be greatly appreciated guys…

much thanks.

1 Like

@kevinbritain, the onboard blue LED is actually on D7, not D0. Can you provide more details on the “relay” you are trying to drive?

1 Like

Correct, LED is on D7 and in code i have D0 being triggered however after i disconnected the relay i changed this code to D7 to monitor the status as it was randomly going to high (triggering the pin)

the relay was a standard keyes sr1y relay module that is connected to a gate remote, however as stated above i later disconnected the relay and with just the photon and power, the blue led on also D7 still randomly triggers… that being said, i just flashed the photon and re-did the code and recreated the do it button and it is randomly triggering the D7 alot less… but still weird…

I think you should use a less common event name, since any other device that publishes an event called button will trigger your handler.
I’m sure I could make your LED come on every few seconds by just publishing a “button” event from any of my devices or via CLI too.

Normally you would use a MY_DEVICES subscribe, to limit the possible sources, but I’m not sure how that’d work with the DO button.

Hey, that seems very logical… just changed event name… will test throughout day… thanks…

1 Like