Introduction: Make a Cheapest DIY Sonoff 4CH

About: I am Bluino Electronics.

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!

Step 1: Hardware Reqiered

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.

Order SwitchIoT 4CH PCB

Step 2: Schematic

Step 3: Soldering Button and Male Pin Header

Placed 4 button and 2 male pin header into hole of prototype PCB followed picture, then solder all legs of component on PCB.

Step 4: Wiring and Soldering

To make the connecting wire follow step by step the line path as in the video with refer to the schematic in step 2.

Step 5: Soldering LED

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.

Step 6: Assembling Relay Module

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.

Step 7: Soldering Wemos Board

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.

Step 8: Finished of Hardware

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.

Step 9: Printing 3D Case

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.

Cover STL file for dimensions relay module PCB 76x56mm

or
Cover STL file for dimensions relay module PCB 75x50mm

Step 10: Assembly All Together

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.

Step 11: Uploading Firmware to Wemos D1 Mini (ESP8266) Use SwitchIoT 4Ch App

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.

SwitchIoT 4CH App

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.

Step 12: Connect SwitchIoT Device to a Network

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.

Step 13: Knowing Status LED Indicator

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.

Step 14: Share SwitchIoT Token With Other User

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.

Step 15: Control Multipile the Same SwitchIot Device

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.

Step 16: Usage - Wiring Diagram for Lights

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.

Step 17: Enjoy

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:

SwitchIoT for 1 Channel

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!