Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By GreenBlood
#85256 I’ve been playing with the code to see if there is some reason why the gpio isn’t going low when it should be. So ignor the fact that they do the same thing, I’m just try to get a relay switching at the moment.

I have 4 relays, 3.3v Like these- https://tinyurl.com/sya845m
One each for the four buttons on a remote control that need operating, up, down, select and stop. I want to say to alexa ‘blinds up’, blinds down to fully open and close respectively. (I also want to say ‘light block’ to set the blinds to stop at certain positions when I get that far.)
I have the vcc of the relays going to the 3.3v pins on the lolin nodemcu board, same with the ground and the trigger pin going to the gpio pins on the board.
The relays all light up as if appropriately powered (the red led lights up), and if I set the initial status of the gpio as LOW rather than HIGH, they all trigger fine!
Most odd, no idea what’s going on.
Cheers
Steve
User avatar
By btidey
#85259 So the relay does operate if the GPIO is low as in setting it low at setup.

The code in the routine should pulse it low for 1 second. I assume that is to simulate a button press.

If you request Down are you seeing the serial message "BtnDown 2 called by Alexa". Note that strcmp is case sensistive so won't match unless the message is exactly right. You can use strcmpi

Have you tried testing by extending the duration to say 5 seconds to make it easier to check on the relay operation? Can you check the voltage at the GPIO pin with a meter during the active period?
User avatar
By GreenBlood
#85260
btidey wrote:So the relay does operate if the GPIO is low as in setting it low at setup.

Yes

The code in the routine should pulse it low for 1 second. I assume that is to simulate a button press.

Yes, but it’s not.

If you request Down are you seeing the serial message "BtnDown 2 called by Alexa". Note that strcmp is case sensistive so won't match unless the message is exactly right. You can use strcmpi

Yes, seeing the message as stated.

Have you tried testing by extending the duration to say 5 seconds to make it easier to check on the relay operation?

No, will try that, but-

Can you check the voltage at the GPIO pin with a meter during the active period?

Yes, it’s not showing the voltage drop low at the relay ‘in’ terminal. It’s really confusing as to why it’s doing this.



I think I’ll try uploading a simple sketch that just turns relays on and off, see if that works.
User avatar
By GreenBlood
#85261 All relays work perfectly with this sketch!

Code: Select allint relayPinD5 = 14;
 int relayPinD6 = 12;
 int relayPinD1 = 5;
 int relayPinD2 = 4;
 
void setup() {
 
    pinMode(relayPinD5, OUTPUT);
    digitalWrite(relayPinD5, HIGH);  //Set the pin to LOW (0V)
    pinMode(relayPinD6, OUTPUT);
    digitalWrite(relayPinD6, HIGH);  //Set the pin to LOW (0V)
    pinMode(relayPinD1, OUTPUT);
    digitalWrite(relayPinD1, HIGH);  //Set the pin to LOW (0V)
    pinMode(relayPinD2, OUTPUT);
    digitalWrite(relayPinD2, HIGH);  //Set the pin to LOW (0V)
}
 
void loop() {
 
   digitalWrite(relayPinD5, LOW); //Set the pin to HIGH (3.3V)
   delay(1000);                  //Delay 5 seconds
   digitalWrite(relayPinD5, HIGH);  //Set the pin to LOW (0V)
   delay(1000);                  //Delay 5 seconds
 
   digitalWrite(relayPinD6, LOW); //Set the pin to HIGH (3.3V)
   delay(1000);                  //Delay 5 seconds
   digitalWrite(relayPinD6, HIGH);  //Set the pin to LOW (0V)
   delay(1000);                  //Delay 5 seconds
 
   digitalWrite(relayPinD1, LOW); //Set the pin to HIGH (3.3V)
   delay(1000);                  //Delay 5 seconds
   digitalWrite(relayPinD1, HIGH);  //Set the pin to LOW (0V)
   delay(1000);                  //Delay 5 seconds
 
   digitalWrite(relayPinD2, LOW); //Set the pin to HIGH (3.3V)
   delay(1000);                  //Delay 5 seconds
   digitalWrite(relayPinD2, HIGH);  //Set the pin to LOW (0V)
   delay(1000);                  //Delay 5 seconds
 
}