What’s better than a wifi controlled relay?  Two wifi controlled relays! That’s the sonoff Dual.  I already did a video about that. Then what’s better than 2 wifi controlled relays?!? 4 wifi controlled relays!  Let’s check out the 4 channel Sonoff!
AliExpress.com Product – Sonoff 4CH Pro – 4 Channel WiFi RF Smart ON/OFF Remote Switch Controller Inching/Self-Locking/Interlock/ Timer DIN Rail Mounted

The 4 channel sonoff comes in 2 different models.  The Pro and the not-so-pro?… And actually each of those models and an “R2” version, and a non-R2 version.  So really there are 4 different Sonoff 4 channel devices. That means there are potentially 4 different methods for flashing… Fear not!  I’ll do my best to cover them all.

 

The first model we’ll talk about is the original non-pro non-R2 4 channel sonoff.  Fortunately all these different models look very different from the outside, so you don’t even have to take it apart to know which model you have.  The non-pro has 3 banks of connectors. And the non-R2 has more of a blocky case, compared to the R2 that has rounded corners and just a little more style.  The one I have is the non-R2. The first thing that struck me was how deep these screw holes are. You’ll need a long skinny screwdriver to get those out. Now let’s look at the board.

 

There are 3 banks of wire connectors.  One is for neutrals, then there’s the hot in and the switchlegs out.  The 3rd bank is either for ground or for those crazy countries that let people use 240v… The serial connections are labeled so no problem there.  The tasmota site says at some point in the past there was a problem with the Rx/Tx pins being mislabeled. It should be the same as every other sonoff device: 3.3v – Rx – Tx – Gnd.  They also labeled GPIO-0 and it is connected to the first relay button. So you’ll just have to hold that button down when you power up to get into programming mode. We’ll do that in just a second.

 

Let’s talk about tasmota setup for a minute. If you’re wondering why I want to change the firmware to Tasmota check out this video where I explain my reasons. Now, I’ve tried multiple times to establish a “standard” for flashing.  Something that is easy and repeatable, but things are constantly changing, both with tasmota and with arduino libraries and board managers. If you’ve flashed anything lately with tastmota 5.13 and esp board manager 2.4.1 you know what I’m talking about!  So, what I’m advocating now is to get the zip file from ESPeasy that contains the FlashESP8266.exe file.

https://github.com/letscontrolit/ESPEasy/releases/download/mega-20180513/ESPEasy_mega-20180513.zip

(i tried changing the name to FlashEZ, it doesn’t work). Then download the sonoff.bin file from the tasmota github page and save it to the same folder as FlashESP8266.exe.   

https://github.com/arendst/Sonoff-Tasmota/releases

No messing with Arduino IDE, no messing with libraries or board managers, no errors.  There’s some extra steps to the setup after flashing, but it’s worth it to not deal with some of the variables that keep changing and causing a lot of people headaches.

 

Some Sonoffs, including the 4ch use the 8285 chip instead of the 8266.  As far as I can tell the only difference is that the 8285 has the 1M of memory inside the chip. So there’s no reason why you can’t use the .bin files from the Tasmota github.

 

Once we’ve got the bin file, we can get the 4 channel in programming mode by connecting our FTDI adapter, holding the GPIO-0 button down, and then plug the FTDI into our usb port.  Then open FlashESP8266.exe and select the port and sonoff.bin. Click “flash” and pray.

 

Once you’ve successfully flashed you’ll need to connect to the wifi network the sonoff creates. First step is to press the GPIO-0 button 4 times quickly.  Find the Sonoff wifi and connect to it. Input your home wifi ssid and password, then restart. Sometimes you have to power down and power back up for the sonoff to connect to your wifi.  Now you have to find the IP address of the sonoff by looking in your router (or fing). Put the IP address in your browser and open the Tasmota main page.

 

Sorry to repeat all that again.  I feel like I’ve said the same thing like 10 times.  If you’ve seen me say it all 10 previous times in the past I apologize.  With new people watching it’s hard to know what to repeat and what not to repeat.

 

