Introduction: Arduino ESP8266 Control Relay Module With Blynk & IR Remote | Real-Time Feedback

About: This Page is for different Electrical and Electronics Projects, DIY, Circuits, etc. All the projects are explained with circuit diagram, Breadboard schematic, working principle, Arduino sketches so it becomes …

In this IoT project, I have made a WiFi and IR remote control relay module using an ESP8266 (ESP01) and Arduino with Real-time Feedback. I have also explained in detail how the ESP8266 and Arduino can communicate to show the current state of relays in the Blynk App.

This smart relay has the following features:
1. Control Home appliances from Blynk App through the internet.

2. Control Home appliances from TV Remote (Infrared).

3. Monitor the Relay-Time feedback in the Blynk App.

4. If no internet available then control the relay module with IR remote.

Supplies

1. TSOP 1738 IR Receiver (1 no)

2. 100uF Capacitor (1 no)

3. Arduino Nano

4. ESP01 module (ESP8266)

5. Optocoupler PC817 (4 no)

6. Transistor BC547 (4 no)

7. LEDs (1.5) (7 no)

8. Diode 1N4007 (4 no)

9. SPDT Relay 5v (4 no)

10. 220-ohm Resistors (8 no)

11. 1k Resistor (6 no)

12. 2k Resistor (1 no)

13. 4.7k Resistor (1 no)

14. 10k Resistor (1 no)

15. Male & Female connectors (2mm Pitch Female BERG Strip)

16. AMS1117 3.3V voltage regulator (1no)

17. Push buttons (2 no)

18. Zero PCB

Step 1: Circuit Diagram

This is the complete circuit diagram for this home automation project. I have explained the circuit in the tutorial video.

In the circuit, the RX and TX pins of Arduino Nano is connected with the ESP01 (ESP8266), So that the Arduino and ESP01 can communicate with each other and we can monitor the real-time status in the Blynk.

A 1738 IR detector is connected with the D8 pin of Arduino to control the relay module from any IR remote (Ex TV Remote).

There is also a push-button to select the MODE.

In MODE-1 we can control the relay module from both Blynk App and IR remote.

And in MODE-2 we can control the relay module from only IR Remote.

In this circuit, we can use both 5V or 12V relay but we have to change the resistors accordingly.

Step 2: Configure the Blynk App

Install the Blynk App from Google play store or App store.

Create a new project (Board: ESP8266 and Connection Type: WiFi)

Then add all the 4 buttons with virtual pins V1, V2, V3, V4.

I have explained all the details in the tutorial video.

Step 3: Control Relay Module From Blynk Through Internet

As you can see in the picture, we can easily control the relay from the Blynk App. The ESP01 is connected with the WiFi.

1. When I tap on any button the Blynk server sends the signal to ESP01.

2. Then ESP01 (ESP8266) sends the signal to Arduino Nano through the serial terminal.

3. After receiving the signal from ESP01, the Arduino TURN ON or OFF the respective relay and send the feedback to ESP01 through the serial terminal.

4. When feedback received from Arduino, the ESP01 sends the current status to the Blynk server.

5. Thus we can always monitor the current status in the Blynk App.

So if the internet is available, we can control the relay module from anywhere in the world.

Step 4: Control Relay Module From IR Remote

We can also control the relay module from any IR remote. For that, we have to map the Hex codes of the buttons with the respective relay, in the code. (We will discuss later).

1. When I press any button in the IR Remote, it will emit some Infrared signal.

2. The 1738 IR detector will receive the IR signal and send it to Arduino as Hex Code.

3. Arduino first compares the HEX code with the predefined value.

4. If the Hex code matched, the Arduino will TURN ON or OFF the respective relay.

5. Then if the internet is available, the Arduino will send the current status of the relay to ESP01.

6. ESP01 will send the signal to Blynk Server so that we can monitor the current status on the mobile.

Thus we can control the home appliances with IR remote.

Step 5: No Internet Mode

If there is no internet, then we can control the relay module from the IR remote.

When the internet comes back, ESP01 will connect with the WiFi automatically.

Then the Arduino will move to the internet mode and send the current status to the Blynk server.

After that, we can control the relay module both from mobile and IR remote.

Step 6: Program the ESP8266 (ESP01)

1. Enter the WiFi credentials, (WiFi Name & Password).

2. Then enter the AUTH TOKEN sent by the Blynk.

3. Connect the USB to TTL interface board (FTDI232) with ESP01.

4. Download the Arduino sketch (attached) for the ESP8266 board.

5. Select the Generic ESP8266 board and proper PORT. Then upload the code.

Please check out the following article on how to program ESP01 using Arduino and FTDI232.

https://iotcircuithub.com/esp8266-programming-ardu...

Step 7: Program the Arduino Nano

First, you have to collect the HEX codes from the TV remote button. Please refer the above video, I have explained step by step how to get the HEX code from any IR Remote buttons.

1. Download the Arduino sketch (attached) for the 2.Arduino board.

2. Replace the HEX codes in the Arduino sketch as shown in the video.

3. Connect the Arduino Nano with LAPTOP.

4. Select the Arduino NANO board and proper PORT. Then upload the code.

In the tutorial video, I have explained in detail how the ESP01 and Arduino communicate with each other.

With this logic, you can control any number of relays with a single ESP01 board.

Step 8: Designing the PCB

As I am going to use the circuit daily, so after testing all the features of the smart relay module on the breadboard, I have designed the PCB. You can download the PCB Gerber file of this home automation project from the following link:

https://drive.google.com/uc?export=download&id=1P2TSvgNDOtFRQ46fEMdo0sjDmfgSuL6n

Step 9: Order the PCB

After downloading the Garber file you can easily order the PCB

1. Visit https://jlcpcb.com and Sign in / Sign up

2. Click on the QUOTE NOW button.

3 Click on the "Add your Gerber file" button. Then browse and select the Gerber file you have downloaded.

Step 10: Uploading the Gerber File and Set the Parameters

4. Set the required parameter like quantity, PCB color, etc

5. After selecting all the Parameters for PCB click on SAVE TO CART button.

Step 11: Select Shipping Address and Payment Mode

6. Type the Shipping Address.

7. Select the Shipping Method suitable for you.

8. Submit the order and proceed for the payment.

You can also track your order from the JLCPCB.com My PCBs took 2 days to get manufactured and arrived within a week using the FedEx delivery option.

PCBs were well packed and the quality was really good at this affordable price.

Step 12: Solder All the Components

After that solder all the components as per the circuit diagram.

Then Connect the Arduino Nano and ESP01 with the PCB as shown.

Step 13: Connect the Home Appliances

Connect the 4 home appliances as per the circuit diagram. Please take proper safety precautions while working with high voltage.

Connect 5Volt DC supply to PCB as shown in the circuit. (I have used my old mobile charger)

Step 14: Finally

Turn on the 110V/230V supply and 5V DC supply.

Now you can control your home appliances in a smart way.

I hope you have liked this home automation project. I have shared all the required information for this project.

I will really appreciate it if you share your valuable feedback, Also if you have any query please write in the comment section.

Please follow TechStudyCell. Thank you & Happy Learning.