Menu

Flashing ESPEasy to the Sonoff 4CH

So far flashing the ESP8266 has been pretty easy, but with the new Smart Home devices from itead,it has become a bit more complicated. The reason for this, is because they have changed from the ESP8266, to the physically smaller ESP8285. The function of the 8285 is the same as the 8266, but it got the memory build in, instead of having it on an external chip.

Before we can flash ESPEasy to the ESP8285, we need a .bin file compiled for it. You can do that with the Arduino IDE, and in that load the ESPEasy source code, set the ESP8285 under Tools > Board, and then go to Sketch > Export compiled Binary, and you will then find a .bin file in the same directory as your Arduino sketch. Or you can go here and download the .bin file I compiled and put on mine https://github.com/blddk/esp8285/tree/sonoff_4ch. Here you can also find the NodeMCU flasher tool, which I used to flash my Sonoff 4CH.

Before being able to flash the ESP8285, there are a few settings which needs to be changed (config file is also included on my github), here is how I set mine up to be able to flash it.

So now we got the software part ready, but this isn’t enough this time. With the Sonoff switch, we have been able to just power it by giving it 3v3 from the TTL adapter, but the Sonoff 4CH draw too much current, so the CH340G chip on my TTL adapter can’t supply enough current to make it boot up properly. So to get enough current available, I modified my TTL adapter a bit.

From the top side, it still looks pretty normal, except you can see the extra jumper I added to easy be able to switch between 3v3 and 5v while having a connector attached to it.

On the bottom side, I put an LM1117 voltage regulator on between the VCC and 3v3 pin, and also connected it to GND to complete the circuit. This isn’t perfect, as it is just in parallel with the voltage regulator inside the CH340G chip, but it works. With this extra voltage regulator, you no longer have to worry about having enough current on 3v3, because it can supply a lot more than the TTL adapters normally can do.

I also made a cable just for connecting easily to the Sonoff 4CH.

And then I got to something very confusing, because it just would not work.

Normally TX on your TTL adapter, needs to go to RX on the thing you are connecting to, and RX to TX. This is because the transmitted signal must go to the pin where it is expected to be received. But the silkscreen on my Sonoff 4CH was actually opposite. RX from the TTL adapter needs to go to RX on the Sonoff board. I first found this after having been struggling with getting it to work for some hours, where I just go absolutely nowhere. I then found the datasheet for the ESP8285 based module they used, and probed for a bad connection, but instead I found the TX and RX pins swapped, so it was opposite than the silk screen.

After swapping the wires around in the connector, I could flash ESPEasy onto the Sonoff 4CH, and finally it accepted the new code.

All I needed now was to figure out what pin was connected to what function, and then it was ready to use. And to save a bit of your time, here is my findings for pin connections.

Captain, as stated in the schematic you refer to gpio7 anderen gpio8 as 2.5 Jack / Tem1 & Tem2, but i cant find a populated/unpopulated Place of an 4-pol 2.5 Jack. Can you help meine Out. I want to add a Temperatur/Humidity sensor

Hi Captain, thank you ever so much for your help above. I have successfully flashed Espeasy to my sonoff largely inspired by this post. I am having some issues though, I am really hoping you can help?

So my set up is using Domoticz, http control. Regardless of whether i use Domoticz gui, other controllers, or via HA-Bridge to Alexa I often get a mis-fire on the relays. I have no problem switching relays off, but when I switch them on I often get more than one coming on when not requested. For example, I’ll switch on just Relay 3 and all 4 switch on one after another.

If you get a chance, could you possibly take a look at my rules and tell me where I am going wrong:

On RearSecurityOn do
gpio,12,1
EndOn
On RearSecurityOff do
gpio,12,0
EndOn

On RearSecurity#Switch do
If [RearSecurity#Switch]=0
gpio,12,0
else
gpio,12,1
EndIf
EndOn

On OutdoorLightsOn do
gpio,5,1
EndOn
On OutdoorLightsOff do
gpio,5,0
EndOn

On OutdoorLights#Switch do
If [OutdoorLights#Switch]=0
gpio,5,0
else
gpio,5,1
EndIf
EndOn

On RearSocketOn do
gpio,4,1
EndOn
On RearSocketOff do
gpio,4,0
EndOn

On RearSocket#Switch do
If [RearSocket#Switch]=0
gpio,4,0
else
gpio,4,1
EndIf
EndOn

On WifiRelayOn do
gpio,15,1
EndOn
On WifiRelayOff do
gpio,15,0
EndOn

On WifiRelay#Switch do
If [WifiRelay#Switch]=0
gpio,15,0
else
gpio,15,1
EndIf
EndOn