How To Flash Tasmota With Mac/Linux Terminal: Wemos D1 Mini

Disclosure: Some of the links on this site are affiliate links. This means that, at zero cost to you, I will earn an affiliate commission if you click through the link and finalize a purchase. This helps support my work, thank you!

The Wemos D1 Mini is an incredible little device and you can pick one up for less than the cost of a beer.

There is a wealth of documentation online and it is very easy configure. Best of all it has a USB port so it is very easy to flash.

If you want to flash an ESP based device without a USB port, check out this tutorial. Alternatively some devices can be flashed over the air, without soldering!

Tasmota is an awesome concept and adds great cloud-free functionality to your smart home devices. It’s lightweight and versatile firmware designed to run on ESP devices.

It has support for many smart home functions, including many of the more commonly used sensors.

Best of all it’s absolutely free!

Table of Contents

  1. Requirements
  2. Prerequisites
    1. Installing ESPTool
    2. Download the latest Tasmota binary
  3. Flash the D1 Mini
  4. Configure Tasmota
    1. Find the Tasmota device IP address
    2. Access the Tasmota configuration menu
    3. Configure MQTT

Requirements

  • A computer with a Linux/OSX
  • A Wemos D1 Mini
  • USB cable
  • Python 2.7 or 3.4+
  • Sensor/Switch/LEDs (optional)

Prerequisites

In terms of hardware it is very simple to flash the D1 Mini. There is a USB to serial chip built into the D1 Mini, so when you connect it to the USB port the computer sees it as a serial device. Simply connect your D1 Mini to an available USB port.

In order to flash the Tasmota firmware on to the D1 Mini we will use a software tool called ESPTool. This tool is Python based and therefore you should first install Python and pip if you don’t already have it.

Enter the following command to check your default Python version, this will also indicate if you do not already have Python installed as the version will not be returned.

python --version

Installing ESPTool

The easiest way to install ESP tool is to use pip. Simply enter the following command to install the dependancies.

pip install esptool

If you receive an error you may need to specify the version of pip, go ahead and try either of these commands instead.

pip2 install esptool
pip3 install esptool

If you still receive an error, there is another option given on the ESPTool Github page that you can try.

python -m pip install esptool

Once the ESPTool dependancies have been installed, we need to navigate to the directory where we would like to install the ESPTool script. I will install to ~/Documents for simplicity but you can choose any location.

cd ~/Documents

Then we need to clone the Git repository so go ahead and enter the following command.

git clone https://github.com/espressif/esptool.git

This will install the script in to your chosen directory.

<your-directory>/esptool/

So in my case it is now installed in my documents folder.

~/Documents/esptool/

Download the latest Tasmota binary

Now that we have ESPTool installed, we need a copy of the latest Tasmota binary. You can download the tasmota.bin file from Github.

You can save the file to any location of your choice, but I would recommend placing it in the same folder as the esptool.py script.

~/Documents/esptool/tasmota.bin

Alternatively if you are using a Linux build without a GUI, you can get the download link from the alternative source and download it with curl. This command should work so long as the link isn’t broken! In which case you will need to amend the link in this command.

curl http://thehackbox.org/tasmota/release/tasmota.bin --output tasmota.bin

Flash the D1 Mini

It is time to flash the D1 Mini! Go ahead and connect it to your computer with a USB cable. The D1 Mini will appear to the computer as a serial USB device and first we must locate it by entering the following command.

ls /dev/tty*usb*

In the output, look for the USB serial device. You might want to copy and paste or make a note of it for using with ESPTool during the flashing.

Mac Terminal

Linux Terminal

Tip: If you have several devices, you can run the command with and with the D1 Mini connected, then run it without the D1 Mini connected and take note of the device that is no longer present. This will be the D1 Mini.

Now that we have the device name, we are ready to start flashing. The first step is to erase the flash memory in order to prevent any problems. Firstly, make sure you are in the ESPTool directory.

cd <your-directory>/esptool/

Next we can run the ESPTool script and erase the flash memory, go ahead and enter the following command.

sudo ./esptool.py --port <your-device-port> erase_flash

I am currently using Linux to flash the D1 Mini, therefore the command that I need to enter is as follows.

sudo ./esptool.py --port /dev/ttyUSB0 erase_flash

The script will confirm once the erase operation has completed successfully. The D1 Mini is now ready to be flashed with Tasmota.

The command that we will use to flash Tasmota is as follows.

sudo ./esptool.py --port <your-device-port> write_flash -fm dout 0x0 <path-to-tasmota>.bin

As I am using Linux, my device will be ttyUSB0 and my tasmota.bin file is in the same directory as esptool.py. If your .bin file is in a different location, enter the complete path.

In my case, the following command will flash Tasmota to my D1 Mini.

sudo ./esptool.py --port /dev/ttyUSB0 write_flash -fm dout -fs tasmota.bin

Flashing can take a minute or two so perhaps go get yourself a nice cold beverage. Once complete the script will confirm verification.

Congratulations! You have now flashed your D1 Mini with Tasmota and your new Tasmota device should be showing as a WiFi device.

Configure Tasmota

Now that our Tasmota device is showing as a WiFi access point, we can connect to it. Once connected a pop-up will appear that will allow us to choose our router and enter the password for our network.

Click on Scan for wifi networks, select your network, enter your password and click save.

After a few moments your Tasmota device will disconnect from WiFi. If your computer does not automatically reconnect to your router, you can now reconnect.

Tasmota should now be connected to your router and we can access it in the web browser to complete the configuration.

Find the Tasmota device IP address

The easiest way to to find the IP address of your new Tasmota device is to look for it in your router management page. You can usually access this page by navigating to some local IP address like http://192.168.1.1 but it is device specific, therefore you should consult the manual for your device.

In my case I am currently using the stock router supplied by my ISP and navigating to http://192.168.1.254 brings me to the management page. Here I am able to see the new Tasmota device and its IP address, 192.168.1.129.

In my case it is not always obvious which is the new Tasmota device, but usually the first time the device is visible on the management page it has no name. All of the other devices have names, therefore I know this is the new Tasmota device.

Alternatively you can use a third party application like Fing to find the IP address if you don’t have the facility on your router.

Access the Tasmota configuration menu

Now that we know the IP address of the new Tasmota device, we can navigate to it in a browser in order to access the configuration menu. In my case it will be http://192.168.1.129 but you should use your own IP address here.

Firstly click Configuration to access the main configuration menu.

Next we need to click Configure Module to tell Tasmota how we want it to control our D1 Mini. Select Generic (18) as the module type and click save.

You will need to wait for Tasmota to restart before you observe the changes.

The options that you select for the IO ports are application specific so it really depends what you would like to do with your D1 Mini. I am guessing you already have a good idea and will know what to select here!

The module that I am using to create this tutorial is actually going to be used as a temperature sensor in my Home Assistant setup. I have the DHT11 sensor connected to D4, therefore I can select it in the box for D4.

Tip: Tasmota is also compatible with the DHT22 sensor, but you need to select SI7021 (3) as it uses the same protocol.

Configure MQTT

Finally we need to configure MQTT so that the device can communicate with the outside world. This really needs a tutorial of its own and I plan to write one. For the moment we will just cover the basic setup.

Enter the IP address and port for your MQTT broker. In my case this is the IP address of my Home Assistant server.

Enter the user name and password for your MQTT broker. If you are using Home Assistant and its MQTT plug-in, it will be the same as your admin login.

Enter a name for the device under topic, without spaces. Then click save and allow Tasmota to restart.

If you are configuring your device for Home Assistant and you want the device to be discoverable, you can enable this in the console.

From the main menu, click on console to bring up the Tasmota console for the device. Enter the following command and wait for the device to publish the information.

SetOption19 1

You may need to wait a moment as Tasmota publishes a series of messages. Once complete you will be able to discover your D1 Mini in Home Assistant.

Congratulations for making it to the end of this tutorial! I hope that it helped you get Tasmota up and running on your D1 Mini. For further information check out the Tasmota setup guide, and please check out some of my other cool tutorials!

2 responses to “How To Flash Tasmota With Mac/Linux Terminal: Wemos D1 Mini”

  1. Doug Henningsen Avatar
    Doug Henningsen

    First timer….working toward your WiFi Temperature Sensor. Everything above worked perfectly until “Access the Tasmota configuration menu”. I type in the IP address in Chrome and get “This site can’t be reached 192.168.0.4 took too long to respond.”
    Alternate steps:
    – no luck on Edge, Firefox
    – tried HTTP & HTTPS
    – Confirmed IP address by plugging/unplugging the device
    – Turned off MS Windows Defender Firewall on private and public networks
    – Said Abracadabra in hopes of summoning my magical powers

    Open to any suggestions.

  2. Doug Henningsen Avatar
    Doug Henningsen

    Backtracking…I have not confirmed the IP address…just realized nothing is different in the list of IPs when the D1 mini is and is not connected. That’s the problem.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top