In the tasmota main page go to Configure Module and set the module type to 4 channel.  Save & Restart. Next let’s input your mqtt broker information. If you’re new and don’t know what that means go watch this video about setting up Home Assistant and MQTT.  Then Save & Restart again. One more thing I like to do is change the name of the board in Configure Other, so it’s easier to find on my network. Save & Restart again. Now if you look at the Configure Module page you should see all the relays and switches are already set-up.  

 

That’s all you have to do to get the 4 channel flashed.  Now I want to show you something really cool that you can do starting with version 5.12 of tasmota, and that is Home Assistant Discovery.  What this will do is allow the device, in this case our new 4 channel sonoff, to add itself to Home Assistant as switch, well as 4 switches.  That means we don’t have to go into the configuration file and manually add the lines to create these 4 switches! To make that happen go to the Console and type “SetOption19 1”.  You will need to restart Home Assistant for the switches to be added. But once you do… bingo! There they are. All ready to go! Interestingly when you add switches this way, they don’t get saved in your config.yaml.  I actually couldn’t find where they get saved. And, if you disconnect the device later the switches will still be there but will say “unavailable”. I don’t know all the details of the Discovery function, but it’s a cool way to not have to edit the config.yaml when you add new tasmotized devices!

 

I don’t have a non-Pro 4ch R2, and I couldn’t find any images of the board. So if you have the non-Pro R2 and have trouble getting it into flash mode, post a link to an image and we’ll check it out and I’m sure we can figure out where all the pins are that you’ll need.

 

Now on to the Pro.  The Pro is quite a bit different from the non-Pro.  To start with it has very different wire connections. The pro can be powered by AC (110 or 220v) or by DC (5-24v), and each relay is separate from the power coming into the unit.  Meaning each relay can switch a different circuit, and they are all independent of the power coming into the board. So you could switch a combination of high and low voltage circuits. Also, the relay connections have NO/NC contacts.  Similar to what you’d find on an independent relay, like this. On the non-pro all the relays are connected as Normally Open, which is the way a Sonoff Basic works. The relays are 15A rated on both the Pro and the non-Pro.

 

Another difference is the Pro has a second microprocessor.  That allows the pro to do some extra functions like have it’s own timers that don’t require the app or a hub like home assistant. I don’t know how those functions will work once we flash the ESP chip… That other chip has it’s own serial pins.  Don’t get those confused with the ESP chip pins. The ESP serial pins are in the same place on the Pro as they were on the non-Pro.

 

GPIO-0 is not connected to the button like it is on the non-pro.  But fortunately we know where to find GPIO-0 on all these chips. Remember when we flashed the Sonoff Touch?  If you have the non-R2 Pro, then you’ll have to connect to GPIO-0 just as it comes off the chip. It’s the second from the right on the opposite side from the antenna.  Right here:

 

I have the Pro R2, and GPIO-0 is in a different place!  So ya, 4 different 4 channel models and GPIO-0 in 3 different places.  Thanks iTead. This image shows where GPIO-0 is located on the Pro R2.

 

Now we can finally get to flashing the Pro.  Connect the serial pins, hold a jumper from ground onto GPIO-0, then plug the FTDI into your usb port.  The Pro takes longer to boot up, so you have to hold GPIO-0 to ground for a few seconds before it will enter programming mode.  I’m guessing that has something to do with that other chip. Follow the same process as the non-Pro once it’s in programming mode. Start FlashEZ, select your bin and flash away.

 

Now because GPIO-0 isn’t connected to a button, getting the board to broadcast it’s wifi is quite tricky. I actually couldn’t do it.  I tried putting GPIO-0 to ground 4 times, but either I did something wrong or for some other reason that didn’t work. Fortunately there’s another way to communicate with your newly Tasmotized device.  If you want the full explanation of how this works check out this video by Vicious. He’s the only reason I even know about this method. Essentially, you use a program called Termite to communicate with your sonoff through the serial pins.  So while it is still connected to your computer with your FTDI adapter you can type in commands to set you home WiFi SSID and password. I’ll leave the details to him, but you can bet I’ll be using this method in the future. Thanks Vicious. You can even start Home Assistant Discovery this way with “setoption19 1”.  (mind blown)

 

