WI-Fi Controlled 4CH Relay Module for Home Automation

by Shan Peiris in Circuits > Wireless

4033 Views, 37 Favorites, 0 Comments

WI-Fi Controlled 4CH Relay Module for Home Automation

20200326_074638.jpg
20200326_074652.jpg
cover.jpg

I have been using a many WI-FI Based on off Switches Previously. But those are not suit with my Requirement. That’s why I wanted to build my own, which can replace normal Wall Switch sockets without any Modifications. The ESP8266 Chip is Wifi enabled IoT platform for everyone. What I have done is created a four Channel relay board for it and the coolest part is that board also has a 100-240V-AC to 5V-DC Power supply on board so you will be able to connect it directly to AC mains while creating a Wifi enabled switch board. It also has a header where you will be able to connect Tx-RX based devices (Something like a Nextion Dispalys).

A brief specification of the board is as mentioned below

  • It comes with a header where you can plug TX-RX based devices & Connect TTL-USB Programmer for programme the ESP12E WI-FI chip.
  • Four Relays to connect four AC/DC loads and both NC/NO connectors of the relay are provided
  • Can be pre-programmed with Home automation integration.
  • 100-240VAC or 5VDC select able input.
  • Power : 3W
  • LED for Testing which is connected to a GPIO and also as indicator when the relay go on /off
  • Dimensions of the board are 76 x 76 mm

Supplies

1x Hi-Link HLK-PM01 (230V-5 VDC 3W)

1x ESP12E/ESP12F

4x PC817 Opt coupler

4x 5V Relay

4x D400 Transistor or any NPN Switching Transistors

1x AMS1117 - 3.3v

4x LED Yellow (SMD 1206)

1x LED RED (SMD 1206)

8x 10KΩ Resistor (SMD 1206)

4x 330Ω Resistor (SMD 1206)

1x 120Ω Resistor (SMD 1206)

2x Micro Switch

3x Screw Terminal 5mm pitch 2pin

Selecting the Hardware

ESP-12E-Module.jpg

In addition, you should have a suitable soldering and measure set, which consists of a soldering iron, solder, (hot air soldering device), Multimeter and so on.

Tools:

  • Soldering Iron or better to use Hot air Gun
  • De soldering Pump
  • Wire Cutter and Stripper
  • Screw Driver
  • USB TTL Programmer (To upload program you have to use TTL converter or you can use Arduino UNO by removing Atmega328 as same as TTL convertor.)

Design and Testing the Circuit

2.1.png
47606370-f5a07400-da12-11e8-9611-f15481c9a02f.png
justbuttons_2bx4mYZrX7.jpg
20200326_091046.jpg
3.1.JPG

The first step after understanding how ESP12E work. I started by gathering all of the components I needed: 10K and 330 ohm resistors, NPN Transistors, Breadboard, Jumper wires. I followed along with a printout of the ESP12E. The process was tedious but I was able to get a working circuit diagram for the ESP Chip Stand Alone mode. I would tie the inputs high or low and used a multimeter to test the outputs. Now I was ready to translate the breadboard and schematic into to a PCB.

To design the PCB I used Autodesk EAGLE exclusively. There are other great programs like EasyEDA and Fritzing available to help design a PCB.

Turn the Project Into an Actual PCB (Assembly and Soldering)

20200326_091102.jpg
20200326_091143.jpg
3.2.JPG
3.5.png
64469932-61d22500-d158-11e9-8ac6-2db9bd4dbf49.jpg

You can etch the PCB yourself at home. But I ordered the PCB with a professional manufacturer, which offer affordable prices and high quality manufacturing. Therefore, there is no reason to do so at home. Plus you will have a professional looking PCB created by you! The assembly and soldering of this project is quite simple.

First you solder all components (as in the pictures) on the board, but make sure that the SMD components are soldered in the correct orientation. You can recognize the correct direction by the white dots on the board. When you have finished soldering, do not under any circumstances connect the circuit board with current, as this could damage the components!
Started by placing and soldering the LEDs, then the resistors and the pin headers. I use a bit of solder flux paste to make the work easier. Solder paste makes the PCB dirty. To clean it, I use a cotton swab with acetone.

Hardware Connection

20200326_090817.jpg
usb-to-ttl-converter-bk004-7.jpg

To upload program you have to use TTL converter (showing below) or you can use Arduino UNO by removing Atmega328 as same as TTL convertor.

Make connection between WiFi Relay 4CH and TTL converter.

PCB ->TTL Converter Pin

VCC -> 3v3

GND->GND

DTR ->GND

RXD->TXDTXD->RXD

Required Files

Upload the Program

5.1.png
5.2.png
5.3.png

You have to install ESP boards to Arduino IDE before use ESP8266. So, please follow these steps.

  • Run Arduino IDE Go to File > Preference to Open preference window.
  • Paste https://arduino.esp8266.com/stable/package_esp8266com_index.json URL into the board manager URLs.

Device in Action

20200326_075211.jpg
20200326_074733.jpg
20200326_091446.jpg
6.1.JPG
6.3.JPG
6.2.JPG

Final Wiring & Trial of PCB

After upload the program, remove all TTL connection and power up by 100-240 V AC. Now your own Smart Switch is ready to use.

Hope this can be helpful for someone and learned as much as I did. You can use all the files shared here and have a go yourself.

Any comments are welcome, if you if you enjoyed it share your feedback or any improvements that may be done. Thanks everyone and see you soon.

Happy making!