2 Channel Relay interfacing with ESP 01 & NodeMCU | ESP 8266 | Control two high voltage devices.

In this tutorial, we will explore two channel relay. If you missed 1-channel relay interfacing read this tutorial. This is an extension and will introduce ESP 01 and ESP 8266 together. 

You can think of 2 channel relay as two 1-channel relays placed side by side. Relay needs 2 input triggers to operate each relay. 


Hardware Requirements

1. NodeMCU
2. ESP 01
3. Jumper wires
4. 2 Channel Relay (Active LOW trigger)
5. Multi output voltage power module



We will use the same code for both ESP 01 and ESP 8266. We will use GPIO pins 0 and 2. GPIO0 is D3  and GPIO2 is D4 on NodeMCU.
void setup() {
  pinMode(0, OUTPUT);
  pinMode(2, OUTPUT);
  digitalWrite(0, HIGH);
  digitalWrite(2, HIGH);
}

void loop() {
  digitalWrite(0,LOW);
  digitalWrite(2,HIGH);
  delay(3000);
  digitalWrite(0,HIGH);
  digitalWrite(2, LOW);
  delay(3000);
}


Above code will activate one relay for 3 seconds and then turns it off and activates the other for 3 seconds in a loop and works on NodeMCU and ESP 01. Now lets connect 2 channel relay to ESP 01 and ESP 8266.

NodeMCU
2 Channel Relay
3v
Vcc
GND
GND
D3
IN1
D4
IN2
 

    Nodemcu and 2 channel relay






ESP 01 3v -> Power module 3V
Relay Vcc -> Power module 3v 
Relay  GND -> Power module GND
ESP 01 GND -> Power module GND
ESP IO0 -> Relay IN1
ESP IO2 -> Relay IN2


ESP 01 and 2 channel relay




In the next tutorial we will explore 4 channel relay with NodeMCU.

Note

If you want to isolate power for relay and micro controller. You can use RY-Vcc and GND to power relay. In the above experiment i have shorted Vcc and RY-Vcc to use power from NodeMCU or power module.

Comments

Popular posts from this blog

Microphone Sound Sensor explained | HW-484 | Interfacing with ESP 8266

Using ESP 01 in Access Point (AP) mode to control ESP relay switch | ESP wifi tutorial | Part - 1

[Experiment] DIY Robotic 2 wheel drive car using L298N motor driver and NodeMCU | ESP 8266