Sonoff 4CH 4 Channel Mains Control


Sonoff Sonoff 4CHA parcel turned up for me today – the Sonoff 4CH. You may recall I wrote some time ago about a smaller version they put out and I was quite scathing about the wiring. I turned out as you recall that this was a third party product and they were in the process of making their own version. Well, this is it.

The unit uses an ESP8285 (like the 8266 but with built-in Flash) to make a low cost 4-way mains power switch in a very nice DIN box. The price of the unit, at around £11.53 + postage, makes it cheaper than some people charge just for the box!!!

If you read this blog regularly you’ll know I’ve no interest in running their products on their own cloud – and that despite having my own very comprehensive software, this fellow has recently IMHO taken the lead in powering Sonoff products with his code. Well, it just so happens he supports this boar,  so this morning I grabbed the latest software, put in my MQTT and WIFI credentials, made the one change to the code needed to run this board (a single define) and off I went to open the board up.

Inside is the usual handy programming connector needing 3v3 and ground as well as serial in and out from an FTDI. As usual, I broke all the rules and instead of using a proper 3v3 supply I powered the board for the purposes of programming, directly from the FTDI – remembering to set it to 3v3 and not 5v.  At first I got nowhere until I realised I still had my Arduino environment set to ESP8266 – a quick check and there is indeed a setting for the smaller board.

And that was it – nothing to report really – it works as you’d expect.  Now what I don’t understand are the little covers – which on one side of the board cover up the 4 buttons to turn the outputs on and off (one of them is also the programming button) and on the other side the LEDs.  I will be drilling 5 holes in there so I can actually see the LEDs – but that’s just me.

Itead Sonoff 4CHDIN mounting, well put-together, inexpensive 4-relay switching.  The information claims you can use a maximum of 2.5Kw and that each output is 10 amps… well, I’m not sure I’d want to put 10 amps through there especially inductive, maybe more like half of that, while obeying the total of no more than 2.5KW.  There’s a little fuse on the board on the incoming live – but to save opening it up in the event of problems and finding a tiny fuse, I’d be thinking about the lowest sensible value of fuse in your power lead. I put a 10 amp fuse in there and may yet replace it with a 5 amp (of course what this means depends on which side of the pond you are on – we Brits get a lot more power out of 10 amps than our American friends).

You may notice something odd  – or depending where you live you might not find it odd at all – the neutral block is green and the earth block is grey. You see, being a Brit – I associate earth with grass – i.e. green and our earth wire is either green or some combination of green and yellow… so I could see someone being caught out by that – you’ll notice my wiring looks off with the green earth heading into the grey box!!!   Those push connectors incidentally work a treat! With previous Sonoff products I had people asking me what to do with the Earth wire – no such problem here.

This one is going to Spain with me – we have Star wiring over there and spare room on the power DIN rail so this will fit in very nicely to control some lighting and one small heater over there. If you’re starting from scratch this could make a decent low-cost-per-relay move into home control along with whatever software you use to control things – in my case – I send commands out from Node-Red via MQTT straight to the board over WIFI.


ITead Sonoff 4CH circuit board


At least on the surface, another winner from this company. Don’t all rush as Itead are on Chinese holiday until 3rd of Feb!


