Arduino Library 2.20.0

Date: 30/08/2021
Component: Arduino Library
Release Note: Add OTA support and include latest Arduino Boards

Additional Information

  • Fix ESP8266 connection with TLS/SSL enabled
  • Add support for ESP32 RTOS
  • Add support for ESP8266 & ESP32 OTA
  • Add examples for Arduinos: MKR1010, Nano RP2040 Connect, Nano 33 IOT
  • Add support for OTA on Arduinos: MKR1010, Nano RP2040 Connect, Nano 33 IOT
  • Add new examples for using ESP32 RTOS, OTAs, etc.
1 Like

New Error identified when using ClientListener + ThingerWebConfig + framework-arduinoespressif8266 3.30002.0 (3.0.2) + <thinger.io> 2.20.0+sha.6b17ee0 + WifiManager 2.0.3-alpha+sha.9af7253 :

[_SOCKET] Connecting to iot.thinger.io:25202...
[_SOCKET] Using secure TLS/SSL connection: yes
[_SOCKET] Error while connecting!

The error does not occur if you use ClientListener + ThingerWebConfig + espressif8266@2.6.2(Arduino-Framework 2.7.4) + thinger.io@2.16.0 + WifiManager 2.0.3-alpha+sha.9af7253

I identified the Error when trying this code:

#define _DEBUG_

// Requires WifiManager from Library Manager or https://github.com/tzapu/WiFiManager

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <DNSServer.h>
#include <WiFiManager.h>
#include "FS.h"
#include <ThingerWebConfig.h>

// Enter your device data
#define USERNAME "xxxxxxxxxx"
#define DEVICE_ID "yyyyyyyyyy"
#define DEVICE_CREDENTIAL "wwwwwwwww"

class ClientListener : public ThingerWebConfig{

public:

    ClientListener(const char* user, const char* device, const char* device_credential) : 

      ThingerWebConfig(user, device, device_credential){}

protected:

  virtual void thinger_state_listener(THINGER_STATE state){
    ThingerWebConfig::thinger_state_listener(state);
    switch(state){
         case NETWORK_CONNECTING:
                break;

         case THINGER_AUTHENTICATED:  
                break;

         default:                     

                 break;         

    }
  }
};

ClientListener thing(".", ".", ".");

void setup() {

  Serial.begin(115200);

  thing.set_credentials(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

  pinMode(LED_BUILTIN, OUTPUT);

  thing["led"] << digitalPin(LED_BUILTIN);

  thing["millis"] >> outputValue(millis());

}

void loop() {

  thing.handle();

}

Vs Code + Platformio:

[env:nodemcuv2]
platform = espressif8266
;platform = espressif8266@2.6.2
board = nodemcuv2
framework = arduino
monitor_speed = 115200
lib_deps = 
    thinger.io=https://github.com/thinger-io/Arduino-Library.git#6b17ee081ae12d66a77989b781632595380a98a1
    ;thinger.io@2.16.0
    WiFiManager=https://github.com/tzapu/WiFiManager.git#2.0.3-alpha
    

Error after connecting to Router:

....
*WM: [1] CONNECTED:
*WM: [1] Connecting to NEW AP: Router
*WM: [3] Using Password: xxxxxxxxxx
*WM: [3] WiFi station enable
*WM: [3] enableSTA PERSISTENT ON
*WM: [1] connectTimeout not set, ESP waitForConnectResult... 
*WM: [2] Connection result: WL_CONNECTED
*WM: [3] lastconxresult: WL_CONNECTED
*WM: [1] Connect to new AP [SUCCESS]
*WM: [1] Got IP Address:
*WM: [1] 192.168.0.102
*WM: [2] disconnect configportal 
*WM: [2] restoring usermode STA
*WM: [2] wifi status: WL_CONNECTED
*WM: [2] wifi mode: STA
*WM: [1] config portal exiting
[_CONFIG] Updating Device Info...
[_CONFIG] Done!
*WM: [3] unloading
[NETWORK] Connected!
[_SOCKET] Connecting to iot.thinger.io:25202...
[_SOCKET] Using secure TLS/SSL connection: yes
[_SOCKET] Error while connecting!
[_SOCKET] Connecting to iot.thinger.io:25202...
[_SOCKET] Using secure TLS/SSL connection: yes
[_SOCKET] Error while connecting!

@alvarolb , what would the example look like with ThingerWebConfig + ClientListener + OTA ??? Thanks

Hi @George_Santiago ,

I’ve just posted a code that works with the ESP32, the wifimanager code works with both ESP32, ESP8266, if I were you would give it a try with the ESP8266, changing just the thinger’s library by the 8266 versions,

Check this → ESP32 WiFiManager

Hope this helps.

Thanks for the sugestion, @ega

But the products we develop are based on the code above ( Esp8266 +ThingerWebConfig + WiFiManager + ClientListener). Without this fix in the library, we will have to use the Arduino-Thinger 2.16 version with Esp8266/Arduino 2.7.4 .

Let’s wait for @alvarolb to analyze the problem and propose a solution. Only after the correction will we be able to use the new library features (OTA…) on our devices.

Hi,

My friend the code I shared is OTA ready, I just realized that I made it in Arduino IDE and not VSCode lol, but it allows you to set the SSID WiFiPassword, User, Device and Credential in the wifi setup, so you can develop your end user devices, I just did not used the ClientListener, but I’m almost sure it will work.

Is there any specific reason why to define the credentials in the setup loop? I am not sure, but I dont know if the definitions keeps available out of the setup loop (I would believe they doesn’t), so when in the main loop when it calls the thinger function and tries to login, the definitions are destroyed basically, I would recommend you to keep the definitions globally declared.

Hello, @ega
Thanks for the sugestion.
Our products are for commercial purposes and were developed based on the “Arduino-Library” of Thinger.io. For this reason, it would be important for us to analyze and fix the identified “bug”.
I found your proposal for ESP32 + WiFiManager very interesting.
Thanks for the collaboration.
But let’s wait for the analysis and correction of the “bug” in Thinger.io’s “Arduino-Library” library.

Hi,

I saw you corrected the code in your post, but I wonder why to define this

ClientListener thing(".", ".", ".");

And then in setup:

thing.set_credentials(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

What do you want to do?

We use this to hide the parameter fields (USERNAME, DEVICE_ID, DEVICE_CREDENTIAL) on the WiFiManager web site. With this, the end user has no way to change this data.
We then retrieve the data (USERNAME, DEVICE_ID, DEVICE_CREDENTIAL) stored in JSON.
This structure/strategy works very well for our device and business purpose.

Everything works fine using: ClientListener + ThingerWebConfig + espressif8266@2.6.2(Arduino-Framework 2.7.4 ) + thinger.io@2.16.0 + WifiManager 2.0.3-alpha+sha.9af7253

But it has an error when using: ClientListener + ThingerWebConfig + framework-arduinoespressif8266 3.30002.0 (3.0.2 ) + <thinger.io> 2.20.0+sha.6b17ee0 + WifiManager 2.0.3-alpha+sha.9af7253:

It certainly seems like a bug, I tried the SmartConfig (I think this one fits better to your needs) and the WebConfig without success the connection with TLS enabled, and neither could update via OTA updater.

Regards,

1 Like