The following instructions will show vendors how to install the ESPHome firmware on the ESP32 microcontroller using a PC or laptop running Linux. They will be required for the first time during product testing when the test firmware is installed on the prototype.

You can use one of two tools to install the firmware on the microcontroller: Python or Docker.

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.Indicator of device status with the test firmware

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.Indicator of device status with the test firmware

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.

Don't forget to share this post!

Let’s dive into your case

Share with us your business idea and expectations about custom software development for the internet of things.

    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