Skip to content Skip to sidebar Skip to footer

Sonoff Upload Firmware but Code Doesnt Work

Brand the Sonoff smart power controller even more awesome past installing the Tasmota open source firmware.

Tasmota adds many new features, and allows you to integrate Sonoffs into an existing dwelling automation system without relying on external deject services. It includes MQTT back up, Belkin WeMo emulation, easy configuration using a web browser, and you don't even need a compiler or IDE to install information technology.

Notation: Since this video was released, the Tasmota project has inverse its build process so that the binaries are at present called "tasmota" instead of "sonoff". I have edited the text instructions below to match, but screenshots and the video notwithstanding refer to the old proper noun.

  • Tasmota firmware
  • esptool helper utility
  • USB-to-Serial converter with 3.3V way
  • Sonoff Programming Adapter
  • Episode #30 well-nigh putting any Sonoff into bootloader manner

Footstep 1: Fix hardware for flashing

To load new firmware onto a Sonoff, you lot need four pieces of hardware:

  1. A compatible Sonoff model or equivalent (more than than 50 devices are supported by Tasmota)
  2. A USB-to-Series converter that can run in 3.3V mode (don't use a 5V converter!)
  3. Jumper wires or a programming adapter to connect the USB-to-Series converter to the Sonoff
  4. A computer with WiFi. You tin employ a mobile phone for the WiFi steps if you prefer.

You can make the connections using jumper wires and the instructions in my previous video, or yous tin utilize my handy little programming adapter. Both methods practise exactly the same thing: my programming adapter just makes information technology neat and piece of cake.

Make certain the Sonoff is totally disconnected from any mains power.

Don't proceed unless you have washed that! Connecting your reckoner to a Sonoff while it is continued to mains is extremely dangerous.

Details of the electrical connection are shown in the previous episode, so check that out if you need more information.

Stride two: Download Tasmota

The Tasmota firmware and its documentation is available at github.com/arendst/Sonoff-Tasmota, including both firmware and pre-compiled binary releases. If you lot desire to compile the code yourself that's fine, but you don't need to if you just want the latest version. The binary releases are at:

 github.com/arendst/Sonoff-Tasmota/releases

At that place is a big list of binaries for each release, which tin be confusing if yous don't know which ane you need. The binaries fall into several categories which are outlined on the releases page.

For well-nigh devices, you should choose the binary called "tasmota.bin" which includes all the features required for the majority of compatible hardware.

The binaries with 2-letter country codes appended, such as "tasmota-Information technology.bin", take the exact aforementioned functionality equally the standard "tasmota.bin" simply with different languages for the user interface. If you want to run Tasmota in a language other than English, select the appropriate "tasmota-XX.bin" file.

Whichever version y'all select, download information technology to your reckoner.

I prefer to rename the binary file so that it includes the release version, such as "tasmota-8_4_0.bin". That style if I come back to it later on, I can see what version I downloaded.

Step iii: Download and install esptool

Esptool is a utility that can be used to read and write the flash retentiveness on devices using the ESP8266 and ESP8285 microcontrollers, including all current Sonoff models. Information technology's written in Python and so you will need a working Python environment on your computer.

You tin can download esptool from github.com/espressif/esptool.

Follow the instructions on that page to install information technology on your computer.

Step iv: Notice serial device

Your USB-to-Serial converter connects to your reckoner by USB, and appears to the reckoner as a virtual serial port. The exact location of the virtual series port will vary depending on the blazon of converter that you have, what operating arrangement you apply, and which physical USB port you plug the converter into.

If you accept the Arduino IDE installed, a expert way to find the location of the virtual serial port is to start the IDE, look at the ports listing in Tools -> Port, and so plug in the converter and bank check the ports listing over again to see if a new port has appeared.

On my Mac, the port appeared at /dev/tty.usbmodem14201, so I'll use that in the following examples.

Stride 5: Put Sonoff into bootloader style

Disconnect power from the Sonoff, hold the GPIO0 pin low, and reconnect power. And then release GPIO0. This process is explained in detail in the previous video.

This will put the Sonoff into a mode where it waits for new firmware to exist loaded.

OPTIONAL Step 5b: Support original firmware

If you want to make a backup of the original firmware and so you can restore it dorsum to manufacturing plant-original later, leap to the annex nearly the bottom and so return here. Otherwise, behave on!

Step half dozen: Upload the Tasmota firmware

Open a concluding, and go into the directory where you take the Tasmota binary. Use esptool to push information technology to the Sonoff using the serial port location that yous found earlier:

esptool.py -p /dev/tty.usbmodem14201 write_flash -fs 1MB -fm dout 0x0 tasmota-8_4_1.bin
  • The "-p" parameter sets the series port
  • The "write_flash" command tells esptool to transport new data to the flash memory
  • The "-fs" parameter is the flash size. Put this parameter in if you know it. If you don't, you tin omit this parameter and esptool will try to car-detect the wink size for you
  • The "-fm" parameter is the flash mode to utilize
  • The "0x0" parameter tells esptool to start writing into flash from address 0
  • The final argument is the binary paradigm to load

Uploading the binary takes virtually 30 seconds.

While esptool is doing the upload it will written report useful information almost the hardware in your Sonoff, including the MAC address. This can be extremely useful if you want to put a DHCP static lease into your router fix your Sonoff to a specific IP accost. You can re-create and paste the MAC accost out of the terminal and save it in a document or spreadsheet for future reference if yous desire to.

Step seven: Connect to Sonoff via WiFi

Disconnect the Sonoff power ability, then reconnect it. When the Tasmota firmware starts up and doesn't find any existing configuration, it goes into a setup manner and creates its ain WiFi network. The network will have a name similar to "Tasmota-6392", with the iv digits based on the last part of the unique MAC address of the Sonoff hardware.

On your calculator or smartphone, go into WiFi settings and look for a network with a name similar to this. Make a note of the network name, because you volition demand it in a moment!

Connect to the Sonoff's WiFi network without any username or password. Your computer should then automatically open a captive portal, with a WiFi configuration screen for the Sonoff.

Enter the WiFi settings for your normal network into the Sonoff. You can enter them directly, or you can click the "Testify wifi networks" link to accept the Sonoff scan for available networks so that you can select the right one and and so enter the password manually.

Enter the details, and click "Relieve".

The Sonoff will then reboot and attempt to connect to your normal WiFi network.

This will cause your figurer to drop off the temporary WiFi network that was created by the Sonoff, and reconnect to your normal network.

Step eight: Connect to Tasmota configuration interface

Open up a web browser, and enter the address of the Sonoff using the network proper noun that yous noted in Stride seven with ".local" added to the end. For example, the accost could be something like

tasmota-6392.local

This will open a configuration interface where you can view data nigh the device, change its settings, fill-in and restore the configuration, install firmware updates, and command the output.

Many of the configuration options are explained in the video. Explore the menus and prepare the Sonoff to suit your dwelling automation arrangement.

Addendum: Reconfiguring from scratch

If your home WiFi changes or yous have the Sonoff to another location, information technology volition go on trying to connect to the network that you originally configured and you won't exist able to control information technology.

If this happens, y'all don't need to re-flash Tasmota. Instead, you can put information technology into WiFi recovery mode.

Tasmota tin use the button on the Sonoff to put it into special modes. If you quick-press the button four times, information technology volition restart the setup process and create its own WiFi network again just similar in pace 7. And so you tin can connect to its WiFi, and give it new details then information technology can connect to your main WiFi network again. Your other settings will exist retained so you don't need to set them again.

If yous press and hold the button for more than than xl seconds, Tasmota will clear all its settings, reboot, create a WiFi network, and begin the setup procedure from scratch.

Other things y'all can do with the button are explained at github.com/arendst/Sonoff-Tasmota/wiki/Button-usage

Addendum: Backing upwardly and restoring original EWeLink firmware

If you want to go on the pick of returning the Sonoff to mill-original condition, yous tin download the original firmware out of its flash retentiveness and salve it for later use. Obviously this has to be done BEFORE you flash Tasmota onto it!

Do everything up to Step 5, only DON'T continue with Stride 6. Instead, use esptool to determine the flash size of the Sonoff. Using your ain serial port address, run a control similar this:

esptool.py -p /dev/tty.usbmodem142101 flash_id

This will give a result that looks something similar this:

jon@Jonathans-MacBook-Pro:~/Downloads$ esptool.py -p /dev/tty.usbmodem142101 flash_id
esptool.py v2.6-beta1
Serial port /dev/tty.usbmodem142101
Connecting….
Detecting flake blazon… ESP8266
Scrap is ESP8266EX
Features: WiFi
MAC: dc:4f:22:2b:c8:63
Uploading stub…
Running stub…
Stub running…
Manufacturer: e0
Device: 4014
Detected wink size: 1MB
Hard resetting via RTS pin…

You lot can see the result "Detected flash size: 1MB" near the end.

The Sonoff will have reset back into normal fashion, so put it back into bootloader manner in the usual style, then use a command like this to download the existing flash memory and save it in a local file:

esptool.py -p /dev/tty.usbmodem142101 read_flash 0x0 0x100000 sonoff-ewelink.bin

Pay attending to the value "0x100000" above. That instance will read the flash starting at address 0, and continuing on to the 1MB bespeak. If you lot have a 2MB flash, you'd use "0x200000", for instance.

On my laptop, information technology looks like this:

jon@Jonathans-MacBook-Pro:~/Downloads$ esptool.py -p /dev/tty.usbmodem142101 read_flash 0x0 0x100000 sonoff-ewelink.bin
esptool.py v2.6-beta1
Serial port /dev/tty.usbmodem142101
Connecting….
Detecting bit type… ESP8266
Chip is ESP8266EX
Features: WiFi
MAC: dc:4f:22:2b:c8:63
Uploading stub…
Running stub…
Stub running…
1048576 (100 %)
1048576 (100 %)
Read 1048576 bytes at 0x0 in 94.0 seconds (89.2 kbit/s)…
Difficult resetting via RTS pin…

After information technology's finished, you will take the original flash memory saved on your calculator in a file chosen "sonoff-ewelink.bin".

So continue with installing Tasmota.

Later, if y'all change your mind and want to put the original firmware back in place, you can follow the normal steps for installing Tasmota only instead employ the file y'all saved. The control will expect similar to this, only with your serial port address substituted:

esptool.py -p /dev/tty.usbmodem142101 write_flash -fm dout 0x0 sonoff-ewelink.bin

farquharyesectood.blogspot.com

Source: https://www.superhouse.tv/31-sonoff-tasmota-installation-and-configuration/

Post a Comment for "Sonoff Upload Firmware but Code Doesnt Work"