Autoconnect Blynk (WifiManager Alternative) - ESP8266/ESP32

Hey guys so i came across this amazing library - AutoConnect and wanted to share it with the blynk community!

Its feature packed!

  • Stores SSID and Password so no need to hard code them in the sketch

  • Custom WebPage for blynk server (No need to hard code blynk server details)

  • Blynk Custom WebPage Supports both local and cloud server (No need to upload sketch everytime to change blynk credentials)

To use Blynk Cloud enter port as 80 and the IP address from pinging “blynk-cloud.com”.

  • Unlike WifiManager library the portal can be accessed even when the device is connected to WiFi making it possible to modify credentials for blynk or reconnect to another WiFi network!
    (Connect by typing the ip assigned to the device)

I have already made an example ready to go, just download and upload it to your device and connect to blynk without any modification in the sketch! It stores all value in SPIFFS and thus all configuration survives reboot.

Download the example sketch - AutoConnect Blynk Sketch

5 Likes

Thanks for sharing.

So it’s similar to Blynk.Inject except,

  • Blynk.Inject dynamically assigns and stores an auth token
  • AutoConnect dynamically stores a statically-assigned auth token
  • Blynk.Inject only works in previewing an app (and with the Enterprise Plan)
  • AutoConnect works while running / playing a project and in previewing an app (with static provisioning)

I don’t know how to modify the SSID and password with Blynk.Inject. That’s not to say it can’t be done.

Did I get that about right?

Joe

Yes you did get all the points right, its really similar to Blynk.inject!
As far my knowledge with Blynk.inject, with the enterprise app, i guess the WiFi can be changed, infact i remember it working exactly like this library but just within the application instead of a browser window. I am not sure though.

Well, I guess you could always enter a new SSID and password via a pair of Text Input widgets and write them to the ConfigStore in EEPROM.

I’ll keep an eye on AutoConnect. Again, thanks for sharing.

Add an option to reset the wifi credentials

Dear @Nilava_Chowdhury
Thank you for sharing.

1 Like

since the credentials are stored in flash storage, its not possible yet to reset the credentials without wiping the whole flash storage!

Thank you for sharing this. I was really looking for something like this to integrate Blynk with simple web page for informational purposes as in my project not all parameters read from device are transferred to Blynk Server, and it seems this library makes it really easy. Great!

2 Likes

Just do a wifi.disconnect()…that will clear out any saved wifi config.

Are you sure?

Pete.

Yes.

https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/station-class.html?highlight=disconnect()#disconnect

I use it all the time as part of my own connection management code.

Hmmmm, very interesting - thank you.

Must read-up a bit more on the Arduino core.

Pete.

1 Like

Here is a snippet of what I do for connection management at start up. All the user has to do is enter wifi credentials, the system will call out for an auth token from one of my webservers if the user leaves it blank.

// Check to see if we have a configured SSID.  If we do, use it.
  if (WiFi.SSID() != "")
  {
    MYDEBUG_PRINTLN("SSID Configured, connect to it.");
    display.println("Connecting to WiFi...");
    display.display();
    WiFi.mode(WIFI_STA);
    WiFi.begin();
    int loop = 10;
    while ((WiFi.status() != WL_CONNECTED) && (loop > 0))
    {
      delay(500);
      MYDEBUG_PRINT(".");
      loop--;
    }
  }
  else
  {
    MYDEBUG_PRINTLN("No SSID Configured, start configuration portal");
    
    display.println("Device not configured");
    display.println("");
    display.print("AP:");
    display.println(" ESP_" + mac);
    display.display();
    
    // WiFi hasn't been configured, fire up the config interface.
    WiFiManager wifiManager;
    
    //set config save notify callback
    wifiManager.setSaveConfigCallback(saveConfigCallback);
    
    wifiManager.addParameter(&custom_blynk_text);
    wifiManager.addParameter(&custom_token);
    wifiManager.addParameter(&custom_blynk_server);
    wifiManager.addParameter(&custom_blynk_port);

    // Set the connect timeout to 2 minutes
    wifiManager.setTimeout(120);
    String hname = "ESP_";
    hname.concat(mac);
    if (!wifiManager.autoConnect((const char*)hname.c_str())) {
      // If we timeout here it is because we did not receive a configuration from the portal
      // The device will have to be reset to try again
      MYDEBUG_PRINTLN("WifiManager config timeout.");
      WiFi.printDiag(Serial);
    }
  }
1 Like

You can also use the disconnect option in Auto connect menu, that would do the same !

@Nilava_Chowdhury Have you tried it with OTA?

No, but i don’t think it would work, esp8266 doesn’t have that much memory left after this as this library is quiet memory hogger!

That’s true. I see you’re running your sketch with ArduinoJson v5 and not with v6.

1 Like

Thanks for sharing. When compiling I am getting this error:
fatal error: PageBuilder.h: No such file or directory #include <PageBuilder.h>

Where can I get PageBuilder.h?

Regards, Hatters

PageBuilder.h - Google Search leads to Hieromon (Hieromon Ikasamo) · GitHub same author of library referenced in this OP :stuck_out_tongue_winking_eye:

3 Likes

Noted. Thanks a lot