Getting Started with Tasmota and Introduction to Tasmota Templates
Tags: esp8266, iot, beginners
Published: 2022-09-14 15:00:13

##What is Tasmota?
Tasmota is an open-source firmware created by Theo Arends for smart home devices using the ESP wifi chip. Tasmota is very common and is compatible with various smart home platforms such as TUYA, Google Home, Home assistant etc. In the course of this article, you will be introduced to Tasmota and its most basic functionality, templates and how to create your own template.


##Installing Tasmota to your ESP WiFi chip
For this article, I will be using the node MCU ESP8266 chip. First, we will have to download the firmware. Here are the links to download the Tasmota firmware.

- [Tasmota.bin](https://drive.google.com/uc?export=download&id=1f3-QKQrIE3AC1qu4HVPNiGXSrWKsczbJ) 

- [Tasmota IR](https://drive.google.com/uc?export=download&id=1INBGJufvj8Sx-KFV7OHEL4J81rnQwbRy)

- [Tasmota Display](https://drive.google.com/uc?export=download&id=1vouIxSx3odEYwV7P6RZx2or3fcwFsBzN)

To download the .bin file directly from tasmota click [here](http://ota.tasmota.com/tasmota/)

There are several ways to install Tasmota to your esp board but my favourite way is to use esptool, to use esptool you need python installed on your computer. After installing python open your computer terminal and type in 

`pip3 install esptool`

After the installation type in the following command in the terminal

`esptool.py --port [com port] erase_flash` this is to erase the flash memory.

```
esptool.py --port [com port] write_flash -fs 4MB -fm dout 0x0 [location of .bin file]
```

replace the part labelled com port with the com port your board is connected to and the part _location of .bin file_ to the location of the .bin file. 
Yours should look something like this if you use Linux

```
esptool.py --port /dev/ttyUSB0 write_flash -fs 4MB -fm dout 0x0 /home/pius/Documents/tasmota/tasmota.bin
```

For more information on flashing tastmota to esp boards visit [here](https://tasmota.github.io/docs/Getting-Started/#flashing).

## Tasmota Setup
After installing Tasmota to your board, go to the wifi settings on your laptop or mobile phone, you should see a WiFi device named tasmota.

![Tasmota WiFi](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/704bwlyhij5s6j178ilx.png)

Connect to it and a config page should pop up on your screen, if you don't see a pop up, plug your board to your PC if it not already plugged in and open up Arduino IDE or any serial terminal. Open the serial monitor in Arduino and chose 115200 baud rate, then connect to your board and press the reset button on your micro controller board, you should see the the IP address on the serial terminal. Like this


![Arduino Serial Terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9q4xac8mofjg9odxb2rc.png)

After gaining access to the config page input your router's credentials and click save.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6fb4ykh1dwe7t7pmg6c3.png)

If the connection is successful, you should see a new IP address on the serial terminal. connect back to your router and type in that IP address in your browser. If the setup was successful you should be greeted with a page like this

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x927elba50l9mpoahxj0.png)


## Tasmota Templates
 Normally when using ESP8266 you would have to write code to make it do stuff for you,but with Tasmota templates you just have to set certain parameters and you are good to go.

To get started, on the home page click on Configuration and then Configure templates. You should have something like this on your screen. 

![Configure templates](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5fsgkz9nvdg062aq57q3.png)

In the _name_ text-box you can put any name you want, in the  _based on_ drop-down, you are to choose a device in which your template will be based on, but for this article we would use **Generic**. If you click on any of the drop-downs for any GPIOs you would see things like buttons, Led, PWM etc. The scope of this article will only be covering buttons, Leds and relays.

### Buttons
Buttons are simply physical inputs, so if I wanted to control the onboard LED connected to GPIO2 via the  flash button connected to GPIO0 on the ESP8266, my template configuration would be like this.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o7720jockhc2kasrd1sa.png)

From the image, you can see I choose button 1 and led 1, this means that if you want a particular input to control an output, in this case our LED, the led and the button must have corresponding numbers. The same applies to relays also. After selecting the correct button and led click on _save_ to save the template, but we aren't done yet, we still have to activate our template. After the template has been saved you should a button _main menu_ click on it to go back to the home page. In the home page click on configure and then click on configure other. If you followed the steps correctly you should see be seeing this.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bpra1ekxgkr7ytrigwid.png)
 
check the activate box in the template section to activate your template and click save

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6x5gmxbct3njxmbegnfk.png)

Now when you are back at the home page press the GPIO0(flash button on your ESP8266, the onboard led should toggle.


{% embed https://youtu.be/BdirjxhbKZc %}

### Relay
Relays works the same way as buttons but they are virtual; If you choose a relay instead of a button a virtual button will appear on the home page which we can use to toggle an led. Set up your template like this

![set up relays](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t6gzqffbuvospmu7y2ve.png)

then when you go to the home page, you should have something like this


![virtual button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ghwlg6ws42xbgxzd5u9r.png)

Here is a video demonstration

{% embed https://youtu.be/Zi1TfDyssds %}

for more information on Tasmota templates click [here](https://tasmota.github.io/docs/Templates/)

## Tasmota pre-built templates

> Making things easy is hard _ted nelson_ 

Someone put in a lot of hard work to create a repository containing various templates for esp8266 based smart devices, so we have a bank of ready-to-use templates to make using Tasmota easier. To access the site click [here](https://templates.blakadder.com/). Let me walk you through on how to use the pre-built templates.

- On the site click on development boards

- Scroll to Adafruit HUZZAH ESP8266 Development Board and click on it

- Copy the configuration from the web page 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vmgu13tzlngprvuv44lt.png)

Then go back to the config web page of Tasmota and navigate to _configure other_ and paste the configuration you copied into the template text box and click save.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tacm8cic0uz1fgwga13y.png)

Now when you press the GPIO 0 (flash button) on the ESP8266 the LED will toggle.

You can apply this same steps to other templates in the repository.

Tasmota makes it very easy to build a home automation system without code, imagine turning your regular home into a smart home without writing a single line of code or starting a business with it. So try out Tasmota today and thanks for reading.