If you want to enter your switches manually in HA. Open your configuration and add these lines, but change the middle part of the topics to whatever you put for your MQTT topic in the Tasmota MQTT config.

 

One of the best parts about the Pros is it can receive RF signals. But you need an RF bridge to take advantage of that function.  Fortunately, I’ll be hacking the RF Bridge in the next video.

 

So the 4 channel is pretty cool… but it isn’t the only way to control multiple relays… Just for kicks I set up a D1 mini with 4 relays and 4 buttons.  I call it the Hydra! I think I exceeded the max current output for the D1 mini though, because when I tried to run all the relays and all the switches it started behaving all crazy.  I could control the relays fine from the web UI, but when I tried it with the buttons it freaked out. So if you do this you might not want to use the powered buttons.

 

You can also create your own 4 channel from a sonoff SV and 3 relay modules.  Since the 4ch models cost between $20-30 and the SV + relays cost less than $10, it is a tempting arrangement. Those of you who came early to the maker faire probably met Tyson.  He was manning the booth for the first few hours. He used an SV with 3 extra relays to run his sprinkler system.

 

I tried doing the same with a sonoff basic.  I fried 2 in my attempts. I’m not saying it’s impossible but it can cause problems so if you don’t have sonoffs to spare you might not want to try it.  I think the problems come from the current requirement for the relay. These GPIO pins have a max output of like 12 mA. I tested these relays to see how much current they draw.  At 5v they draw __ mA. So what most relays require is a secondary source of power, besides the GPIO pin. In other words, the signal from the GPIO pin is not sufficient to power the relay coil, so the relay won’t work.  And you may damage your ESP chip in the process. The Sonoff Basic can’t supply that extra power. So you need a secondary source. Adding a second PS kinda defeats the purpose of using the Sonoff in the first place.

 

So that’s it.  The Sonoff 4 channel, all 4 of them…  Seems like a good board. Kinda pricey I think, compared to either the sonoff SV or the D1 mini with relays attached, but if you’ve got a one and you’ve just been waiting to use it with Home Assistant or some system, now you can.

 

I’m not sure where I’m going to use these.  They can’t really go in a switchbox… Maybe I’ll find a use for them in the garage or something.  

Viscous video

The relays on the Pro can operate in 3 different modes.  Interlocking, self-locking, and inching. If this switch is set in the 0 position, then all the relays will be interlocked, meaning only one can be on at a time.  If you change that switch to the 1 position then the relays can be in either self-locking, or inching mode. When the big switch is on 1, then this set of 4 tiny switches determines if each relay (1 through 4) is self-locking or inching.  Switch 1 controls relay one, switch 2 controls relay two and so forth. If the big switch is on 1 and tiny switch 1 is set to 1 then relay one will be in Self-locking mode. Self-locking means the relay will operate independent of any other relay. It can be on or off, regardless of the state of any of the other relays. If tiny switch 1 it is set to 0 then relay one will be in inching mode. Inching mode means the relay will activate but then deactivate after a set time. With the R2 the time delay can be set from 1-16 seconds. (The non-R2 Pro uses smaller intervals, 0.25 – 4 seconds). This other bank of 4 tiny switches controls the time delay.  There are 4 switches with 2 possible positions each, for a total of 16 different possible arrangements. Each different arrangement corresponds to a different time delay. There is a key on the back of the board that tells you what the different switch positions do, including how to set the time delay. Also, iTead has a decent explanation on their website. Not a lot of words, but very pretty pictures. So the Pro does add quite a lot of functions compared to the non-Pro.

 

https://www.itead.cc/sonoff-4ch-pro.html