How to flash Sonoff Mini in MacOS

How to flash Sonoff Mini in MacOS

2019, Sep 30    

How to use REST API to flash Sonoff Mini with Tasmota.

Requirements

  • chceck if eWelink firmware in Sonoff Mini is updated to at least version 3.1. If not, connect Sonoff Mini to Wifi using eWelink app and then update firmware using same app
  • physicaly open the device cover and connect DIY jumper
  • create Wifi with SSID sonoffDiy and password 20170618sn (both are case sensitive!)
  • connect Sonoff Mini to this network
  • run HTTP server on sonoffDiy network (ideally nginx) - HTTP server must support the Range request header

Find the Sonoff Mini on network

Find in administration of your WiFi router your Sonoff Mini IP Address deviceIP . Using utility dns-sd find Zeroconf detals, specifically deviceID - look for Instance Name.

dns-sd -B _ewelink._tcp

It will look like eWeLink_100000140e. 100000140e is your deviceID.

Download Tasmota

On HTTP server download Tasmota to root folder of HTTP server:

sudo wget http://thehackbox.org/tasmota/release/tasmota-lite.bin -P /var/www/html

And count SHA256 <SHA256> of firmware binary file tasmota-lite.bin:

shasum -a 256 tasmota-lite.bin

It will look like c01b39c7a35ccc3b081a....

Update firmware using OTA

  • check if your Sonoff Mini is connected:
curl http://<deviceIP>:8081/zeroconf/signal_strength -XPOST --data '{"deviceid":"<deviceID>","data":{} }'

if response looks like this, everything is ok:

{ 
    "seq": 2, 
    "error": 0, 
    "data": { 
      "signalStrength": -67 
    } 
 }
  • Check if otaUnlock is true:
curl http://<deviceIP>:8081/zeroconf/info -XPOST --data '{"deviceid":"<deviceID>","data":{} }'

Response:

{ 
	"seq": 2, 
	"error": 0,
	"data": {
	"switch": "on",
	"startup": "stay",
	"pulse": "on",
	"pulseWidth": 2000,
	"ssid": "eWeLink",
	"otaUnlock": true
	}
 }

If otaUnlock is false just use:

curl http://<deviceIP>:8081/zeroconf/ota_unlock -XPOST --data '{"deviceid":"<deviceID>","data":{} }'
  • Update firmware using OTA:
curl http://<deviceIP>:8081/zeroconf/ota_flash -XPOST --data '{"deviceid":"<deviceID>","data":{"downloadUrl": "http://<HTTPserverIP>/tasmota-lite.bin", "sha256sum": "<SHA256>"} }'

And wait abou 30 seconds.

Once the firmware is successfully uploaded and Sonoff Mini restarts, look for sonoff-xxxx WiFi. You should know the rest.

API Documentation for Sonoff DIY