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: