Sonoff gateway: sketch uploads fine but doesn't run

  • Contest Winner

    Pretty weird behaviour here. I have two sonoff bought a couple of years ago acting as mqtt gateways with this sketch running perfectly fine.

    I've recently bought another couple and despite uploading the same sketch it just does not work (the two of them). Sketch and wiring is the same of those working, arduino IDE's settings the same, the output when flashing is the same without errors, the PCB layout is identical (the new model has just 3 screws for the case instead of one but doesn't matter).

    After flashing just nothing happens (no serial output, no relay switching when pressing the button, no connection to the mqtt broker). I'd say it is a broken unit but doesn't make sense having two out of two broken and still able to be flashed (I'd have received a timeout error if the chip was completely broken). Tried flashing already multiple times without luck.

    Anybody seen a similar behaviour? Any special protection added to the ESP8266 chip in recent models I need to take rid of?


  • @user2684
    Install ESPTOOL

    run command ( it is for Linux - use com with its number in Windows ) --port /dev/ttyUSB0 flash_id

    Sonnof must response with its chip ID

    Something like this:

    Manufacturer: e0
    Device: 4016

    If it does, chip and connection is ok....

  • Contest Winner

    @kimot thanks you've definitely given to me the right direction to look into.

    Looks like my chip info is different and is the following: v2.6
    Serial port COM7
    Detecting chip type... ESP8266
    Chip is ESP8266EX
    Features: WiFi
    MAC: ec:fa:bc:86:da:e2
    Uploading stub...
    Running stub...
    Stub running...
    Manufacturer: 5e
    Device: 4014
    Detected flash size: 1MB
    Hard resetting via RTS pin...

    I see that manufacturer 5e is given problems to many people so I've followed the advice I found here to actually solve the issue, specifically flashing with the -fm dout flag (e.g. --port COM5 write_flash -fs 1MB -fm dout 0x0 file.bin) and now it works!

    Many thanks!

  • Mod

    @user2684 There's a lot of info regarding flashing ESP devices on this site: and

    You could also consider running Tasmota on your Sonoff devices, as it contains much more functionality compared to MySensors MQTT gateway.

Log in to reply

Suggested Topics