Relay not working properly with nodemcu

wouldnt it work if just removed the 'D' from where you are defining the pins?

And I think you should use D5, D6 and D7 on the ESP8266.
I don't know what the Relay board arrangement is, but if D8 is "pulled-up" then the ESP will not BOOT. (Another potential Problem.)

Just in case --

const byte K1 = D5;
const byte K2 = D6;
const byte K3 = D7;


void setup() 
{
  pinMode(K1,OUTPUT);
  pinMode(K2,OUTPUT);
  pinMode(K3,OUTPUT);
  Serial.begin(9600);
  Serial.print ("led is ready");
}

void loop() 
{
  digitalWrite(K1, HIGH);
  delay(500);
  digitalWrite(K1, LOW);
  delay(500);
  digitalWrite(K2, HIGH);
  delay(500);
  digitalWrite(K2, LOW);
  delay(500); 
  digitalWrite(K3, HIGH);
  delay(500);
  digitalWrite(K3, LOW);
  delay(500);
}

Ok, try that

ahh yes i have experienced that problem...I did have to disconnect the esp from the relay in order for it to start

ok so with arduino it is working but with the esp again the same result...only leds blinking but not clicking sound or connection between the open terminals

actually on d5 i am using an led for a different feature of the project but i can and will move it to another pin

With 5V and GND applied to the relay board (and nothing else):
touch a Relay board input to GND - what is the result?
touch a Relay board input to 5V - what is the result?

so i tried that...
when i used an arduino then the relay and led was turning on when i touched the ground pin
But when i used an esp then the same result...only led turning on when the relay board input pin was touching ground

Yes, that proves the relay board inputs are pulled-up ("tied high").

I have 'exactly' the board that you do.
It works with the ESP/NodeMCU.

const byte mon = D4;
const byte K1 = D5;

void setup() {
  pinMode(mon, OUTPUT);
  pinMode(K1, OUTPUT);
}

void loop() {
  digitalWrite(mon, HIGH);
  digitalWrite(K1, HIGH);
  delay(500);
  digitalWrite(mon, LOW);
  digitalWrite(K1, LOW);
  delay(500);

}

I can put it on youtube (if necessary).

still not working...same thing led turning on but no clicking sound nor the open terminals of the relay are closing

it is the same nodemcu but i dont think you need to put it on yt

Another thing.
By running the Node/USB 5V to the relaybd "VCC", you end up having the 5V_pulled-up on the ESP output. I'm uneasy about that.
So that's not the case --

  • Remove the JD_VCC - VCC jumper block (widget)
  • Connect the Node/USB 5V to the JD_VCC terminal
  • Connect NodeMCU 3V to relaybd VCC

what do you mean by JD?

And im pretty sure nodemcu doesnt have a 5v terminal...i was powering relay through vin pin

"VIN pin", if the NodeMCU is connected to USB the VIN is USB is 5V (same same).

and JD?

Hold your horses, Sparky.

image

ohk thnks