1

I'm using a Relay Channel and NodeMCU(8266-WIFI). When i trigger the connection, LED Turns ON in Node MCU But the Relay connection is not working. I'm not sure what is the issue, Please help to fix it..

My Pin connection as follows.

  1. NodeMCU (VIN) -> Relay (VCC)
  2. NodeMCU (G) -> Relay (G)
  3. NodeMCU (D1) -> Relay (IN4)

My code as follows,

#include <ArduinoJson.h>
#include <ESP8266WiFi.h>  
#include <FirebaseCloudMessaging.h>
#include <Firebase.h>
#include <FirebaseHttpClient.h>
#include <FirebaseArduino.h>
#include <FirebaseError.h>
#include <FirebaseObject.h>


// Set these to run example.  
#define FIREBASE_HOST "xxx-xxxx.firebaseio.com"  
#define FIREBASE_AUTH "xxxxxx"  
#define WIFI_SSID "xxxx"  
#define WIFI_PASSWORD "xxxxx"  
  
void setup() {  
  Serial.begin(9600);  
  
  // connect to wifi.  
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);  
  Serial.print("connecting");  
  while (WiFi.status() != WL_CONNECTED) {  
    Serial.print(".");  
    delay(500);  
  }  
  Serial.println();  
  Serial.print("connected: ");  
  Serial.println(WiFi.localIP());  

  pinMode(D1, OUTPUT); 
  pinMode(LED_BUILTIN, OUTPUT); 
  
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); 
  Firebase.set("LED_STATUS",0);  
}  
  
int n = 0;  
 
void loop() {  
  // Get value  
  n=Firebase.getInt("LED_STATUS");  
 
  if (n==1) {  
     digitalWrite(D1, LOW); 
     digitalWrite(LED_BUILTIN, LOW); 
     Serial.print("LED is ON ");   
     Serial.println(Firebase.getInt("LED_STATUS"));   
     delay(1000);  
  }  
 else{  
   //LED_BUILTIN
   digitalWrite(D1, HIGH); 
   digitalWrite(LED_BUILTIN, HIGH); 
   Serial.print("LED is OFF ");   
   Serial.println(Firebase.getInt("LED_STATUS")); 
   delay(1000); 
 }  
 
} 

Connection PICTURE

12
  • the red wire is not connected to anything
    – jsotola
    Aug 4, 2020 at 6:42
  • you mean the Main power Red wire right ?I removed the connection to take photo..
    – GK_
    Aug 4, 2020 at 7:08
  • What version of the NodeMCU is that?
    – Majenko
    Aug 4, 2020 at 9:55
  • On back of board it mentioned, "Node MCU V3" and in front top right corner , ver 0.1
    – GK_
    Aug 4, 2020 at 10:49
  • 1
    Does the relay work when you connect IN4 to Vcc ?
    – SBF
    Aug 4, 2020 at 15:14

1 Answer 1

1

I found that the 3V isn't enough to power the relay. https://www.instructables.com/Getting-Started-With-ESP8266LiLon-NodeMCU-V3Flashi/ shows the board supplies USB power (pin VU).

You can remove the jumper that connects signal voltage to relay power and connect the relay board to the USB power.

After that change I could turn the relays on and off, but I could not reliably power 4 relays, 2 relays as shown below seems fine.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.