Skip to content

Instantly share code, notes, and snippets.

@Dacesilian
Last active February 3, 2021 21:16
Show Gist options
  • Save Dacesilian/b117f2194a72e3b7184b802e9cc82c82 to your computer and use it in GitHub Desktop.
Save Dacesilian/b117f2194a72e3b7184b802e9cc82c82 to your computer and use it in GitHub Desktop.
Sonoff Mini flashing ESPHome (OTA v2.0)
Needed software:
- HFS HTTP fileserver (for serving firmware file) - https://www.rejetto.com/hfs/?f=dl
- Not all HTTP servers will work, it has to support streaming, I think
- Postman (for instructing device to download file from URL) - https://www.postman.com/downloads/
- OTA protocol documentation: https://github.com/itead/Sonoff_Devices_DIY_Tools/blob/master/SONOFF%20DIY%20MODE%20Protocol%20Doc%20v2.0%20Doc.pdf
Steps:
- Prepare your firmware you want to flash (for example from ESPHome)
- Open some packet sniffer to view mDNS packets (in Linux: tcpdump port 5353 -i <your_interface> -vv)
OR view your router DHCP leases to find you, which IP address your device has
- Connect power to device, wait for a while (3-5 seconds)
- Long-press button for 5 seconds (wait till blue LED starts blinking fast)
- Search for WiFi network (with your phone) -> ITEAD-XXXXXXXXXX
- This part is tricky, be patient and wait for WiFi to appear. Repeat steps above if needed.
- Connect to this itead WiFi - password 12345678
- Open your browser and go to http://10.10.7.1
- Fill in your existing WiFi network (in home for example) and password, Save it.
- Open Postman, send POST request (my device has IP for example 10.36.1.37):
http://10.36.1.37:8081/zeroconf/info
```
{
"deviceid": "",
"data": { }
}
```
- Save returned deviceId (for example 1000f31493)
- You have to unlock OTA mode (have otaUnlock: true in info), so send POST request to
http://10.36.1.37:8081/zeroconf/ota_unlock
```
{
"deviceid": "1000f31493",
"data": { }
}
```
- Install HFS HTTP Server, start it and drag-n-drop with mouse your firmware file, you want to upload to Sonoff
- Get SHA256 sum of your firmware file - for example with PowerShell:
Get-FileHash .\firmware_file.bin | Format-List
You have to lowercase this hash! You can use:
(Get-FileHash .\firmware_file.bin | select Hash | Select-String Hash).ToString().ToLower()
- Send POST request with Postman (change values - device ID, file name, IP of your computer with HFS HTTP server running, sha256sum):
```
{
"deviceid": "1000f31493",
"data": {
"downloadUrl": "http://10.36.1.10/firmware_file.bin",
"sha256sum":
"08b2037b519631d8c1440bd35cfdefbd8b0d980496b8c0f55ff9e5d5df667cee"
}
}
```
You should get a response and will see in HFS HTTP File Server that file is beeing downloaded (Requested GET progress).
After successful flash, you Sonoff Mini will restart.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment