Basics project 109d How to flash SONOFF mini with Tasmota firmware


Basics: Project 109d

Project name:  How to flash SONOFF mini with Tasmota firmware

Tags: SONOFF Mini, SONOFF, Tasmota Firmware

Attachments: NONE

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1. Jumper for 2 pins 1 pc

jumper 2 pins

2. SONOFF mini 1 pc

sonoff mini

3. AC lamp power cord with switch 1 pc

sonoff mini

General

We will learn how to flash SONOFF mini with Tasmota firmware. The SONOFF mini is using the ITEAD manufacturer cloud solution and requires an online account. The purpose of this project is to release the SONOFF mini from this integration by replacing the original firmware with the Tasmota open source firmware. When you do that, you can easily integrate and control the switch in any open source home automation setup (home assistant or openhub, for example. (Please note when you do this your eWeLink app will not work with your SONOFF mini)

Understanding the Tasmota

Tasmota is an alternative firmware for ESP8266 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Written for Arduino IDE and PlatformIO.

It was initially written for Sonoff devices, but it supports devices from many other brands like Electrodragon, MagicHome, AriLux, Blitzwolf, and Allterco. You can also install it on development boards like the Wemos D1 mini and the ESP8266 NodeMCU.

You can read more about it here.

Understanding the SONOFF mini

This is a mini and compact DIY smart switch used for different kinds of switch boxes, even the smallest EU standard switch box. Convenient to automate your home appliances with eWeLink app through your smartphone or tablet or your voice command. Support to connect an external rocker light switch unable to automatically spring back for easily managing connected devices in your home, both on your phone or directly from the wall. It supports the DIY mode (designed for developers) which allows users to integrate MINI into worldwide third-party open source smart home control system to achieve LAN control without cloud service, such as Home Assistant, openHAB, ioBroker .etc.

Features:

  • Control your home appliances with the app.
  • Ask devices to turn on/off just by a voice command.
  • Set a time for devices to make it start or stop running automatically.
  • Allow developers to flash the firmware to access more features they want.
  • Support the rocker light switch to control devices (self-return switch not included).
  • Create smart scenes to trigger groups of SONOFF devices on/off via tapping on your phone.
  • Make an action to trigger another or receive a message alert to your phone.
  • Share the device with your family to control it together.
  • Check the device status change on your phone in real time.
  • Run the device on your phone albeit no normal Wi-Fi connection.
  • Keep the device in the status before power failure when the electricity system is restored.

Specifications:

  • Input: AC 100-240V 50/60Hz 10A Max;
  • Output: AC 100-240V 50/60Hz 10A Max;
  • Wi-Fi: IEEE 802.11 b/g/n 2.4GHZ;
  • Material: PC V0;
  • Dimension: 42.6X42.6X20mm;

You can download Quick Installation Guide, User Manual. You can read more about it here.

Tasmota can be flashed on this device via OTA using the Sonoff DIY feature.

Several free GPIOs are available. The OTA jumper pin is the most accessible and very easy to use on a pin header.

Signals and connections of the SONOFF mini

sonoff mini
Image credit: Tasmota
SONOFF mini
Image credit: Tasmota

GPIO0 – Button

GPIO1-TX

GPIO2- Available

GPIO3 -RX

GPIO4 – S2 (external switch input)

GPIO12 – Relay and red LED

GPIO13 – Blue LED

GPIO16 – OTA jumper pin

GND – S1 (external switch input)

Drawing

Step by Step instruction

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.

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. 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 3.1 or higher will also support it.

1.Preparation

1.Download and install the eWeLink App on your smartphone from Google Play or Apple Store. This App is necessary to connect the SONOFF mini to the SONOFF Cloud Service. You must register an account to connect to this service (it is free). We need to upgrade the original firmware from ITEAD in the SONOFF mini to version 3.3 (or higher) which is required to make Over-The-Air (OTA) updates to the firmware in DIY mode.

2.Connect a mains power cable to the SONOFF mini as described in the user manual.

sonoff mini

3.Connect your smartphone to a WiFi network using 2.4GHz and not 5GHz.

4. Launch the eWeLink App and register an account with their Cloud Service from within the App.

5.Connect the SONOFF mini to your mains power (220V or 110V AC). The SONOFF mini should immediately start up and go into Pairing Mode during first time init. This is indicated by the blue LED on the Mini flashing 2 short + 1 long blink repeatedly. The SONOFF mini stays in Pairing mode for 3 minutes. Then it gives up unless successfully paired. In order to put it into Pairing Mode again, unplug the mains, wait 5 seconds and re-apply power to it. Check the blink rate of the blue LED.

6.From your App, click the + icon at the bottom of the screen.

sonoff mini

7. You can select the first option Quick Pairing. If you tried Quick Pairing first, and it failed, then you need to reset both you SONOFF mini and your App before you try again with Compatible Pairing. When in Compatible Pairing: It is important the you follow the on-screen explanation on how to set the Mini into Compatible Pairing Mode.

sonoff mini

8. Type your local WiFi network name (SSID), and password which you use to connect to your local WiFi network. Please note – you can use 2.4GHz WiFi Network only. Click on NEXT button.

9.Searching for and finding your SONOFF mini may take a while.

sonoff mini

Hopefully it works for you, and you end up with a screen like this:

sonoff mini

10.Set the name of you SONOFF mini and click on COMPLETE button.

sonoff mini

11.Click on GOT IT button.

sonoff mini

12.You should be able to click the on/off button and actually hear (and see) that the SONOFF mini switches on and off.

13.Click on the text where is says SonoffMini in the middle of the big icon with the on/off button. The number following the device name may vary. You will be taken to the device page with a huge on/off button in the center of the screen. Use this opportunity to click on the on/off button just to make sure that the connection with your SONOFF mini is alive and OK.

sonoff mini

14.Let’s go to Setting. Click on the circle with three dots. Select Setting.

sonoff mini

15.It will take you to the Device Setting page. You will see which firmware version you currently have in your SONOFF mini (we have 3.0.0), and if an update is available (for example, we have version 3.3.0 with red dot>). Press on red dot and you will open another page NEW FIRMWARE. Press on GOT IT button.

sonoff mini
sonoff mini

16.Press on OK button.

sonoff mini

17.There is no progress bar or anything indicating that something is actually going on. So just be patient and wait until you done.

sonoff mini
sonoff mini

2.Getting ready for flashing SONOFF mini with Tasmota firmware

1.We are ready to disconnect SONOFF Mini from the SONOFF Cloud Account and put it into DIY mode. DIY mode allows you to control and use the Mini on your local network without an internet connection or a cloud account.

2. Make sure that your SONOFF mini is not connected to mains power. DISCONNECT MAINS POWER, WHEN MAINS POWER CONNECTED COVER BOX MUST BE CLOSED!

sonoff mini

3. Open the white cover and connect GND and OTA with the jumper which is included in the small plastic bag in the box. Fitting the jumper like this puts the Mini into so-called Do-It-Yourself (DIY) mode. This “mode” is only relevant while the original SONOFF firmware is still loaded. It is needed in order to be able to flash the Tasmota firmware Over-The-Air (OTA).

sonoff mini
sonoff mini

4.Close the white cover and prepare your SONOFF mini to connect to mains power. Blue wire (N, neutral) and Brown wire (L, live).

sonoff mini

5. You need to download the right Tasmota firmware file from GitHUB. It is extremely important that you choose the right file. If you try to flash an incorrect version, you will most likely corrupt the SONOFF mini and the only way to recover from that, is to manually flash using wired flashing with a FTDI USB-2-Serial board. Essentially, the Tasmota firmware you are aiming for, is the tasmota.bin with SONOFF mini DIY mode support. But regretfully, this file is too big to fit in the limited internal memory space of the SONOFF mini alongside the SONOFF original firmware (They both have to be in memory at the same time during flashing). So, you might think that it’s a good idea to instead use the tasmota-minimal.bin file. Do NOT attempt to flash the tasmota-minimal.bin file on the SONOFF mini as it does not allow you to change any settings. The file you should look for, is named tasmota-lite.bin. Go to Github and download the latest version of tasmota-lite.bin.

sonoff mini

6. Go to Github and download the Itead Sonoff Devices DIY Tools.

sonoff mini

6. You need to unzip this file. It will be folder Sonoff_Devices_DIY_Tools-3.3.0 inside. We will need the file tool_01DIY(v3.3.0).exe inside the subfolder tool.This file we will need later.

sonoff mini

7.The only way for this Tool to find the SONOFF mini, is if they are connected to the same WiFi network. The Sonoff firmware in the SONOFF mini is preprogrammed to connect to a network named (SSID) sonofDiy with a password – 20170618sn. And that is the only network it will connect to. So, you have to create a WiFi Hotspot with that particular name and password for the next step to work. There are several ways to do that. You can use your smartphone (iPhone or Android phone) or windows 10 OS.

On your Windows 10 OS:

  • Modify your PC configuration to provide a Mobile hotspot: SSID – sonoffDiy (case sensitive!); password – 20170618sn
  • Power on the SONOFF mini and verify that it shows up on the Mobile hotspot Settings page
sonoff mini

On iPhone:

  • Change the name of your phone. Go to Settings->General->About. Change Name to sonoffDiy
  • Go to Settings –> Personal Hotspot (Allow Others to Join must be selected, WiFi password set as 20170618sn)
  • Make sure your phone is connected to the internet over the Mobile Network.
  • Make sure the Hotspot you just created is a 2.4GHz network.

8. Then connect your Windows computer to the Personal Hotspot by going to the WiFi setting and choosing the network named sonoffDiy. When Windows asks you for the password to connect, just type: 20170618sn. You need to verify that you have an internet access.

9.Connect your SONOFF mini to mains power. It should automatically connect to the same Personal Hotspot that you just created on your smartphone. This is because the SSID name and password is pre-programmed into the SONOFF original firmware.

10.Double click on tool_01DIY(v3.3.0).exe file on your windows PC which is connected to the sonoffDiy network.Windows Firewall automatically pops up during first time run, because it detects that the app requires certain firewall permissions. But on computers where the app fails, Windows Firewall never popped up as expected. The Tool should automatically detect your SONOFF Mini.

DIY mode tool Tasmota firmware

11.Select the SONOFF mini and toggle it ON and OFF to verify you are connected to the right switch.

sonoff mini ON
sonoff mini off

Let’s test DIY mode. You need to find out your SONOFF mini IP address (use Advanced IP scanner program). – in our case it is 192.168.1.175.

advanced ip scanner

As we know the SONOFF expose its services on port 8081. According to the SONOFF DIY MODE Protocol Doc.pdf ON/OFF status JSON command is:

POST /zeroconf/switch
{
“deviceid”: ” 100098593f “,
“data”: {
“switch”: “on”
}
}

DIY mode

“deviceid” is found in DIY tool for your SONOFF mini. We can test it with REST Ape – Advanced API Testing Client extension of Google Chrome or you can download API testing tool here.

tasmota sonoff mini

12.Click on Brush machine button in the upper right corner.

DIY mode tool Tasmota

13.Click on Import Firmware and choose the downloaded Tasmota firmware – tasmota-lite.bin.

tasmota diy mode tool

14.Click on Flash device list and click on OK button. If everything works good, you will see the green progress bar growing from left to right.

tasmota diy mode tool
SONOFF MINI TASMOTA DIY MODE TOOL

15.If the firmware update gets stuck at 0%, the SONOFF mini could not reach the manufacturer server because your Personal Hotspot does not share the Internet connection. If this happens, use the DIY tool to set the SSID and password of your Wi-Fi network on the SONOFF mini. The device will connect to your network. Disable the Personal Hotspot and use your WiFi network for DIY tool laptop as well. Start Brush machine again, flash Tasmota. If the firmware update gets still stuck at 0% all you can do – try another computer with a different version of Windows, or play around with the Firewall settings in your PC in order to get the DIY Tool to reach through your internet connection to the Sonoff server in China. If you are totally out of luck, the server may be down – and you are stuck.

TASMOTA DIY TOOL SONOFF MINI
diy mode tool tasmota
TASMOTA DIY TOOL SONOF MINI

16. If all went well, which I certainly hope it did, you should get a pop-up message box. Click on Yes button. You’ll have no more need for it for now. Your SONOFF mini has now been successfully Tasmotized. Quit DIY mode tool.

tasmota sonoff mini
tasmota sonoff mini

17. Stop Personal Hotspot.

18.Once the firmware upload completes and the device restarts, power off the SONOFF mini and remove DIY jumper as it is no longer needed and might interfere with future Tasmota features that use GPIO16.

19.Power on the SONOFF mini again. The tasmota_xxxxxx-xxxx SSID should be available.

tasmoto sonoff mini

20.Connect to the tasmota_xxxxxx-xxxx network. Go to any web browser and type the http://192.168.4.1.

tasmota sonoff mini
tasmota sonoff mini

21.Now we can configure the Wifi network. Click Scan for networks and select your own Wifi network.

tasmota sonoff mini

22.Type your Wifi network password and click on Save button. The SONOFF mini reboots and connects your network.

tasmota sonoff mini

23.Use a program like Advance IP scanner to find the IP of you SONOFF mini or check your routers DHCP list.

tasmota sonoff mini

24.Type your SONOFF mini IP address in any web browser (in our case 192.168.1.149). The Tasmota GUI appears.

25.Click on Configuration. Then click on Configure Module.

tasmota sonoff mini

26.Set these Settings:

tasmota sonoff mini

Module type: Generic (0)
D3 GPIO0 Button1: Button1 (17)
D2 GPIO04: Switch1 (9)
D6 GPIO12 Relay1: Relay1 (21)
D7 GPIO13 Led1i: Led1 (52)

tasmota sonoff mini

27.Click on Save and the SONOFF mini will reboot.

sonoff mini tasmota

28. Congrats. Your SONOFF mini is ready for use.

Summary

We have learnt how to flash SONOFF mini with Tasmota firmware. We will show you how to flash SONOFF mini with Tasmota firmware using USB TTL converter in next project.

Thank you for reading and supporting us.

Libraries:

  • No libraries required for this project

Project resources:

  • See attachments on the beginning of this project description

AcoptexCom

Has one comment to “Basics project 109d How to flash SONOFF mini with Tasmota firmware”

You can leave a reply or Trackback this post.
  1. ปั้มไลค์ - 2020 June 2 Reply

    Like!! Great article post.Really thank you! Really Cool.

Leave a Reply

Your email address will not be published.