Table of contents:

In this tutorial, we’ll explore the process of installing ESPHome firmware on the ESP32 microcontroller, designed specifically for Linux users operating PCs or laptops. Three primary methods exist: flashing an ESP32 device via a web browser, utilizing esptool, or utilizing Python. Let’s delve into each approach extensively.

Flashing an ESP32 device via a browser

For developers using ESPHome for ESP32 microcontroller firmware creation on Linux, we’re pleased to announce a notable feature that brings several useful enhancements. Now, with a couple of clicks, you can effortlessly install ESPHome-based firmware on your microcontroller. This seamless process is facilitated through the web interface of the 2Smart Cloud platform, leveraging the ESP Web Tools library.

For installing ESPHome-based firmware on your microcontroller through a browser, just follow the guidance available on the 2Smart website. Ubuntu users need to grant access to the serial ports by adding their user to the dialout group using the command: “sudo usermod -a -G dialout <user>“, followed by a system restart. Below, let’s explore the key steps of the process.

Kindly note that we’ve already executed the firmware assembly on our servers, so there’s no need for you to utilize assembly programs on your computer.

Begin by creating an ESPHome configuration and generating the firmware. Afterward, connect your microcontroller through a selected serial port and install the firmware using the platform’s web interface.

Flashing ESPHome Firmware on ESP32 Microcontroller

An important advantage of this firmware installation method is the direct accessibility of microcontroller logs from your web browser. Upon successful flashing, connect to the computer’s serial port to access and view logs.

Flashing ESPHome Firmware on ESP32 Microcontroller

Moreover, you could also download the logs of a microcontroller to your PC.

Flashing ESPHome Firmware on ESP32 Microcontroller

If you encounter any difficulties with the web interface method mentioned above, you have the option to use alternative tools for firmware installation: Python or Docker. Refer to the instructions below.

Flashing an ESP32 device with esptool

  1. Python 3.8.10 is already installed by default in Ubuntu 20.04. Install Python or upgrade it to version 3.8.10 or higher if you don’t have the proper version on your device.To flash the board, the pip3 package manager should be installed. To accomplish this, use the following command to update the package list:

    After this, install the package manager:

    
    
    sudo apt-get -y install python3-pip
    

  2. Unzip the firmware file and navigate to the directory containing the archive’s contents in the terminal.The firmware archive's content
  3. Connect the microcontroller to the PC utilizing a USB cable. Enter the following command and hit Tab:

    Please note that you may be utilizing the ttyUSB1 port rather than the ttyUSB0 port, for example. Bear this in mind as you proceed through the current and next steps.

  4. Set file permissions by running the following command:
    
    
    sudo chown $USER:$USER /dev/ttyUSB0
    

    Setting permissions

  5. Install the necessary libraries to work with the “2smart.sh” script using the following command:
    
    
    pip3 install -r requirements.txt
    

    Installing libraries
    Installing libraries

  6. Clean up the microcontroller memory by running the following command:
    
    
    ./2smart.sh --device /dev/ttyUSB0 erase_flash
    

    Cleaning the microcontroller memory

    If the memory cleaning stops at the “Connecting ….___….___” step, press the Boot button on the DevKit board:

    The Boot button on the DevKit board

  7. Run the “2smart.sh” script to flash the microcontroller:
    
    
    ./2smart.sh --device /dev/ttyUSB0 write
    

    If the flashing stops at the “Connecting ….___….___” step, press the Boot button on the DevKit board.

    Flashing the microcontroller

  8. After a successful flash, you will see the “Leaving… Hard resetting via RTS pin…” notification.Flashing the microcontroller
  9. After flashing is completed, return to your 2Smart Cloud account and wait until the device is detected by the platform. If this does not happen within one to two minutes, unplug your device and plug it back in the PC.The device’s “Ready” status indicates that the prototype has been successfully connected to the platform.
    Flashing ESPHome Firmware on ESP32 Microcontroller

Let’s collaborate

We’re empower your business with our technology expertise

Let’s discuss your case

Flashing a device with Docker

  1. Install the appropriate Docker Engine for your system. All versions can be found on the developer’s website.Check if you already have Docker installed. Run the following command:

    Checking to see whether Docker is installed on the system

    You can also install Docker from the ubuntu repository with the following command:

    
    
    sudo apt install docker.io
    

  2. Unzip the firmware file and navigate to the directory containing the archive’s contents in the terminal.
  3. Connect the microcontroller to the PC utilizing a USB cable. Enter the following command in the terminal and hit Tab:

    This step is required to verify that the microcontroller is connected to the USB port.

    Please note that you may be utilizing the ttyUSB1 port rather than the ttyUSB0 port, for example. Bear this in mind as you proceed through the current and next steps.

  4.  Set the permissions to the USB port by running the command:
    
    
    sudo chown $USER:$USER /dev/ttyUSB0
    

  5. Use the following command to make the user Docker accessible:
    
    
    sudo usermod -aG docker $USER
    

    After adding the user to the Docker group, log out and log back in for the changes to take effect.

  6. Clean up the microcontroller memory. If the esptool images have not been downloaded, they will be downloaded automatically. Run the following command:
    
    
    ./2smart_docker.sh --device /dev/ttyUSB0 erase_flash
    

    Cleaning the microcontroller memory

    If the memory cleaning stops at the “Connecting ….___….___” step, press the Boot button on the DevKit board:

    The Boot button on the DevKit board

  7. Run the “2smart_docker.sh” script to flash the microcontroller.
    
    
    ./2smart_docker.sh --device /dev/ttyUSB0 write
    

    If flashing stops at the “Connecting ….___….___” step, press the Boot button on the DevKit board.

    Microcontroller flashing

  8. After a successful flash, you will see the “Leaving… Hard resetting via RTS pin…” notification.Flashing the microcontroller
  9. After flashing is completed, return to your 2Smart Cloud account and wait until the device is detected by the platform. If this does not happen within one to two minutes, unplug your device and plug it back in the PC. The device’s “Ready” status indicates that the prototype has been successfully connected to the platform.
    Flashing ESPHome Firmware on ESP32 Microcontroller

When getting confirmation that your connection to the prototype platform with test firmware was successful, you can continue working on your product. A similar approach is used to install the production firmware on finished devices.

Rate this article:

4.6 / 5. 11

( 11 votes )

Don't forget to share this post!

Let’s dive into your case

Share with us your business idea and expectations about the software or additional services.

    Thanks for contacting us!

    We will get in touch soon.

    This site is protected by Google reCAPTCHA and the following Privacy policy and Terms of use apply

    Send us a message

    This site is protected by Google reCAPTCHA and the following Privacy policy and Terms of use apply