Homey Community

Sonoff re-program


#1

Did somebody allready re-programmed the ESP8266 chip on the Sonoff to use for example the Homey Arduino app?


#2

Yes,
I did flash several Sonoff devices with Tasmota firmware. Works 100% with Homey.

You can now even buy son off devices on Amazon which are already flashed with Tasmota firmware.

Gr. Remco


#3

I haven’t specifically, but should be possible. Not sure how the relays and/or sensors are connected to the ESP8266 on Sonoff devices (which GPIO’s), though (specifically for sensor support, you’re going to need additional Arduino libraries if you want support for those).


#4

How can we recognise these Tasmota flashed son off devices ?


#5

There you go:

Gr. Remco


#6

To be clear: OP isn’t asking about an alternative firmware, like Tasmota. He’s asking about flashing a Homeyduino-based program onto the ESP8266 inside a Sonoff device.


#7

Yes that’s correct, I found this:

https://randomnerdtutorials.com/reprogram-sonoff-smart-switch-with-web-server/

Now waiting on my sonoff to arrive and then try if I can get my code in it after a re-flash.
The reason is that I want to have a nice box for it, I have some “hobby” versions now


#8

See also huisvanvandaag.nl (Dutch)


#9

Hello, i’ve done this tutorial and my sonoff is flashed (I can control it via 192.168…/on - /off).

What’s the next step to control it with Homey ? I don’t really understand “MQTT”…

Thanks,

Julien


#10

Easy peasy with: https://apps.athom.com/app/com.athom.homeyduino


#11

Thanks for answer !

But when I try to add I got this message:

ans if I continue manually and add Sonoff IP I get this:

Since i’ve fashed my sonoff, I don’t have a “pairing mode” on my Sonoff (normal ?)

Do you know why I’m not able to add it ?

Thanks again,

Julien


#12

Can you post you’re arduino source code?


#13

Code is from https://randomnerdtutorials.com/reprogram-sonoff-smart-switch-with-web-server/

/*********
Rui Santos
Complete project details at http://randomnerdtutorials.com
*********/

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

MDNSResponder mdns;

// Replace with your network credentials
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";

ESP8266WebServer server(80);

String webPage = "";

int gpio13Led = 13;
int gpio12Relay = 12;

void setup(void){
  webPage += "<h1>SONOFF Web Server</h1><p><a href=\"on\"><button>ON</button></a>&nbsp;<a href=\"off\"><button>OFF</button></a></p>";  
  // preparing GPIOs
  pinMode(gpio13Led, OUTPUT);
  digitalWrite(gpio13Led, HIGH);
  
  pinMode(gpio12Relay, OUTPUT);
  digitalWrite(gpio12Relay, HIGH);
 
  Serial.begin(115200); 
  delay(5000);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  
  if (mdns.begin("esp8266", WiFi.localIP())) {
    Serial.println("MDNS responder started");
  }
  
  server.on("/", [](){
    server.send(200, "text/html", webPage);
  });
  server.on("/on", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(gpio13Led, LOW);
    digitalWrite(gpio12Relay, HIGH);
    delay(1000);
  });
  server.on("/off", [](){
    server.send(200, "text/html", webPage);
    digitalWrite(gpio13Led, HIGH);
    digitalWrite(gpio12Relay, LOW);
    delay(1000); 
  });
  server.begin();
  Serial.println("HTTP server started");
}
 
void loop(void){
  server.handleClient();
}

#14

That’s not Homeyduino code, that’s regular ESP8266 Arduino code.

Homeyduino is a separate Arduino library that you need to install, and the code needs to be modified so it uses that library.


#15

Thank you Robert !

I’ll try it, I hope I’ll able to do it :sweat_smile:

May you just tell me in wich step from the tutorial https://randomnerdtutorials.com/reprogram-sonoff-smart-switch-with-web-server/ do I need to add library and how ?

Thanks and sorry for being so noob :rofl:

Julien


#16

Sorry ! Bad research I guess information is here: https://github.com/athombv/homey-arduino-library/blob/master/docs/usage.md


#17

Yes indeed. Good luck!


#18

By the way, got my Sonoff stuff.
And re-program then to work with Homey was very easy, me happy and more importment my wife also :wink:


#19

Yes it works for me too ! It was easier than I thought ! I feel like a hacker now :joy:


#20

There is actually an more easier way to flash Tasmota in an sonoff device.

You dont need to compile anything just flash the tasmota bin file with an FTDI programmer into the SONOFF and use the Termite client to setup the network and you are up and running. After its flashed with tasmota you can update new tasmota releases over the air (OTA) no FTDI cables needed.

FTDI Programmer can set with a jumper too 3.3v or 5 volt:

Make sure the FTDI is set on 3.3 Volt otherwise you fry the electronics of the Sonoff.
Make sure TX is connecting with RX and RX with TX common mistake is TX-TX and RX-RX

Hooking up the FTDI - -> SONOFF

FTDI VCC 3.3v - > VCC sonoff
FTDI GND --> GND sonoff
FTDI RX --> TX sonoff
FTDI TX - ->> RX sonoff
FTDI GND - -> GPIO1 sonoff

The reason why you need too hookup the GPIO1 to GND is that the ESPXXXX chip needs to be set in Flashmode to accept the Tasmota bin file.

The Video Explains all:

Tasmota firmware:

ESPEasy flasher

Termite Client
https://www.compuphase.com/software_termite.htm