Sonoff dual wifi switch

Hello I’m new to this so was wondering anyone can advise on the setup of this switch through smarthings hub with a mod to the firmware

I’m not sure if anyone has written a DTH for the dual switch yet.

I’ll tag @erocm1231, if anyone knows he will.

Ok many thanks for that

I have been wanting to get the Dual switch working but have been so busy that I haven’t had the time. I have 4 new devices coming from itead that I want to work on as well.


Thank you for your reply, would it be true in saying that there are plans for intergration with the sonoff/itead and echo coming soon or is this just a rumor ?

I haven’t heard of any official integration, but I wouldn’t be surprised given the traction that Alexa has.

Ok I’ll still be flashing my sonoff to keep it local and using my smarthings hub, but I’ve ordered 10 dual units as it was a size issue so ill change them to single for now ,thanks again keep up the excellent work


I’m more keen with the Sonoff 4ch wifi switch, i can just put it inside the wall plate. Would love to see it working. Are you getting one of that to tinker as well ?

  • thanks.

Hello could someone tell me where I am going wrong please .I have the sonoff TH 10 device and have flashed it with ESP easy and put the firmware in sonoff TH image to it also Is this the right image or do o have to install the sonoff .ono image as well? on connected to smarthings hub and it will work like a switch but will not detect temperature I know the sensor works as I have installed it into an un flashed device and connected it to ewelink and the temperature reads (it is the waterproof sensor for temp that I have) can someone please detect me to where I am going wrong…thanks

Also when I try to discover the device I have to use the ip and put the sonoff sw title as it will not install when I put in the Th switch title the Th is running as a sonoff switch but not Th switch . I have downloaded Eric’s firmware for it and installed it as he said? esptool.exe -vv -cd nodemcu -cb 115200 -cp COM%comport% -ca 0x00000 -cf Sonoff.ino.generic.bin Putting my Coms port in and also changing the sonoff file to TH Can anyone give me a clue please as being a novice doesn’t help thanks

Hi, any luck with adding sonoff dual to ST? Have a few and wanted to link them to ST.
Would it be very diferent from sonoff single switch?
For anyone that understands a bit more of programming would this code need a few tweeks!?

// derived from the Basic MQTT example

#include <ESP8266WiFi.h>
#include <PubSubClient.h>

// Update these with values suitable for your network.
String MQTT_SUBSCRIPTION = “sonoff/2/#”;
String MQTT_PUBLISH = “sonoff/2”;

const char* ssid = “xxx”;
const char* password = “yyy”;
const char* mqtt_server = “zzz”;

boolean relay1 = false;
boolean relay2 = false;
int incomingByte = 0;
int iStep = 0;
int iNewState = 0;

WiFiClient espClient;
PubSubClient client(espClient);

void setup_wifi() {
// We start by connecting to a WiFi network
//Serial.print("Connecting to ");

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {


//Serial.println(“WiFi connected”);
//Serial.println("IP address: ");

void callback(char* topic, byte* payload, unsigned int length) {
boolean bset = false;
payload[length] = ‘\0’;
String sPayload = String((char *)payload);
String sTopic = String(topic);
if (sTopic == MQTT_PUBLISH + “/relay1/set”) {
if (sPayload == “1”) {
if (relay1 == false) bset = true;
relay1 = true;
} else {
if (relay1) bset = true;
relay1 = false;
if (sTopic == MQTT_PUBLISH + “/relay2/set”) {
if (sPayload == “1”) {
if (relay2 == false) bset = true;
relay2 = true;
} else {
if (relay2) bset = true;
relay2 = false;
if (bset) setrelays();

void reconnect() {
// Loop until we’re reconnected
while (!client.connected()) {
//Serial.print(“Attempting MQTT connection…”);
// Create a random client ID
String clientId = “sonoff-”;
clientId += String(random(0xffff), HEX);
// Attempt to connect
if (client.connect(clientId.c_str())) {
// Once connected, publish an announcement…
client.publish(MQTT_PUBLISH.c_str() , “connected”);
// … and resubscribe
} else {
// Wait 5 seconds before retrying

void setup() {
client.setServer(mqtt_server, 1883);

void loop() {

if (!client.connected()) {
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte =;

if (incomingByte == 0xA0) {
  iStep = 1;
else if ((iStep == 1) && (incomingByte == 0x04)) {
  iStep = 2;
else if ((iStep == 2) && (incomingByte >= 0) && (incomingByte <= 3)) {
  iStep = 3;
  iNewState = incomingByte;
} else if ((iStep == 3) && (incomingByte == 0xA1)) {
  iStep = 0;
  if (iNewState == 0) {
    relay1 = false;
    relay2 = false;
  if (iNewState == 1) {
    relay1 = true;
    relay2 = false;
  if (iNewState == 2) {
    relay1 = false;
    relay2 = true;
  if (iNewState == 3) {
    relay1 = true;
    relay2 = true;
  // client.publish(MQTT_PUBLISH.c_str(),String(iNewState).c_str());
  if (relay1) client.publish((MQTT_PUBLISH + "/relay1").c_str(), "1");
  else client.publish((MQTT_PUBLISH + "/relay1").c_str(), "0");

  if (relay2) client.publish((MQTT_PUBLISH + "/relay2").c_str(), "1");
  else client.publish((MQTT_PUBLISH + "/relay2").c_str(), "0");
} else iStep = 0;


void setrelays() {
byte b = 0;
if (relay1) b++;
if (relay2) b += 2;
if (relay1) client.publish((MQTT_PUBLISH + “/relay1”).c_str(), “1”);
else client.publish((MQTT_PUBLISH + “/relay1”).c_str(), “0”);

if (relay2) client.publish((MQTT_PUBLISH + “/relay2”).c_str(), “1”);
else client.publish((MQTT_PUBLISH + “/relay2”).c_str(), “0”);

Hello Eric, i have successfully flashed the sonoff dual R2 using your bin file “SonoffDual.ino.generic.bin”, the sonoff dual is now appearing on the mobile app, i can toggle the on/off of the both switches. the problem is that the relays are not actually switching!
any ideas ? thank you

Maybe this comes a little bit late but:

I hope Smartthings enable publishing apps again so we can release the integration with ST too.

Did you get you sonoff dual relay problem fix ?
I have looked at many post but I still have the relay issue.
I see the Sonoff dual in my smartthings I can’t get the relay to toggl on or off.
need help please !