ESP8266 & ESP32 VSCode OTA Support

Today we are releasing an initial version for remote OTA support on VisualStudio Code!! :star_struck: :star_struck: :star_struck:

A Visual Studio Code extension that provides remote OTA updates directly from the Internet for ESP8266 and ESP32 over Thinger.io.

Currently it works on ESP32 and ESP8266 devices

Features

  • :rocket: Device switcher to select the target device for the update
  • :green_circle: Device connection status
  • :ant: Compatible with multiple PlatformIO configuration environments inside a Project
  • :dizzy: Automatic build and upload in one click
  • :clamp: Support for compressed OTA images (zlib on ESP32, and gzip on ESP8266)
  • :mag_right: MD5 Checksum verification for firmware binaries

How to Test

Example for ESP32

  • Create or use an exsiting project on VSCode with Platformio for ESP32
  • Add latest Arduino Library from Github on your platformio.ini configuration, for example:
[env:ota-test]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
lib_deps = https://github.com/thinger-io/Arduino-Library.git
  • Flash the following example for ESP32 (with your device credentials and WiFi Config) with PlatformIO upload command:
#include <ThingerESP32.h>
#include <ThingerESP32OTA.h>

#define USERNAME "your_user_name"
#define DEVICE_ID "your_device_id"
#define DEVICE_CREDENTIAL "your_device_credential"

#define SSID "your_wifi_ssid"
#define SSID_PASSWORD "your_wifi_ssid_password"

ThingerESP32 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
ThingerESP32OTA ota(thing);

void setup() {
  pinMode(16, OUTPUT);

  thing.add_wifi(SSID, SSID_PASSWORD);

  // digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc)
  thing["GPIO_16"] << digitalPin(16);

  // resource output example (i.e. reading a sensor value)
  thing["millis"] >> outputValue(millis());

  // more details at http://docs.thinger.io/arduino/
}

void loop() {
  thing.handle();
}
  • Install Thinger.io VSCode extension directly from the Extension manager. Search for “Thinger.io”. Checkout on Microsoft Marketplace

  • From now on… you will be able to select your device in the extension and click on play button to upload new firmware remotelly. You will need to create a token in your Thinger.io account the following permissions (and insert it when prompt by the extension):

    • ListDevices
    • AccessDeviceResources
    • ReadDeviceStatistics

Any feedback is apprecietad!

4 Likes

Release Notes

:star_struck: :star_struck: :star_struck: :star_struck: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap:

1.0.4 (2021-08-09)

  • Added Espressif ESP8266 OTA Support! :heart_eyes: :heart_eyes: :heart_eyes: :heart_eyes:
  • Added MD5 checksum verification for updates
  • Improved error handling with messages thrown by devices
  • Compression support on ESP32 (zlib) and ESP8266 (gzip)
1 Like

After testing this… IT ROCKS!!!

I was into the Arduino OTA, but of course it limitation is that is needed to be in the same network segment… but with this it is not neccesary at all, just need the device connected to thinger server and it allows to modify the running sketch from anywhere.

Thank you guys.

2 Likes

You can now update the RoadMap in the documentation: :white_check_mark: ESP32 & ESP8266 OTA

Hi, @alvarolb . I was curious to learn more about the features:

The “Alerts manager” would be a functionality similar to what is already done by Endpoints, or similar to what NodeRED can do, for example, send an alert, to the email, if the device is offline for more than 3 hours?

Will the “Reporting generator tool” and “Reporting tool” make it possible to make reports with data from the buckets, for example, in Python or R language and send it by email?

I was excited about the possibilities.

Hello @ega

I upload the example script with platformio to an Esp32 dev Kit and I can’t get it to work.
In platformio the card does not seem to me
Have you got it without problems?

Yes, I had no problems,

I installed platformio (I used to code in arduino ide, so big advance for me to switch to platformio), then the thinger extension, I created the token into the instance and then set it into the thinger extension, and it shows me the actual devices created (in VSCode), and if I select some that is not online, the icon becomes red.

Specifically what you can’t do? or which step you are not able to reach? are you working with the public server or a private instance?

I use a private instance.
I have created a token with all the permissions and put in the extension
If I create a data bucket with ESP32 that I am trying to configure if that Ota data appears to me. ¿?¿?
Do you create the token for the Device or general?

Hi @JAVIER_MARIN, for private instances you need to configure the extension in VSCode settings, there is a section for Thinger.io there to configure host (with your private instance), and token. The token is fine with all permissions, it should work, but it is more secure if you limit the acccess for Device and the following permissions:

  • ListDevices
  • AccessDeviceResources
  • ReadDeviceStatistics

I had difficulty at first because I didn’t work with VS Code. But I managed (image below). It would be nice to document this with some images.
One question: You don’t need to indicate the Thinger.io account username in the extension, but only the token?

I did some testing with the ESP8266. After successfully uploading the Firmware… It only worked when I pressed the reset button on the NodeMCU. I don’t know if this is the default behavior, but it would be better if the NodeMCU resets right after the firmware update.
I’m going to investigate if this is because I’m using USB as a power supply or if it’s something from the VS Code.

1 Like

I did tests powering the ESP8266 with USB and with the JACK connector.

The Firmware Upload was successful, but I only managed to get the firmware into operation by pressing the RESET button on the NodeMCU. Otherwise, NodeMCU was still running the previous firmware.
I also simulated turning off/on the NodeMCU, removing the power cable, and I was also unsuccessful. ESP8266 has not moved to the latest firmware.


Thanks @alvarolb and @ega .
my problem was the token.
it’s already working

very very happy with this update, save a lot of workota-ok

1 Like

Include a button to “uncheck” the device.
This functionality is important, otherwise a device will always be tagged, and the developer may confuse the “Upload by Serial USB” buttons with the “Upload by OTA/internet” buttons when updating a firmware.

It is also interesting not to select any device when resetting the VS CODE. Otherwise, the developer may mistake and “Upload by OTA” by mistake when trying to “Upload by Serial”.
I also suggest changing the device’s background color from blue to green, to draw the developer’s attention, avoiding “Upload by Serial” instead of “Upload by OTA”.


verde

Hi!

I would test what happens for ESP8266, but in theory a reboot is issued at the end of flash both for ESP32 and ESP8266 to apply the update.

Will check how to solve it.

In theory it keeps selected the latest flashed device for that project. So, if you change between projects, the flashed device will change. With the ability to deselect a device it should be solved.

VSCode Studio does not allow setting arbitrary colors on the toolbar… a “normal state” is without any background color. You can only set backgrounds for warnings, errors, etc…

We have new version of the Visual Studio Code Extension:

Release Notes

1.0.5 (2021-08-24)

  • Add configuration to disable SSL verification for local deployments
  • Add command to palette for clearing selected device
  • Device search box now also query by device name
  • Improved OTA cancellation mechanism in any step
  • Preliminar support for LZSS compression for Arduno devices
  • OTA Speedup (~15%) with HTTP Keep-Alive (see recommendations on Readme)

Is “remote console” definitively abandoned, or do you have a schedule to get it working?

I can successfully telnet into my ESP32 devices within the wlan, but doing that worldwide over thinger.io without requesting a port forwarding would have been ways more sexy…

Hi @rin67630 ,

today I have been working on it. Some advances:

Now it display messages correctly

void loop() {
  delay(1000);
  Console.println("yes! it works!");
}

4PSuEZi13E

Now it also accepts reading commands from the terminal. Can be used normally as a Serial port

void loop() {
  if(Console.available()) {
    String cmd = Console.readStringUntil('\n');
    Serial.printf("Read command: %s", cmd.c_str());
  }
}

041V4v7L3

Saving the distances, It works practically like a linux terminal, each character is echoed back to the web terminal to ensure the message arrived fine to the device.

I think it can be released tomorrow. I need to do some more testing. :wink:

2 Likes

Still working on it… some work in progress. A minimal example… it says ESP32 but it is compatible with any other device.

TiA0aJgRQx

  console.set_terminal("ESP32", [&](String cmd){
    if(cmd=="free"){
      console.println(ESP.getFreeHeap());
    }else if(cmd=="reboot"){
      console.println("device will reboot now...");
      thing.reboot();
    }else if(cmd=="model"){
      console.println(ESP.getChipModel());
    }else if(cmd=="cores"){
      console.println(ESP.getChipCores());
    }else{
      console.println("\033[31munknown cmd");
    }
  });
1 Like