Blog 2Smart (EN)

How to update the firmware and mobile application of ready-made devices within 5 minutes

Tool for delivering over-the-air updates
Following the creation of Custom firmware for an IoT device, the updating process becomes extremely simple. New firmware versions are delivered over the air which is enough for the device (in our case, a Wi-Fi relay) to be connected to the Internet.

This allows the vendor to add new functionality to the firmware and fix possible bugs at any time.  At this stage, we decided to apply both major and minor updates. Changes will be made to the firmware code and the interface of the mobile application.

Device firmware update

For an example of such an update, let's use the correction of the text that the mobile app user receives when the relay is physically turned on and off with a button on the corpus. Before the update, the notifications read "Relay on" and "Relay off". After the update, the text will change to "Relay was turning on" and "Relay was turning off". 

Fixing bugs, adding new functionality, or improving existing functionality. 
The procedure of any larger code update will be similar to the one described below.

1 - Prepare a test device (a Wi-Fi relay on a breadboard in our example.) Running devices on printed circuit boards will receive a ready-to-use update after the new firmware version has been published on the platform.

Wi-Fi relay on a PCB

2 - In the “Products” tab of the vendor's cabinet, select the device which Custom firmware you want to update.

Choosing the device whose firmware you want to update

3 - Click the "Update firmware" link.

Firmware update link

4 - Click "Update firmware".

Confirmation of desire to update firmware

5 - In the firmware sources on your computer, find the files that need to be corrected and make the necessary changes.

To fix the notification text, we worked with the file located at Firmware/lib/relay_node/property/relay_state.cpp.

Older firmware version

New firmware version

6 - After fixing the code in the correct files, don't forget to make changes to /src/main.h. Specify the new version of the device in the “Device Version” field (in our case correct "1" to "2").

Update the firmware version in the code

7 - Flash the test device with the new firmware version via USB cable.

Note! If the firmware has already been written to the microcontroller, do not forget to remove it according to the documentation.

Firmware update of test device

8 - After completing the flashing process, the device will create a Wi-Fi hotspot with a name that matches that of the device. Connect your computer or smartphone to this Wi-Fi hotspot.

Connect to the device's Wi-Fi network to access the web interfaceConnect to the device's Wi-Fi network to access the web interface

9 - Follow the link to open the web interface of your device.

Device web interface

10 - Copy the values from the Connection Information screen into the fields on the Credentials tab:

  • In the “Login” field - the value "User Login".
  • In the “Token field” - the value "Access Token".
  • In the “Hostname” field (under the Advanced spoiler) enter the value "".
  • In the “Device ID” field, copy the value "Test device ID".

After completing the fields, click Save.

Entering parameters for connection in the device web interface

11 - Assure that your computer is still connected to the device's Wi-Fi hotspot. Click the “Wi-Fi” tab and then click “Scan”.

Search available Wi-Fi networks

12 - Select your Wi-Fi network in the list and enter the password to access it. This is necessary so your Sandbox device can connect to the test environment of the 2Smart Cloud platform.

Note! Devices based on the ESP32 microcontroller support only Wi-Fi networks with a frequency range of 2.4 GHz!

Selecting the Wi-Fi network to use for the test device

13 - Now switch to your Wi-Fi network and open the device page in the vendor's account. After successfully connecting the prototype to the internet, the device status will change to “Ready”.

Notification of successful connection of a test device to the platform

14 - Click the " Preview State" link and check that the Firmware  Version sensor displays the new firmware version’s value.

Preview sensors

15 - Double-check that the firmware update has given the desired result (notification text has changed). Test the operation of the device similar to the initial testing of the prototype.

16 - Build a new version of the firmware on your computer in .bin format.

Preparing the firmware file

17 - Click the "Update Firmware" link and upload the ready-made firmware file to the platform.

Firmware update link

18 - Click "Publish".

Publishing a product update

19 - Confirm your desire to publish a new version of the product.

Publishing a product update

20 - Devices with older firmware versions will receive the update automatically after checking for updates. The user can also click the “Push” button on the “Firmware” tab of the device interface in the app to get the update immediately. 

Button for a forced device firmware update in the mobile application interface

21 - When the device has been updated, the new firmware version will be displayed in the mobile application interface.

Text widget with the current firmware version of the device

22 - You can see the changes made to the firmware by entering the notifications section of the mobile app. By pressing the physical “on/off” button on the relay body, you will receive messages with the new text.

Notifications from the 2Smart Cloud mobile application with messages about turning on/off the device

Colleagues and friends who used the Wi-Fi relay confirmed that the new version of the firmware came automatically within 24 hours.

Mobile app interface update

Having discovered that the widget library was updated on the 2Smart Cloud platform, a decision was made to update the interface of the mobile application for controlling the Wi-Fi relay. By adding a graph widget for the Wi-Fi signal level sensor, we can see statistics on how this level has changed over time.

Editing the application interface is no different from creating it when adding a new product:

1 - Click on the link “Edit layout” on the product page in the vendor's cabinet.

Link to the mobile app interface editing tool

2 - Click "Add widget".

Adding a new widget to the interface of the 2Smart Cloud mobile application

3 - Choose the widget of your liking. (In our case, it was "Number".)

Adding a new widget to the interface of the 2Smart Cloud mobile application

4 - Configuring the widget. Select the display of sensor data “WiFi Signal”.

Configuring the new widget of the 2Smart Cloud mobile application

5 - In the emulator of the mobile application, confirm that you received the desired display of the “history of changes” in the signal strength of the Wi-Fi network on the graph.

Configuring the interface of the 2Smart Cloud mobile application

Configuring the interface of the 2Smart Cloud mobile application

6 - Click "Save".

Saving the updated interface of the 2Smart Cloud mobile app

7 - Click "Publish".

Publishing a product update

8 - Agree to the publication of minor product updates.

Window for confirming the publication of product updates

9 - The only thing left to do for users, is to restart the 2Smart Cloud mobile app on their smartphone to see the changes made to the interface.

Once the firmware has been updated, it might be of interest to monitor how the actual devices are updated. In addition to the usual feedback, you can do this using the statistics section in the vendor's 2Smart Cloud cabinet.

The final article of our series is dedicated to working with statistics.

All articles about IoT device creation and support

  1. Learn your way around the IoT platform –  create your first device and control it from your smartphone without an MCU
  2. How to create a Wi-Fi switch to control via a mobile app and Telegram bot
  3. 4 stages of using the platform to create a new IoT device
  4. How to create an IoT device on a printed circuit board and take it from prototype to finished product
  5. How to write firmware for an IoT device based on an SDK
  6. How to update the firmware and mobile application of ready-made devices within 5 minutes
  7. Collection and analysis of statistics –  a useful tool for product improvement
Made on