SonOff DIY Mode - OTA Unlock & Convert to Tasmota - Automated

Picked up some of the new Sonoff Mini’s recently with the plan to build them into some light switches. Consensus is that the stock ewelink firmware leaves a bit to be desired, but their new DIY mode does make it doable to OTA unlock & re-flash - with a few hoops. Also varying warnings that their Windows app triggers some antivirus warnings for unknown reasons.

Found a couple of reasonably comprehensive guides on doing it manually without using the App, including the following two, but it’s pretty roundabout and time consuming.
https://www.sigmdel.ca/michel/ha/sonoff/sonoff_mini_en.html
https://blog.mx17.net/2019/12/03/software-install-of-espurna-on-sonoff-mini/

Long story short - I used tuya-convert recently to convert some cheap hardware store wifi plugs to tasmota - quite a tidy package and process. Also this week had another 6 sonoff mini’s arrive that I wanted to convert as well, so I re-wrote some of the functions, and added a few of mine own to automate the process in tuya-convert fashion. :slight_smile:

sonoff_diy_convert.zip

They still need to have the diy/ota mode jumper fitted refer earlier links for photos, but it’s a whole lot easier than re-soldering them.

If it’s of use to people, you’re welcome to use it. There’s a few bits where the code isn’t as tidy as it could be, but it works, so that’s good enough for me. Install it alongside a tuya-convert install on a pi or similar and it’ll do the device id read, ota unlock, and reflash the firmware all a bit under a minute.

Enjoy. :stuck_out_tongue:

EDIT: Copy of the readme file from the zip below so you know what to expect.

# Jp - jpwise - 20200111 - sonoff diy convert tools building on tuya-convert functions.
# tuya-convert - all credit for their work to the original authors
# https://github.com/ct-Open-Source/tuya-convert

A packaged set of scripts to make converting SonOff DIY modules on linux easy.
Runs on top off the tuya-convert project package.
 - add on scripts to obtain mDNS device ID's
 - updated wifi config for snonffDiy config
 - enable IP forwarding + Masquerade for OTA unlock
 - automate SonOff otaUnlock requests 
 - uses tuya-convert bundled firmware files.

No guaranatees, express or implied - if it breaks things for you, you're on your own.
Testing done using a raspberry pi using eth0 LAN, and enables wlan0 for OTA functions.

Installation - same as tuya-convert
# git clone https://github.com/ct-Open-Source/tuya-convert
# cd tuya-convert
# ./install_prereq.sh

Additional package - pip3 zeroconf - mDNS functions.
#python3 -m pip install zeroconf

Extract contents of zip into tuya-convert folder alongside existing files.
Then start the flashing process  :)
# ./start_flash_sonoff.sh

There's a few areas that could probably be tidied, but it works, and that was the goal.
1 Like

Cool
Will give it a try next week :grinning:

Let me know how you go. I couldn’t find anyone else who had published scripts to automate it yet, so I made my own. It also enables IP masquerading/NAT on the RPi so the sonoff can access the internet during the unlock stages, and then uses the existing python webserver the tuya project has to serve the tasmota (or in theory espuna) firmware they bundle.

After that it’s just connect to your wifi network as usual, reset 5 & update tasmota, and complete configuring the template, and MQTT, etc.

FYI: For anyone else who buys a few SONOFF Mini’s and comes across this… it doesn’t work anymore if you upgrade your device firmware to 3.5. After spending a day trying to get this to work, and then trying the details in the linked articles, I finally went to try the Windows DIY tool where I found… ugh!

With 3.5, you get SONOFF’s “DIY Mode Protocol 2”… and everything has changed. See here -> https://github.com/itead/Sonoff_Devices_DIY_Tools

Looking at the DIY Mode Protocol 2 stuff, it looks like the main change has been go to back to hosting an AP like the original SonOTA stuff did.
At a glance there would be a few ways to accomodate the changes, it’s been ~5 months since i did the original work and i haven’t touched it since i updated the units I had. I don’t think I managed to fudge the otaUnlock and it still needed to go online for that, but it should be easy enough to automate in a few ways.

The most straightforward thought, and a good first test, would be to manually connect to the
ITEAD-xxxxxxx network with password 12345678, and then browse to the http://10.10.7.1/ address to configure. Set it to connect to the old style sonoffDiy network using password 20170618sn - that should put it into a state pretty much the same as the earlier versions where it’d then connect, and be able to do the OTA unlock and FW update.

If you still have any units running the 3.5 sonoff FW did you want to give it a try and let me know? You’ll need to have the script running and broadcasting the sonoffDiy network when you do it, otherwise it’ll revert back to creating the ITEAD-xxxxxx network after ~20 seconds according to the documentation.

Thx.

I tried this and get as far as the message asking to connect to SSID sonoffDiy but the SSID never appears on my mobile phone. I’ve tried multiple times. Even tried manually adding the SSID but nothing. Any suggestions? The wlan0 is definitely working as I can run the regular tuya-convert without any issues and I’ll get the vtrust SSID every time.

Just did a git pull on the latest tuya package and the script still creates the sonoffDiy AP in my testing.
If you run it and then hit ctrl-c at the message saying to connect, can you go have a look at scripts/smarthack-wifi.log and see what’s in there? Does it show any errors, or does it say the AP was created?

Thanks for checking it. Before I got your response, I messed around with it a bit more before giving up. I then discovered that Sonoff has simplified the process with their DIY Tool, no longer requiring the jumper with the latest firmware, so I just ran with that. It wasn’t a fautless process but I managed to get my two Sonoff SV devices converted. I’ll give your script another go if I get any more Sonoffs. Thanks again.

1 Like