Introduction: Interface Relay Module With NodeMCU

Hello Makers!

I hope you know what is an Relay Module. Have you wondered how the relay module works?

In this Instructable we will see how an Relay works and how to Interface Relay with NodeMCU.

Step 1: Components Needed

List of parts required for this instructable :

Hardware Required

  • NodeMCU
  • Relay Module
  • Breadboard
  • LED (optional)
  • Micro USB cable
  • Connecting Wires

Software Required

  • Arduino IDE (with ESP8266 Library installed)

Step 2: Description

  • Relay is a electrically operated switch. Generally used relay modules are 5v / 12v.
  • The relay uses an electromagnet to mechanically switch electric appliances.
  • A relay can be operated by a relatively small electric current that can turn ON or OFF a much larger electric current.
  • Using relays is safe as there is no any physical contact between NodeMCU and AC devices.

Step 3: How It Works

Relay is basically act a switch between electrical load and NodeMCU.

Relay have two configuration NO (Normally Open) & NC (Normally Close).

Relay have coil which is energized by 5v, when coil energized switching action takes place, based on NO-NC configuration.

If relay is NO configuration then when coil is energized switching action takes place from NO-NC then load will be connected.

Step 4: Circuit Connections

Connections are very simple, initially you need to power-up the Relay Module.

Relay Connections:

Connect NodeMCU Ground (GND) pin to -ve pin of Relay.

Connect NodeMCU Supply (3v3) pin to +ve pin of Relay.

Connect NodeMCU Digital pin (D4) to Input pin of Relay.

Step 5: Code Is Right Here

int relayInput = 2; // the input to the relay pin
void setup() {

	pinMode(relayInput, OUTPUT); // initialize pin as OUTPUT

}
void loop() {

	digitalWrite(relayInput, HIGH); // turn relay on

	delay(1000);

	digitalWrite(relayInput, LOW); // turn relay off

	delay(1000);

}

Download the "Relay_NodeMCU.ino" file and open it up in the Arduino IDE.

Then Create a new sketch and paste the code below in the Arduino IDE and hit Upload. You can tinker with it if you like based on the application, or just use it as it is.

Step 6: OUTPUT

That's all makers!

It takes less time to create this instructable, and its fun too.

Thank you for taking your time to read my instructable.

I hope you enjoy it as I enjoy making it and documenting it to show and tell to other fellow makers here.

CIAO!! with another interesting Instructables!

Comments

About This Instructable

932views

39favorites

License:

Bio: Work until you no longer have to introduce yourself.
More by TheCircuit:Interface Moisture Sensor With NodeMCUInterface L298N Using NodeMCUInterface Relay Module With NodeMCU
Add instructable to: