Make a Cheapest DIY Sonoff 4CH

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

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!

Be the First to Share


    • For the Home Contest

      For the Home Contest
    • Big and Small Contest

      Big and Small Contest
    • Make It Bridge

      Make It Bridge



    6 months ago

    I got this error while uploading the code. What is the problem? Do I have to build the circuit first and then upload the code or is it because I already used my wemos board?
    please reply


    1 year ago

    Can we use capacitive sensor instead of Tact switch?


    3 years ago

    Impressive and looks good. But I think this one is even cheaper :-)
    Anyway, with claim of 'the cheapest' you are bound for scrutiny:
    Sonoff 4ch pro is available for about 8 USD, maybeless if shop around:
    Wemos D1 2.40 USD
    relay board: 1.20 USD
    buttons 1.80 USD (ok, you get more than 4 for that but still)
    Perfboard 0.5 USD
    You will need a PSU (the sonoff has that built in)
    PSU 2.50 USD
    Total: 8.40 USD
    That does not include the 3D printing and it also does not count the fact that since you get parts from different stores, there will be seperate shippings to add.
    So... it is definitely not the cheapest. Not saying it isnt a nice project to do, but it is not the cheapest

    I am a bit taken back by the fact the app wants acces to my pictures


    Reply 2 years ago

    sonoff 4ch costs no less then 18$ on aliexpress, so this project match it, more or less


    Reply 2 years ago

    I checked your link, But it does not have any switches for manual control and also not able to add wifi credentials wirelessly.


    Reply 3 years ago

    Sorry about cheapest claim, this in my assumption with the results of hardware that is easy to use with App and hardware looks neat.
    I get a 4ch Sonoff for about $18.
    In Android permission to access picture is mean to access file in external storage, especially in this App for access firmware file generated.


    Reply 3 years ago

    haha, no problem. You were not under oath in court :-)


    Question 2 years ago

    Is there any way to change pin numbers for relays and switches plz help. I already have PCB with other wiring connections. Plz help.


    2 years ago

    Very nice project and easy to build work well


    2 years ago

    Congratulations!! Very good an complete project.
    Only one question, Is there a way to modify the firmware to include comunication with Alexa?

    Thank you


    3 years ago

    It looks like a nice build. Well laid out and clean design. Do you think you could add a buck converter so we could power it from mains and avoid connecting a usb power supply?