Start a new topic

protocol for Sonoff Dual to replace original firmware

With the following information it should be possible to replace the original firmware.

Details from my protocol analyzer (attached to ERX/ETX:


Sampled from pushing the button on the internet





where 0xxx seems to be:

0x00 both off

0x01 relay one on

0x02 relay two on

0x03 both relays on

2 people have this question

I am using pin15 like suggested in previous posts. I just dont have the wire soldered on my setup just short it when needed

@Matej Same here... I just don't want to solder to that resister like the photo. My luck, I'd knock that resister off. I can't seem to get the above sketches to turn my relays off and on. I can see where the ESP is controlling GPIOs off of the Sil Labs F330... and I'm assuming that the Hex numbers are what the F330 is listening for. Where you able to get the code to turn your relays off and on? Thanks for getting back to me! Rob

Ok, I purchased the Sonoff Dual with the intention of reprogramming the ESP8266. Having just received it a few minutes ago I was shocked to find the relays were not controlled directly and that there was a F330 CPU in-between.

Thankfully after a quick google search I found this thread which provides more than enough information for my purposes but in reading the messages I wondered if anyone had tried re-flashing the F330?

Checking the board the C2 programming interface for the F330 is made available via a header (the one just above the button interface). Looking at the spec sheet for the F330 it has a 10bit A/D and D/A plus I/O. The best part is the I/O is mapped via an internal crossbar allowing the pins to be remapped under software control. The device appears to be supported by the Silabs Simplicity Studio environment.


I may have a look at this at some point in the future when I recive some more duals but for now all I need is access to the two relays which this thread has solved for me.


The protocol shown here so far can do two things:

1) set the relays sending a comand throught the serial port

2) understand the meaning of the data received at the serial port.

I would like to do a thrid thing: ASK the F330 what is the curent status of the relays.

So far we have to wait until there is a change in the relays status for it to respond.

Hello All,

i couldnt flash customized firmware after my first flash to sonoff dual switch, can anyone please help me resolving this issue.

2 people like this
I am trying to flash the device using arduino above code, its throwing some warnings:
Sketch uses 231649 bytes (25%) of program storage space. Maximum is 892912 bytes.
Global variables use 32304 bytes (39%) of dynamic memory, leaving 49616 bytes for local variables. Maximum is 81920 bytes.
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
please help


 You receive that error message when the IDE cannot talk to the board. Check your connections, insure the board in programming mode and verify you have selected the right com port used by the programming cable.

Hi Markus,

Can you sample Button 0 and Button 1 pins with protocol analyzer?

And if possible onboard button too.


Thanks for this contribution Markus, It was very helpful. Managed to load the code onto my Sonoff Dual and have the MQTT working from my own internal server. Is there a way that I can bring in the MQTT and link it into OpenHab?

 Hi Markus,

I have used your description to program the Sonoff Dual - thank you very much for this.

I use a Webserver (browser) that sends requests to the Sonoff Dual and reports the action back to the browser. I also use Fhem homeautomation and managed it with help of an experienced programmer to integrate the Dual into Fhem. Switiching of my blinds/shutters from a webbrowser or through Fhem works very well.

The main drawback for me is that I don't have a real response form the Sonoff Dual to Fhem. When I'm not at home I have no chance to see the status of my shutters.

For Fhem, MQTT is also implemented and it works fine together, e.g. with ESPEasy on ESP8266.

My programming knowledge is really limited, and so far I was not able to implement MQTT into my Arduino sketch (see attachment). Could you take a look at my sketch and give me support how to integrate MQTT into it?

The MQTT broker in Fhem homeautomation is protected with user / password. How could this be intergrated into the sketch? E.g., in ESPEasy the Controller IP, Controller Port, Controller User, Controller Password are listed which I use in the MQTT broker.

It would be really great if I can get help from you or any advice how to go forward.



Any suggestions on a momentary button I could use in my 1 and 2 gang wall receptacles? 

Would love to find a momentary based low voltage button that had options of 1, 2, or 4 buttons that i could hook up to the two onboard buttons on the Dual as well as GPIO's for additional room functionality. 


0x00 both off

0x01 relay one on

0x02 relay two on

0x03 both relays on

it sems that on my sonoff dual (v2.0):

0x05 relay one on, relay two off

0x06 relay one off, relay two on

Hope this helps someone :)

1 person likes this

Can i use RX and TX pins as input?

FOr anyone who doesn't fancy doing tiny soldering, I used a standard male-female breadboard jumper lead; plugged the female side into the gnd pin of the button header, and then just held the tip of the male side to the resistor attached to GPIO10 as I plugged the module into the USB to power up. SLightly fiddly, but no soldering involved, and worked like a charm.



0x00 both off 

0x01 relay one on 

0x02 relay two on 

0x03 both relays on 

0x05 relay one on, relay two off 

0x06 relay one off, relay two on 

Are there any commands to turn off the two relays individually? 

Like this: 

0x?? relay one off 

0x?? relay two off 


Login or Signup to post a comment