68 thoughts on “Sonoff 4CH 4 Channel Mains Control

  1. Hi Pete, I’d like to use this Sonoff 4CH to control 6 channels (6 motors that don’t need earth). Do you know if the earth relays allow to use them as independent circuits so that i can connect the remaining 2 channels there?


  2. I have a very novice question. I am trying to install Sonoff 4ch pros (stock version for now) in my home. I am not sure how to install Sonoffs in combination with the existing switch functionality.
    I want to use Sonoff ewelink app but want to maintain the original switch manual operation with the mains wiring as well.

    So that in case the sonoffs fail I am still able to operate the switches manually.
    Can you guide me please.

    1. The problem you may face with Sonoffs is that they tend to pass the live through. I really wish they would not do that, personally I’d rather have an uncommitted set of contacts, in which case you could jut put those any old way across the switch terminals so that either the switch or the sonoff could turn on the light.

      As it happens you really need to find out for sure if the live feed to the switch IS the live feed. One would ASSUME a live feed to the switch, the other end going back to the lamp and then on to neutral. In some cases the neutrals will be brought to a block in the switch – in other cases there is no neutral in the switch.. of course I’m ASSUMING a UK question – I don’t know which country you are in. If you’re in Spain, at least the parts I’ve been to, they don’t even HAVE specific live and neutral or if they do, no-one seems to bother about it 🙂

      So the answer to your question depends on where you are and how confident you are about the wiring and your skills. If it were ME (and only ME) – I would first ascertain for SURE that the switch had a LIVE feed which then went off to the lamp… and knowing that The Sonoff has a LIVE feed and a switched feed, I’d then take the switched feed only and take it to the OTHER connector on the switch – so that the switched side is switched EITHER by the Sonoff OR the actual switch – but that is a potentially dangerous proposition. No doubt others will have faced this situation and have thoughts a little clearer than mine?

      1. Junk that answer – I’ve just checked my Sonoff Pro – this does NOT apply to the older Sonoffs… it turns out that the Pro has uncommitted contacts – just checked with the meter – ie NO, COM, NC… in which case just wire the NO and COM across the switch.

        1. Thanks for the prompt replies.

          Now I am a bit confused. So I should just connect the live to com and the second wire to NO and leave NC open?

          Also, one more thing that I need clarity on- Should I install it between main supply and switch OR switch and devices?

          1. Assuming you’re talking about the same board as me with uncommitted contacts, NC = normally closed, COM = common, NO = normally open. So the contacts you want are common and normally open – these effectively make a switch that closes when power is applied to the internal relay -it is these two that you want across your switch.

            Be aware of course that if the relay for any reason jams CLOSED – then you won’t be able to turn the light OFF. If you need a failsafe to OFF then it gets more complicated – you’d need to wire the relay IN SERIES with the switch – so that even if jammed shut, you’d be able to turn things off with the switch. I don’t see that as a priority for a light however and it comes with it’s own perils as if someone turns the light off… you’ve no way to remotely turn it on.

            Personally in these situations I hand control over to the electronics and rewire the switch to be NOT connected to the mains – but to act as an input to something like an ESP8266 – I can then READ the wall switch and decide whether it should have priority or not… but that, of course is somewhat more complicated.

            1. Peter, can I ask for help I have a sonoff 4ch pro V1.1 2017-5-9 which I am trying to setup with an RF garage remote. If I follow the setup it accepts the remote and I get the 3 green flashes and the relay kicks in. However it will not store the setting any thoughts

  3. I have successfully installed the Tasmota firmware on a wemos D1 Mini. It works great but I need it to remotely control my garage door. Big problem is that in the event of a power failure the door will open when power is restored. Has anyone experienced and solved this problem? If this is too far off topic here I apologize and will post in a more appropriate place if one is available. Any help on this problem would be very much appreciated.

    1. Power failure / power restoration of what exactly? Installing the Tasmota firmware on a wemos D1 seems a bit odd since this firmware is intended for Sonoff devices..

    2. Tasmota is more for Sonoffs unless you desperately need the internal Alexa support. On the other hand it is souse code so you could add in non volatility. My code restores output states. There is an ESP/Arduino example with MQTT you could doctor.

      1. The good thing about use nig the wemos chip is that tasmota exoses all gpio pins with drop down menus for many different I/o devices including relays, buttons, switches, and sensors of all sorts. The problem is not with the firmware but rather that the chip “polls” all I/o pins and resets them on boot up. I have not been able to compensate for this behavior. When used as a garage door opener I was going to wire a reed switch to an I/o pin to indicate door open and a temp sensor to a refrigerator to indicate temperature in the event of someone leaving the door open, etc. the combination of wemos and tasmota would greatly simplify this effort but for the power failure issue. I am running several sonoff devices with tasmota and it is working really well. I will check out the code that Pete mentioned.

          1. Yes I can’t see him refusing that as really, if you set an output – it is reasonable to expect it to retain that status on power cycle.

            1. I received a response from David Lang that suggested a hardware solution to this as he says it is not a software issue. I have quoted it below:

              “not really, the relay click you are seeing is happening before the software is
              up and running.

              the best that you could do is to setup the relay to be inverted, instead of going from the pin to ground to drive your relay, try going from 3.3v to the pin

              other than that, you need to setup some way to require a longer pulse before triggering the garage door, you could probably do something with a capacitor on the output of the relay that would absorb the power for a bit (possibly with a pull-down resistor to slow it’s charging), it depends on how sensitive the garage door is.”

              I am still looking but very interested in the code solution you referenced. I may have missed something in your comment. I really appreciate the feedback I get. As a relative newcomer I don’t know a lot, but reading your blog and the comments is enormously helpful.


        1. I see. Well, good luck with finding a solution. All of that is already done in my code ( ) with key debounce and a number of temperature sensors handled – sending the lot out as MQTT – but you do need to be using a central handler like a Pi the way I do it along with access point redundancy, connection retries and mqtt checking etc… so I have some movement sensors and umpteen temperature/humidity sensors around the place. But everyone likes to do their own thing. I don’t know why they avoid referring to the ESP12 on the WEMOS MINI as that is what they are using with 4MB of Flash. I ordered some a while ago as they were a reasonable price… and the 4MB of FLASH means I can OTA them. I really must get around to designing a similar board with a set of MOSFETS in it.

          1. The code you linked looks really good. I had read that before when you published it but had forgotten about it until you linked it in your response. Thanks very much.

  4. I got my sonoff or working and under control with mosquito and everything is great. My next challenge, one that I don’t think I can overcome, is to use a wemos d1 mini and relay to control my garage door. The basic problem is that in the event of a power failure., The garage door will open when power is restored. I have a UPS on it but the problem is that even a UPS eventually runs out of power and during a prolonged shut down which is likely to happen. Again when power is restored the door will open. I don’t know if anyone has encountered this problem and has solved it but if so , I am anxious to hear the solution. The Tasmota firmware is great and very full featured. I am using that to install on most of my boards including the D1. It exposes all the gpio in the web interface.

  5. The device could have an additional 5 port connector, so you could connect four external buttons + ground

  6. To that end I just installed EasyEsp on my second Sonoff 4Ch so to compare the two packages. It seems fine albeit very different software and setup.

    The Tasmota wifi setup was a bit challenging for a first timer despite following the button setup instructions. I finally had to load the esp8266 SmartConfig app on an old android phone to get that working. The EasyEsp was turnkey for wifi but then I have done at least a dozen of those in recent weeks.

    I will try another software package on the two problem Sonoff Wifi units. Never opposed to trying something especially since the seals are broken off both units… 🙂

    The Sonoff Wifi unit that will not operate with mains is probably getting the multi-meter treatment to find where it is loosing power. Less optimistic about software issues on that one, especially since it works fine with usb power.

    Getting off the thread a bit so I will stop for now…

    1. Hello,
      This is a follow up after using two Sonoff 4 channel units for a month with no hardware issues!
      After trying a few software choices I settled on ESPeasy, easily modifed in the arduino editor to allow 20 tasks/devices before uploading. All software choices after loading the first have been easily changed over the browser without having to reconnect via the serial port.

      Current status now:
      1-MQTT or The four local buttons can toggle the outputs.
      2-node-red manages using the bright blue led for effective outdoor wood boiler warnings
      3-a one wire network of 8 DS18b20 sensors is connected via an RJ45 mounted to the Sonoff 4Ch housing and these feed node-red/mqtt
      4-I continue to use the outputs for experiments, the latest with IFTTT and turning lights on when I arrive home (cell phone gps). A simple old school motion detector would do the same but what is the fun of that??

      It seems ESPeasy does have someone taking over the code which is a relief.
      There have been reports of wifi response issues with ESPeasy and to that end I loaded a fairly complicated node-red test flow from the community and have no issues on any of my 6 running Sonoff/esp8266 units with Version 147. I actually use that flow to test how far I can move the Sonoff units from the wifi radios before they start having trouble. I can not quite place one at the outside boiler just yet which is a goal.

      Off track: I am looking at ESPurna for my new Sonoff POW as I don’t believe ESPeasy can do that current measurement as of yet.

      Thank you Pete for keeping this blog going! Great site for insomnia….

  7. Got my new 4CH up working with Tasmota!

    Also for others, on the original Sonoff’s, I am having great luck just pushing in the 5 pin header and using a very very light rubber/elastic band to pull just a little against the pins to keep contact. No soldering needed and fast error free flash every time thus far!

    Now I am having quality issues on the original Sonoff’s. Of the first 6 I bought, two work great as expected. The 3rd only works while the usb is connected but fails to start with mains(no usb at that point of course). The 4th unit has very poor wifi with numerous restarts. I have not tested #5 and #6 as the 4CH board arrived and captured my attention!! On the original Sonoff’s I am using EASYESP and have tried both v120 and v147 on all 4 units. The two good units are already integrated into house projects…

    Love your blog Peter, keep up the good work.

    1. as sonoffs are so limited, only a button and a relay, just withdraw easyesp (whose development is now on hold, as original developer is looking for someone to step over…), and use arendst which is proven to be good on them…

      no need of all the bells and whistle, for such devices… even Peter uses arendst version, as his own firmware version (even if perfectly working) has no real advantage on such hardware, with no additional gpio or functionalities needed… and arendst supports OTA…

      1. Well I was quite bummed when I read your note about EasyEsp going into a hold pattern. I had just pushed it into the 4ch Sonoff.
        I liked the EasyEsp because it seemed to be able to do some work on it’s own rather than needing the central server for decisions. But that is perhaps me not learning enough about the other options just yet…
        Such is the world of technology….
        I will try others of course. Glad to catch this snag now rather than after totally fixing on that solution.

  8. Hi

    Thanks for all the great information you supply.
    Did you get your unit direct from itead or is there a place in the UK.



    1. Hi

      I don’t generally use UK merchants as they’re just selling Chinese products and making a living out of it… easier to just send to China if you’re not in a mad rush. Usually takes a couple of weeks. ITEAD are ok, don’t use courier – just normal Chinese post.

  9. In the ballpark of sonoff devices, but perhaps not this particular one, I’d interested to learn what you guys are using to control your lights.

    I’m pretty sure the sonoff touch switch won’t work here in the UK with our ‘no neutral wire’ switch wiring scheme

    1. ..posting a follow up to my own comment in my quest to find a reasonable lighting control solution for my lights in the UK.

      After much deliberation I’m going to attempt to automate my lights using a regular sonoff power switch:

      The plan here is to flash a flavour of my own firmware onto the sonoff switch to add mqtt support and I also hope to be able to hack the sonoff hardware a little too, to enable it to be switched via regular light switch in addition to via mqtt.

      Then I’ll wire this into the lighting circuit directly above the ceiling rose and push this thing into the cavity above.

      One sonoff switch is now winging it’s way from China..if I burn my house to the ground you might not hear from me again 😉

      1. Excellent news – always glad to hear longer term testing. Let’s not forget this code – which I personally think is the best so far – for the Sonoffs (naturally I think my code is the best on the planet but I can’t keep up with this guy for Sonoff-specific code)… I’m using his code with my Sonoffs..

        1. The basic sonoff 1 channel switch arrived and it’s working perfectly on the bench at the moment. I’m using the Sonoff-Tasmota firmware and it’s absolutely phenomenal so thanks for the heads up there. I’ve been able to test with a regular mains switch hard wired into GPIO14 and this is working well in conjunction with WiFi operation via node-red MQTT. So functionally this looks like it’s going to be a very decent solution.

          The one concern I have was that I did notice one of the mains neutral poles on the board was quite poorly soldered. It looked to be only soldered on one half of the pin/pad, solder was missing on the other half and I think I could even feel a bit of movement in the pin. I’ve done a bit of a maintenance job on this and it does look and feel a bit better now..but I think I’m feeling a little bit of healthy mains power paranoia..

          1. If I may suggest, Joe, drop a line to Sonoff about this – my experience is that they take quality control seriously. They would probably want to know if one of their units isn’t up to scratch.

            1. Yes good call, I’ve already opened a support issue with them and they’ve asked for a close up of the board. I’ve sent them this photo which was taken prior to my fix up – I hope they can see the issue on the pin to the right of the image.

          2. I am stumped and I hope someone can help me. I have loaded the tasmota firmware on a basic sonoff and can control it via the web interface. I must have a configuration problem because I cannot get mqtt to work with it. I have mqtt controlling other esp8266 devices in my home but this one stubbornly refuses to be seen by node-red or command line mqtt. My topic is sonoff1 in the web configuration. I just want to turn the unit on or off with mqtt. Any help would be welcome. Thanks.

            1. hmm there’s not much to it to be honest so I’m not sure what the problem might be. Here’s a screenshot of the MQTT page on one of my sonoff basics. I use hive MQTT here

            2. here’s a capture of my node-red lighting flow connected to a couple of sonoff basics – perhaps this will reveal a clue or 2 to you:

              1. Thanks!!! My topic was not properly formed. I saw yours and modified it appropriately. Thanks for the time and effort to help me.

  10. I wonder why they didn’t make the LED cover translucent? Also 4 x 1mm pin-holes in the switch side would keep it save but allow a paperclip to press the buttons

    1. Maybe it was an existing case they used… (I can’t imagine it selling in sufficient quantity to justify a molding while keeping the price down)… still – easy to fix..

      It is mine that is the wrong way around for connectors incidentally – I’m fairly sure green should be ground. I probably got an early model. Still – works a treat.

  11. To make the confusion complete, the green block on your photo is on the left side and on the official itead-photos, its on the right.
    Seems that they are mounted wrong on your board.

  12. I almost bought one of these. but using the ESP8265 with integrated flash killed it! at least until it has 4M and is updatable using OTA. I use OTA for everything!

    1. I’ve note tried OTA yet and that certainly won’t work on my software which is way over the 0.5 meg point – but Theo’s software should allow OTA with 1Meg.

  13. Hi Pete
    Have you any any experience with Sonoff SC ? Looks like a good, neat solution for my room sensors. A lot neater than a DHT hanging from a bit of alarm cable. What is the mic for??? Can the memory be upgraded to take your firmware?

  14. I would be curious to know if someone (s) could make a comparison of Arendst vs below:

    Above looks comprehensive, with OTA updates even with 1MB on ESP.

    I had asked, and Pete had replied, that ESPurna is too complex for his taste.

    But really what are the use cases for either ?
    ESPurna seems well maintained, with a huge device base, including Sonoff 4CH.

      1. Pete,the Home Assistant link has some references to MQTT, perhaps that all you need?

        And my 4channel looks like yours, with the wrong color coding but I’m dyslexic so I try to be careful with such things.

  15. Pete hi,

    I noticed from the board layout on the itead wiki that GPIO2 is broken out alongside the programming pins. Can you confirm this?

    Would be great if it was, then you could attach a series of DS18B20s. In the older single sonoff switches you had to use serial.switch() to make rx/tx available which meant you couldn’t see and debug code through the serial comms.

    I have a home brew to control a boiler which supplies supplementary heat to my heat bank and it also controls the UFH and CH pumps. All based on some temperature sensors on the tank. Hence the need for the extra GPIO.

    Would be brilliant to replace that with one of these.


    1. I can confirm that the 5 way connector includes ground, 3v3, serial in, serial out and GPIO2. This is pretty good because on previous boards some pins were wasted.

  16. It looks good. I plan to use one to control my swimming pool (motor and light) as well as a decorative fountain.

    I also plan to add a flow meter and thermometer (DS18B20) using the exposed header pins (just need to see how well the flow meter operates at 3.3V, or whether I have to steal 5V from somewhere on the board). Since there is only one additional GPIO exposed on the header, this will require disabling serial output, and repurposing one of the RX or TX as a GPIO too.

  17. I don’t really like the terminals used in those sonoff devices. I found them inconvenient/unreliable to use with hard copper wires.

    1. They seem fine to me – but I’m using stranded wire. I would have thought they’d be better, not worse with solid wire.

  18. Peter

    Have you got a unit with a production error? On the Itead Sonoff 4CH web page it shows the green and grey terminal blocks swappped, ie as you would expect them! This is how they are shown in the circuit board picture at the bottom of your blog page.

    1. Yes it has to be a production error – as you say the photo of the PCB is correct – but mine is the wrong way around. Anyway, I’ve reported this.

  19. Theo’s software is indeed great! Have you seen his new version Sonoff-Tasmota ?

    Works with Alexa too!

    1. I hadn’t but not surprised – he started later than me and my software is already WAY too big to allow OTA on an unmodified Sonoff (which is why I often use his – which works very well). I’m assuming, looking at the size of the file I just blew into the 4CH that he’s about to hit the ceiling – so separating things out makes good sense.

    2. His existing stuff works with Alexa too – and that’s great – but then – if you use HA Bridge as I do – anything that handles MQTT will work with Alexa. Now if only I could get Alexa to like me office WIFI…. (I have 2 units – utterly reliable in the house – take into my office – can’t talk right now for one reason or another – even though my ESP8266 devices are fine.

      1. The latest version supports Phillips Hue (emulates a Hue bridge), so more Alexa commands available.

Comments are closed.