Skip to main content
shopping_basket Basket 0
Log in

A First Look at Tasmota Open Source Firmware for ESP Devices

IoT devices based on ESP Device

Firmware provides an open alternative for IoT devices based on ESP8266 and ESP32.

The Internet of Things (IoT) can bring great convenience and efficiency even when used to implement home automation, which might control heating and lighting according to complex schedules and by detecting room occupancy, for example. However, IoT can equally be a cause of much anguish and expense when a vendor goes out of business and their cloud platform goes offline, rendering devices useless. Not to mention that sometimes there may be perhaps two or three different parallel systems in use, with a lack of interoperability hindering integration.

Fortunately, there are solutions available for the technically minded, such as Home Assistant, a highly configurable open-source home automation platform — and Zigbee2MQTT, a vendor-agnostic open-source Zigbee gateway. In this article we take a look at Tasmota, an open-source firmware that may be loaded on compatible WiFi enabled IoT devices, entirely replacing the vendor firmware and making integration with Home Assistant and other platforms trivial.

Warning!

It goes without saying that replacing vendor firmware will almost certainly void warranties and furthermore, product certification also — including safety! Therefore re-flashing devices should not be attempted unless fully aware of all the potential risks and entirely comfortable with these. Mains powered and mains switching equipment, in particular, may present the greatest risk, with the potential for electrocution and fire, hence should only ever be worked on by suitably competent persons.

Note that a small number of specialist vendors appear to be now offering Tasmota firmware as standard and this route may be a safer option for some.

Disclaimer: this is not a how-to guide and for detailed information see the Tasmota project and/or vendor documentation. No responsibility will be accepted for damage or injury etc. resulting from modification of devices or use of the Tasmota firmware.

Features

Tasmota Logo

Tasmota is supported on ESP8266, ESP32, ESP32-S or ESP32-C3 based devices and recently celebrated its 6th birthday, with the first commit being back in January 2016 for what was then the Sonoff-MQTT-OTA project, which provided basic MQTT control for a particular Sonoff brand switch. At the time of writing however now boasting support for no less than 2,266 devices and these range from ESP-based development boards and switches, through to lighting fixtures, curtain motors and household appliances such as dehumidifiers, heaters and kettles.

The extensive list of Tasmota features includes support for ADC input, buttons and switches, displays, numerous sensor and other peripherals, OpenTherm protocol, rules, scripting and more. At its simplest, it provides a web interface that allows status to be read and outputs toggled, with an MQTT interface that also enables integration with custom applications. Although support is provided as standard for Alexa, AWS IoT, Domoticz, Home Assistant and other platforms.

Sonoff S26R2 smart plug

Next, let’s take a look at a practical example with a Sonoff S26R2 smart plug.

Flashing

Programming a USB UART

The Tasmota documentation goes to great pains to note that mains powered devices must not be plugged in during flashing, as this would present a significant risk of electrocution. Instead, the ESP microcontroller power is supplied during programming by a suitable USB UART, which must feature a discrete voltage regulator capable of supplying 3.3v with sufficient current.

One device suitable for programming is the USB UART Click from MikroElektronika (882-8913) . This is based on the FTDI FT232RL plus an AP7331 300mA LDO, featuring a zero-ohm jumper which can be used to configure for 5v or 3.3v I/O, with the latter as the default.

UART was cabled to Sonoff S26R2 smart plug

The UART was cabled up as per the Tasmota documentation.

There are a number of options when it comes to flashing the firmware and these include a web installer that works with the Chrome browser and a dedicated tool, Tazmotizer. The latter has the benefit of first automatically backing up the existing, e.g. vendor, firmware. Another option is to simply use Esptool, the official flashing tool from Espressif. This was installed on Linux with:

$ sudo pip3 install esptool

Following which the vendor firmware was first backed up.

Vendor firmware being backed up

Next, the flash was erased.

Flash was erased

Finally, the Tasmota firmware was flashed.

Tasmota firmware was flashed

It should be noted that there are multiple different build variants available and for details see the Tasmota documentation.

Basic use

Tasmota - Wi-Fi Selection screen

Once the device is reassembled and powered up, the Tasmota firmware enables a WiFi access point, allowing you to connect to its web interface and enter the WiFi network details.

now possible to toggle the power status via the main menu

With the setup out of the way, it’s now possible to toggle the power status via the main menu.

configuration options

There is no shortage of configuration options and Tasmota can be set to simply use a timer for control, in addition to being driven via MQTT and platforms such as Domoticz. It’s also possible to configure logging to a remote syslog server, for example.

MQTT configuration

The MQTT configuration options can be seen above, which allow the broker to be specified, along with authentication details and optional topic formatting.

Tasmota device come online and report its status

By using mosquitto_sub to subscribe to topics on the broker we can see the Tasmota device come online and report its status.

send a message to toggle the power off

Using mosquitto_pub in another window, we can then send a message of “off” to toggle the power off, with the message itself shown above, followed by Tasmota reporting the state change.

For further details see the Tasmota MQTT documentation and also the Smart Home Integrations documentation, which shows how Tasmota devices may be integrated with popular platforms such as Home Assistant, openHAB, Domoticz and others.

Conclusion

Tasmota provides a powerful, flexible and extensible open firmware alternative for supported devices, which makes integration with advanced, custom and local control — not cloud dependant — platforms possible. It appears as though some small vendors are starting to offer Tasmota pre-installed as a standard device firmware, which will hopefully become more commonplace, as this would remove the need to dismantle devices in order to re-flash them, while additionally meaning that warranties and product certification are not invalidated.

Andrew Back

Open source (hardware and software!) advocate, Treasurer and Director of the Free and Open Source Silicon Foundation, organiser of Wuthering Bytes technology festival and founder of the Open Source Hardware User Group.
DesignSpark Electrical Logolinkedin