Arduino with relay control fan

i'm stuck with it a whole week. i can't find anything wrong with it, but when i turn on 5V, my fan just turn on and never off. help me, i had homework and need to finish soon. Thanks


my code is Blink in Examples

You are attaching your fan to "NC" (NORMALLY CLOSED = a short circuit from 5v to fan).

You should attach your fan to "NO" (NORMALLY OPEN = an open circuit from 5v to fan until NODEMCU commands relay to CLOSE)


.

yep, in real life, my relay is NO COM NC, so actually i connect my fan to NO. i had tried to change it and connect to NC and result was the fan is off and never on

YEP. You need to make the MCU control the relay. Post your code, here, too.... but maybe post the "in real life" version so no one has to guess what you have written, like your drawing.

No, it is not... blink uses LED_BUILTIN or a DO pin. You have three pins in your "not in real life" drawing.

1 Like

i'm so sorry, here is my code

void setup() {

  pinMode(15, OUTPUT);
  pinMode(16, OUTPUT);
  pinMode(17, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(15, HIGH);  
  delay(1000);                     
  digitalWrite(15, LOW);   
  delay(1000);    
  digitalWrite(16, HIGH); 
  delay(1000);                    
  digitalWrite(16, LOW);   
  delay(1000);
  digitalWrite(17, HIGH);  
  delay(1000);                     
  digitalWrite(17, LOW);  
  delay(1000);
 
}

and i also change pinouts to 2,4,5 but it still didn't work

Which devlopment board you are using?

Node MCU 32s

check the logic level of the arduino does match to control signal of the relays.

sorry, my EL is bad, i dont understand what u

1 Like

how surprised! that web written by Spanish or Portuguese and i completely not understand anything, and I can't even find my mother tongue

@paulpaulson is asking to see your "nodemcu datasheet"... this datasheet will show the amount of power the nodemcu can source (create) to send control signals from nodemcu to other devices.

it is possible that your nodemcu data pins will not supply the power enough for a relay (or three relays).

If you use deepl... you can not find some popular languages like Tagalog (use Filipino), so use "Deepl Detect Language" or use "DDG.GG translate" or translate.google.com

I found Vietnamese translation: translate vietnamese at DuckDuckGo

i think that, too. it's just 3.3V but with the same voltage, Node mcu esp8266 can control even more relay. So, i still dont get it

Start with making the nodemcu and ONE relay work. (no fans, no dc power supply)

1 Like

i tried, but same result, just ON, never OFF, or while connecting to NC, just OFF, never ON

Remove the power supply, relay and nodemcu from the breadboard and connect them directly together. This will eliminate problems in the breadboard.

i tried, i was stuck with it a whole week

Be sure your connections are complete.

Time for a pic..
Let's see what you got..

~q

1 Like

yep. i even swap all the pins in all the cases and even buy a new relay then a new node mcu 32s. nothing changes