logo
NodeMCU 8 Relay Module
NodeController

This little project with the NodeMCU and a 8 channel relay module
can be controlled from a Web Browser or from an Android App that I am developing
Called NodeController

You could send the command from a Web Browser address bar,
format: ip-address/COMMAND ,eg: 10.220.1.22/RELAY1ON
would turn Relay 1 ON.

format: ip-address/COMMAND ,eg: 10.220.1.22/RELAY1OFF
would turn Relay 1 OFF.

Or you could use the App that I have been developing
NodeController for Android you will find a link in the description

With this design the 8 channel relays don't fales trigger at boot or reset because the power
to the module runs though the second relay which dosn't activate until the NodeMCU
connects to the wifi

PARTS

1 x WeMos D1 USB NodeMcu Lua V3 CH340G ESP8266 Wireless Internet Development 5-9V
or
1 x NodeMCU Lua ESP8266 ESP-12 WeMos D1 Mini WIFI

1 x 8 channel relay module with optocoupler and LOW level trigger
1 x 1 or 2 channel relay module with optocoupler and Low level trigger

1 x 5v dc Power Supply

Some other components depending how you would like to connect the wires to the PCB, eg pin headers, terminals.











8 channel relay       

nodecontrollermain        nodecontrollersettings

nodecontrollerhelp       


Below I have added a link to download a Ziped file with the Arduino Sketch, Schematic, Readme
Download  Sketch and info

 NodeController on Google Play Store

       

NodeController NodeMCU schematic
click picture to enlarge

Below is the Sketch for This Project, you can modify it to suit your own designs.



/*

 MerrittSoft
 NodeController
 07/04/2020
 Language: C++/Arduino
 Thank you to those people that made the Libarays in this project posable.
*/

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>


ESP8266WebServer server;

const int output0 = D0;
const int output1 = D1;
const int output2 = D2;
const int output3 = D3;
const int output4 = D4;
const int output5 = D5;
const int output6 = D6;
const int output7 = D7;
const int output8 = D8;

char* ssid = "ssid_name";
char* password = "ssid_password";



void setup()
{
 pinMode(output0, OUTPUT);
 digitalWrite(output0, HIGH);
 pinMode(output1, OUTPUT);
 pinMode(output2, OUTPUT);
 pinMode(output3, OUTPUT);
 pinMode(output4, OUTPUT);
 pinMode(output5, OUTPUT);
 pinMode(output6, OUTPUT);
 pinMode(output7, OUTPUT);
 pinMode(output8, OUTPUT);

 digitalWrite(output1, HIGH);
 digitalWrite(output2, HIGH);
 digitalWrite(output3, HIGH);
 digitalWrite(output4, HIGH);
 digitalWrite(output5, HIGH);
 digitalWrite(output6, HIGH);
 digitalWrite(output7, HIGH);
 digitalWrite(output8, HIGH);




 WiFi.begin(ssid, password);
 WiFi.hostname("NodeController");
 WiFi.mode(WIFI_STA);
 Serial.begin(115200);
 while (WiFi.status() != WL_CONNECTED)
 {
   Serial.print(".");
   delay(500);
 }
 Serial.println("");
 Serial.print("IP Address: ");
 Serial.println(WiFi.localIP());
 Serial.println();

 server.on("/", []() {
   server.send(200, "text/plain", "NodeController");
 });

 // below are the commands that activate the Relays
 // eg. the /RELAY1ON is the command you add to the end of the ip address to turn Relay 1 ON eg. 10.220.1.20/RELAY1ON ,
 // This can be done in a Web Browser address bar on the same network

 server.on("/RELAY1ON", subroutine1on);

 server.on("/RELAY2ON", subroutine2on);

 server.on("/RELAY3ON", subroutine3on);

 server.on("/RELAY4ON", subroutine4on);

 server.on("/RELAY5ON", subroutine5on);

 server.on("/RELAY6ON", subroutine6on);

 server.on("/RELAY7ON", subroutine7on);

 server.on("/RELAY8ON", subroutine8on);

 server.on("/RELAY1OFF", subroutine1off);

 server.on("/RELAY2OFF", subroutine2off);

 server.on("/RELAY3OFF", subroutine3off);

 server.on("/RELAY4OFF", subroutine4off);

 server.on("/RELAY5OFF", subroutine5off);

 server.on("/RELAY6OFF", subroutine6off);

 server.on("/RELAY7OFF", subroutine7off);

 server.on("/RELAY8OFF", subroutine8off);


 server.begin();
}

void loop() {

 if (WiFi.status() != WL_CONNECTED)
 {
   ESP.reset();
 }
 digitalWrite(output0, LOW);
 server.handleClient();


}

void subroutine1on()
{
 Serial.print("Relay 1 ON ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output1, LOW);
 return;
}

void subroutine2on()
{
 Serial.print("Relay 2 ON ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output2, LOW);
 return;
}

void subroutine3on()
{
 Serial.print("Relay 3 ON ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output3, LOW);
 return;
}

void subroutine4on()
{
 Serial.print("Relay 4 ON ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output4, LOW);
 return;
}

void subroutine5on()
{
 Serial.print("Relay 5 ON ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output5, LOW);
 return;
}

void subroutine6on()
{
 Serial.print("Relay 6 ON ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output6, LOW);
 return;
}

void subroutine7on()
{
 Serial.print("Relay 7 ON ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output7, LOW);
 return;
}

void subroutine8on()
{
 Serial.print("Relay 8 ON ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output8, LOW);
 delay(3000);
 return;
}

void subroutine1off()
{
 Serial.print("Relay 1 OFF ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output1, HIGH);
 return;
}

void subroutine2off()
{
 Serial.print("Relay 2 OFF ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output2, HIGH);
 return;
}

void subroutine3off()
{
 Serial.print("Relay 3 OFF ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output3, HIGH);
 return;
}

void subroutine4off()
{
 Serial.print("Relay 4 OFF ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output4, HIGH);
 return;
}

void subroutine5off()
{
 Serial.print("Relay 5 OFF ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output5, HIGH);
 return;
}

void subroutine6off()
{
 Serial.print("Relay 6 OFF ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output6, HIGH);
 return;
}

void subroutine7off()
{
 Serial.print("Relay 7 OFF ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output7, HIGH);
 return;
}

void subroutine8off()
{
 Serial.print("Relay 8 OFF ");
 Serial.println();
 delay(1000);
 server.send(204, "");
 digitalWrite(output8, HIGH);
 return;
}