Make a Cheapest DIY Sonoff 4CH
by bluino_electronics in Circuits > Arduino
17294 Views, 36 Favorites, 0 Comments
Make a Cheapest DIY Sonoff 4CH
![asset_switchiot4ch_instructable-03.jpg](/proxy/?url=https://content.instructables.com/FOH/PIU9/K14VANWY/FOHPIU9K14VANWY.jpg&filename=asset_switchiot4ch_instructable-03.jpg)
Sonoff is a smart switch device line for Smart Home developed by ITEAD. One of popular product of Sonoff is Sonoff 4CH. These are Wi-Fi enabled switches based on a great chip ESP826. This connected to WiFi so can be controled anywhere use App. Sonoff 4CH 4 gang light switch supports to connect and control 4 electrical appliances, which can be turned on/off separately by the buttons or Android App EweLink. Besides, with the multi gang switch, you can check real-time devices status for each device on App.
While the Sonoff infrastructure may work quite well for basic users, others may want to hack to make own with their hardware. The hardware to build DIY Sonoff 4CH smart switches its very low price: Wemos D1 mini board, Relay Module 4CH, Button and LED.
Next, to load the firmware to Wemos D1 mini board you don't need a computer or laptop, just need an Android smartphone with an awesome app that is SwitchIoT 4CH, with this app makes an IoT device is as easy as uploading firmware without the need for registers/login and server configurations. This tutorial will tell you how to make a DIY Sonoff 4Ch smart switch. Let's Get Started!
Hardware Reqiered
![IMG_20190925_151307.jpg](/proxy/?url=https://content.instructables.com/FE4/FO90/K14TQWE5/FE4FO90K14TQWE5.jpg&filename=IMG_20190925_151307.jpg)
Here are the components that you will need to make this project:
- (1) Relay Module 4 Channel
- (1) Wemos D1 Mini Board (ESP8266)
- (2) 1x8 Male Pin Header (Included with Wemos)
- (4) Tact switch 6x6x12mm
- (1) Double Layers Prototype PCB 3x7mm
- (8) Cable Jumper AWG 30
Note: For an alternatively if you don't want to bother making DIY from prototype PCB. You can manufacture it directly on PCBWAY.
Schematic
![art_wemos.jpg](/proxy/?url=https://content.instructables.com/FOQ/LZAP/K14VANXN/FOQLZAPK14VANXN.jpg&filename=art_wemos.jpg)
Soldering Button and Male Pin Header
![IMG_20190925_152254.jpg](/proxy/?url=https://content.instructables.com/FU8/UXH3/K14TQWSZ/FU8UXH3K14TQWSZ.jpg&filename=IMG_20190925_152254.jpg)
![IMG_20190929_234042.jpg](/proxy/?url=https://content.instructables.com/F1S/QVBC/K14VADHE/F1SQVBCK14VADHE.jpg&filename=IMG_20190929_234042.jpg)
Placed 4 button and 2 male pin header into hole of prototype PCB followed picture, then solder all legs of component on PCB.
Wiring and Soldering
![asset_switchiot4ch_instructable-04.jpg](/proxy/?url=https://content.instructables.com/FPF/UPVP/K14VATRP/FPFUPVPK14VATRP.jpg&filename=asset_switchiot4ch_instructable-04.jpg)
![ezgif.com-gif-maker.gif](/proxy/?url=https://content.instructables.com/FIN/E84O/K14TPE6T/FINE84OK14TPE6T.gif&filename=ezgif.com-gif-maker.gif)
To make the connecting wire follow step by step the line path as in the video with refer to the schematic in step 2.
Soldering LED
![IMG_20190925_180821.jpg](/proxy/?url=https://content.instructables.com/F1H/DR5Q/K14TQW7A/F1HDR5QK14TQW7A.jpg&filename=IMG_20190925_180821.jpg)
![IMG_20190925_180928.jpg](/proxy/?url=https://content.instructables.com/F5V/0B0N/K14TQW0G/F5V0B0NK14TQW0G.jpg&filename=IMG_20190925_180928.jpg)
You need to bend about 90° the legs of LED and then solder it with a little hanging about 5mm, for details can see the picture. This meant that the LED could match the holes in the 3D printed case.
Assembling Relay Module
![IMG_20190925_185856.jpg](/proxy/?url=https://content.instructables.com/FY0/TWQG/K14TQVT7/FY0TWQGK14TQVT7.jpg&filename=IMG_20190925_185856.jpg)
![IMG_20190925_192427.jpg](/proxy/?url=https://content.instructables.com/FPP/2BX8/K14TQVM7/FPP2BX8K14TQVM7.jpg&filename=IMG_20190925_192427.jpg)
![IMG_20190925_192628.jpg](/proxy/?url=https://content.instructables.com/FY6/2536/K14TQVF1/FY62536K14TQVF1.jpg&filename=IMG_20190925_192628.jpg)
First bend 90° male pin header on the relay module to the outside (see picture), then point to the PCB prototype hole from the back side and solder it (see picture), to be more stable also soldering on the opposite side of the PCB prototype.
Soldering Wemos Board
![IMG_20190925_195152.jpg](/proxy/?url=https://content.instructables.com/FG6/UO56/K14TQV7W/FG6UO56K14TQV7W.jpg&filename=IMG_20190925_195152.jpg)
Put the Wemos D1 mini board on the male pin header in the correct direction and then solder it.
Note: When you have soldered, if you find that the Wemos board that you are using getting error cannot be programmed, you will definitely need to desoldering and replace Wemos board with another one. to prevent this you can jump to step 11 for uploading the firmware first before you solder.
Finished of Hardware
![IMG_20190925_200034.jpg](/proxy/?url=https://content.instructables.com/FK2/A63E/K14TQV17/FK2A63EK14TQV17.jpg&filename=IMG_20190925_200034.jpg)
![IMG_20190925_200952.jpg](/proxy/?url=https://content.instructables.com/FPH/OBRY/K14TQUNT/FPHOBRYK14TQUNT.jpg&filename=IMG_20190925_200952.jpg)
![IMG_20190925_200906.jpg](/proxy/?url=https://content.instructables.com/FZ1/KRYH/K14TQUUJ/FZ1KRYHK14TQUUJ.jpg&filename=IMG_20190925_200906.jpg)
Congratulations, you have completing build hardware of SwitchIoT 4CH. This device have 4 relay switch to control turn on/off 220V AC home appliance. Has 4 buttons each of which can function as a toggle switch turn on/off locally for each relay switch. On button 0 there is an additional function if this button is pressed and held for about 5 seconds will forgotten the WiFi SSID and password stored in the SwitchIoT device. The 3mm LED installed on the device has a function as a wifi status led, you can find out more detail about the status in step 13.
This device is ready to use but to make it look more beautiful we cover it with a box made from a 3D printing on the next step.
Printing 3D Case
![IMG_20190930_063412.jpg](/proxy/?url=https://content.instructables.com/FPH/1HA8/K14VB071/FPH1HA8K14VB071.jpg&filename=IMG_20190930_063412.jpg)
![IMG_20190930_063600.jpg](/proxy/?url=https://content.instructables.com/FGE/VJAP/K14VB075/FGEVJAPK14VB075.jpg&filename=IMG_20190930_063600.jpg)
There are two parts, the bottom cover and top cover.
I realize this device is built using a relay module 4CH which does not have a standard PCB size, therefore maybe you will use a relay module PCB size that is different from my use. this has an impact on the not match between hadware with 3D printed case.
Here I shared some STL files (3D model file) for each of the different module relay PCB sizes, before you print the 3D model you should first check which model/size relay module PCB you are using.
Assembly All Together
![IMG_20190930_063246.jpg](/proxy/?url=https://content.instructables.com/FA1/XY0V/K16PA070/FA1XY0VK16PA070.jpg&filename=IMG_20190930_063246.jpg)
![IMG_20190930_214841.jpg](/proxy/?url=https://content.instructables.com/FWZ/WFSG/K14VACZX/FWZWFSGK14VACZX.jpg&filename=IMG_20190930_214841.jpg)
![IMG_20190930_214623.jpg](/proxy/?url=https://content.instructables.com/F8U/FU7K/K14VADJF/F8UFU7KK14VADJF.jpg&filename=IMG_20190930_214623.jpg)
After you wait a few hours and finish printing 3D case, next you assembly hardware and 3D printed case together. You need four 1/4"x4mm screws, two screws are used to tighten the PCB with the bottom cover and other two screws are used to tighten the top cover and the bottom cover.
Uploading Firmware to Wemos D1 Mini (ESP8266) Use SwitchIoT 4Ch App
![Screenshot_2019-10-02-18-22-17-865_com.bluino.switchiot4ch.png](/proxy/?url=https://content.instructables.com/FCW/XFBF/K18JOZ9P/FCWXFBFK18JOZ9P.png&filename=Screenshot_2019-10-02-18-22-17-865_com.bluino.switchiot4ch.png)
![IMG_20191001_172104.jpg](/proxy/?url=https://content.instructables.com/F6S/Q1BS/K16PENFV/F6SQ1BSK16PENFV.jpg&filename=IMG_20191001_172104.jpg)
![IMG_20191001_172003.jpg](/proxy/?url=https://content.instructables.com/FWD/8EQS/K16PENFX/FWD8EQSK16PENFX.jpg&filename=IMG_20191001_172003.jpg)
![IMG_20191001_171710.jpg](/proxy/?url=https://content.instructables.com/FYP/IMJN/K16PENFW/FYPIMJNK16PENFW.jpg&filename=IMG_20191001_171710.jpg)
After you finish setting up hardware with a smartphone, it's time you start upload the firmware into the Wemos D1 mini board (ESP8266). Wait before that make sure DO NOT CONNECT AC POWER during the flash cable connection.
Install SwitchIoT 4CH app from Google Playstore.
Open the SwitchIoT 4CH app, enter to widget settings menu, select the option "Upload firmware via USB", then press the "UPLOAD" button and wait until this is done it will take a little time. If you don't have an USB OTG or you are still at risk with your phone when uploading firmware from the phone, you can generate a firmware file in binnary format (eg. 0x00000_32e5_siot4ch.bin) by tap "GENERATE .BIN" button on App then send it to email or online storage, next open it on your computer then uploaded firmware using software NodeMCU Flasher.
Connect SwitchIoT Device to a Network
![asset_switchiot_instructable-03.jpg](/proxy/?url=https://content.instructables.com/FFZ/ZBYB/K0COWZ1H/FFZZBYBK0COWZ1H.jpg&filename=asset_switchiot_instructable-03.jpg)
![asset_switchiot_instructable-04.jpg](/proxy/?url=https://content.instructables.com/FG2/60JC/K14VB0A8/FG260JCK14VB0A8.jpg&filename=asset_switchiot_instructable-04.jpg)
After uploading is done, turn on the hardware and see what happens. The first time the status LED will blink rapidly, it means the device is not connected to any network (or in AP mode with hostname siot-xxxx), you need to add the network that will be used by the device.
Open App go to setting and choose menu "Connect device to network", confirm status LED of SwitchIoT device is blinks rapidly, connect your smartphone to a network with hostname siot-xxxx after that fill in the SSID and password a network that will be used by the SwitchIoT device. Then press "CONNECT", wait until it's done.
Knowing Status LED Indicator
![asset_switchiot_instructable-02.jpg](/proxy/?url=https://content.instructables.com/F79/RF24/K14VB0A9/F79RF24K14VB0A9.jpg&filename=asset_switchiot_instructable-02.jpg)
There are several conditions when the SwitchIoT device operates, it visible with changing of status LED.
1. The LED blinks rapidly, it means failed to connect with your router, it could be caused by:
- The WiFi strength is weak. Your router is too far away from your device, and there may be some interference in the environment. To solve it, please take your SwitchIoT device close to the router. If the problem still exists, please reset SwitchIoT device, reconnect to a network by add a network setting use App follow previous step.
- WiFi SSID and password stored in the SwitchIoT device has been forgotten, this can happen by pressing the button on SwitchIoT device for 5 seconds. you need reconnect to a network by add a network setting use App previous step.
2. The LED blinks once every 4s, it means fail to connect to the server, it could be caused by the network unable to access the Internet. Please check your network service connections and reset SwitchIoT device.
3. The LED steady on, it means SwitchIoT device works and connected to the server.
Share SwitchIoT Token With Other User
![asset_switchiot_instructable-08.jpg](/proxy/?url=https://content.instructables.com/FBL/JA9M/K14VB0A7/FBLJA9MK14VB0A7.jpg&filename=asset_switchiot_instructable-08.jpg)
SwitchIoT device owner can share fully control of the devices to others, and thus others can turn on/off, change schedule, timer, looptimer and name the device on SwitchIoT app. This functionality is great for the family as it will be allow them to control together.
The way to share SwitchIoT device tokens is very easy, you only need to share the unique tokens to others, and they just paste it into the SwitchIoT app. The token of each SwitchIoT device is unique and is generated from your Android smartphone, therefore this token is permanent, you must handle it with care to share it with others.
Control Multipile the Same SwitchIot Device
![asset_switchiot_instructable-05.jpg](/proxy/?url=https://content.instructables.com/FWI/XVZ4/K0ATXYJL/FWIXVZ4K0ATXYJL.jpg&filename=asset_switchiot_instructable-05.jpg)
The unique tokens can be allowed to be accessed by more than one app and more than one SwitchIoT device. With this feature you can create schemes such as two switchiot devices and SwitchIoT app that can be controlled together. If one SwitchIoT device is ON then the other SwitchIoT device also follows the same conditions ON, as well as the app.
Usage - Wiring Diagram for Lights
![asset_switchiot4ch_instructable-06.jpg](/proxy/?url=https://content.instructables.com/F6N/WOVG/K16PEN78/F6NWOVGK16PEN78.jpg&filename=asset_switchiot4ch_instructable-06.jpg)
This SwitchIoT 4CH device have the same functions basic Sonoff has. In SwitchIoT 4CH App, you can remote turn on/off light/home appliance from anywhere at any time.
See to the picture, is s sample wiring diagram of the usage to turn on/off four lights.
Enjoy
![IMG_20190924_162752.jpg](/proxy/?url=https://content.instructables.com/FZ0/AMLI/K14TQXIB/FZ0AMLIK14TQXIB.jpg&filename=IMG_20190924_162752.jpg)
Hopefully you enjoy your SwitchIoT 4CH. You can also make smart switch devices that are simpler for 1 channel switch and have a lot of hardware variations that you can use, so you can follow this tutorial below:
If you do and done, please share "I Made it!" to let me know how much is worked. Share the link, like and subscribe. As always, if you have any questions please let me know!