Sonoff DIY
Some new Sonoff devices support the new Itead DIY architecture which allows OTA firmware upload. With Sonoff DIY, a user has more control over the hardware features of the device and also allows for upgrading the firmware without additional hardware. The following procedure upgrades Sonoff eWelink firmware to Tasmota.
There are many reports this procedure has changed with newer versions of Sonoff DIY
Tasmota does not provide any kind of support for flashing using this method. Please contact Sonoff Support for help.
IMPORTANT: There are some reports suggesting that the Windows version of Sonoff DIY Tool contains a trojan. It is not clear if it actually contains the malicious code or these are just false positives due to the way Python code was converted to native executables. Nevertheless, proceed with care.
Compatible devices~
Currently the following devices officially support Sonoff DIY: - Sonoff Basic R3 - Sonoff RF R3 - Sonoff Mini
As Sonoff DIY is enabled by connecting GPIO16 to GND it may well be possible that other Sonoff devices running eWelink will support it.
Note
The OTA process Sonoff provides through the Sonoff DIY procedure does not create a backup of the Itead firmware on the device. If you use this OTA method to flash Tasmota on the Sonoff device, you will not be able to revert to the original factory firmware.
Flash procedure~
Guide originally from @Brunas
- Pair the device with the eWeLink app and update firmware. The wifi network you connect to during this step will need to be reachable in order to enter DIY mode.
-
Follow instructions how to enter DIY mode from Sonoff. This is the excerpt from it:
- Long press the button for 5 seconds to enter pairing mode, then press another 5 seconds to ender Compatible Pairing Mode (AP). The LED indicator should blink continuously.
- From mobile phone or PC WiFi setting, an Access Point of the device named ITEAD-XXXXXXXX will be found, connect it with default password 12345678
- Open the browser and access http://10.10.7.1/
- Next, Fill in WiFi SSID and password. Once successfully connected, the device is in DIY mode.
Note: I needed to manually change IP address to 10.10.7.2, 255.0.0.0 with gateway 10.10.7.1 in adapter TCP/IPv4 settings to access that IP address.
- Use Fing or any similar local network scanning app on your smartphone or PC to find IP address of your Sonoff Mini device. MAC Vendor most likely is Espressif and the device has 8081 port open.
- Check that diy mode is working properly.
$SONOFF_IP
must be defined with the IP or FQDN of the intended Sonoff device before running the curl
command. With curl or with PowerShell (Windows):
# curl
SONOFF_IP="10.0.0.2"
curl -XPOST --header "Content-Type: application/json" --data-raw '{"deviceid": "", "data": {}}' http://$SONOFF_IP:8081/zeroconf/info
# powershell
$SONOFF_IP='10.0.0.2'
Invoke-RestMethod -Method POST -Body '{"deviceid": "", "data": {}}' -Uri "http://$($SONOFF_IP):8081/zeroconf/info" | ConvertTo-Json
Or with the Rester browser extension:
Install **Rester** extension in Chrome or Firefox or any other preferred tool to perform REST API operations. To test your device DIY mode create new request in **Rester**: 1. Method: **POST** 2. URL: http://<*IP of your device*>:8081/zeroconf/info 3. Body: `{"data": {}}` 4. You might need to add Header **Content-Type** with value **application/json** 5. Press **SEND**If all is OK, status code 200 should be returned with bunch of data:
{
"seq": 1,
"error": 0,
"data": {
"switch": "off",
"startup": "off",
"pulse": "off",
"pulseWidth": 2000,
"ssid": "YourWiFi",
"otaUnlock": false,
"fwVersion": "3.6.0",
"deviceid": "YourDeviceId",
"bssid": "YourBSSId",
"signalStrength": -52
}
}
With curl or PowerShell (Windows):
# curl
curl -XPOST --header "Content-Type: application/json" --data-raw '{"deviceid": "", "data": {}}' http://$SONOFF_IP:8081/zeroconf/ota_unlock
# powershell
Invoke-RestMethod -Method POST -Body '{"deviceid": "", "data": {}}' -Uri "http://$($SONOFF_IP):8081/zeroconf/ota_unlock" | ConvertTo-Json
Or with the Rester browser extension:
1. Method: **POST** 2. URL: http://<*IP of your device*>:8081/zeroconf/ota_unlock 3. Body: `{"data": {}}` 4. You might need to add Header **Content-Type** with value **application/json** 5. Press **SEND** 6. You should get status code *200*Optionally for curiosity you could retry info query to check if otaUnlock value now is true 5. Download the appropriate binary from http://ota.tasmota.com/tasmota/release and flash it. NOTE: The maximum firmware size is 508kb, which precludes the standard release binary. Absolutely do not use tasmota-minimal at this stage, this would brick your device.
!!! There are a number of reported issues with the stock firmware's OTA behavior, so it may be easier to use an existing server that works around these issues.
!!! Please note: if you have 3.5.0 or 3.6.0 firmware, maybe others (see version in /info
response), firmware has a bug: it connects to specified server, but always sends dl.itead.cn as server name. That is why you have to update from server that supports serving files with server name dl.itead.cn
* ota.tasmota.com
is NOT suitable for this. * Use sonoff-ota.aelius.com
or set up your local web server
$HASH
must be defined with the sha256sum
of the intended firmware file (the .bin
file) before running the curl
command. If using PowerShell, it is not necessary. !!! There are a number of reported issues with the stock firmware's OTA behavior, so it may be easier to use an existing server that works around these issues.
!!! Please note: if you have 3.5.0 or 3.6.0 firmware, maybe others (see version in /info
response), firmware has a bug: it connects to specified server, but always sends dl.itead.cn as server name. That is why you have to update from server that supports serving files with server name dl.itead.cn
* ota.tasmota.com
is NOT suitable for this. * Use sonoff-ota.aelius.com
or set up your local web server
$HASH
must be defined with the sha256sum
of the intended firmware file (the .bin
file) before running the curl
command. If using PowerShell, it is not necessary. For example:
# curl
HASH="5c1aecd2a19a49ae1bec0c863f69b83ef40812145c8392eebe5fd2677a6250cc"
curl -XPOST --data "{\"deviceid\":\"\",\"data\":{\"downloadUrl\": \"http://sonoff-ota.aelius.com/tasmota-latest-lite.bin\", \"sha256sum\": \"$HASH\"} }" http://$SONOFF_IP:8081/zeroconf/ota_flash
# powershell
$FW_URL = 'http://sonoff-ota.aelius.com/tasmota-latest-lite.bin'
$HASH = [BitConverter]::ToString([System.Security.Cryptography.SHA256]::Create().ComputeHash([System.Net.WebClient]::new().DownloadData($FW_URL))).Replace('-','').ToLower()
Invoke-RestMethod -Method POST -Body ('{"deviceid":"","data":{"downloadUrl": "' + $FW_URL + '", "sha256sum": "' + $HASH +'"} }') -Uri "http://$($SONOFF_IP):8081/zeroconf/ota_flash" | ConvertTo-Json
Or with the Rester browser extension:
1. Method: **POST** 2. URL: http://<*IP of your device*>:8081/zeroconf/ota_flash 3. Body: `{"data": {"downloadUrl": "http://sonoff-ota.aelius.com/tasmota-latest-lite.bin", "sha256sum": "5c1aecd2a19a49ae1bec0c863f69b83ef40812145c8392eebe5fd2677a6250cc"}}` 4. Header: **Content-Type** with value **application/json** 5. Press **SEND** 6. You should get status code *200*!!! Flashing can take up to few minutes, as device downloads firmware part-by-part. There is high risk of bricking device if you reboot it or if internet connection fails.
Note: If flashing is successful, a new tasmota-XXXXXXXX access point will be created.
Connect to this AP to configure Tasmota to connect to your WiFi network.
You're now ready to configure tasmota.