Using Blynk with Tzapu's WifiManager

Hello, I’ve successfully used WifiManager by @tzapulica to have an ESP8266 enter access point mode to get wifi credentials before running Blynk. Now I’m trying to write a sketch where the user can enter the auth code (Blynk token) as well. I have added the required parameter to my setup function, and the field for the token shows up in access point mode. When it goes to webserver mode to run, my ESP8266 is not connecting to Blynk. Here is a snippet of the code I am trying to use:

char blynk_token[32];

void setup() {
    Serial.begin(115200);
    WiFiManagerParameter custom_blynk_token("Blynk", "blynk token", blynk_token, 32);
    WiFiManager wifi;
    wifi.addParameter(&custom_blynk_token);
    wifi.autoConnect("Blynk");
    Blynk.config(custom_blynk_token.getValue());
}
void loop() {
   Blynk.run();
}

One thing I noticed in the AutoConnectWithFSParameters example, @tzapulica creates a 34 byte string for the Blynk token, but creates a 32 byte custom parameter. Is there a reason for this, is it because he’s using the following command?

strcpy(blynk_token, custom_blynk_token.getValue());

Thank you,
-Garrett

hi, the example is a bit wrong, i think it should be 33 bytes in both places.

it is normal that blynk is not running when the web portal is up, as autoConnect is blocking. you are also most likely not connected to the internet at that point, so there wouldn t be much chance of blynk connecting anyway.

you can see a possibly better and completly working/tested example of a sketch with both blynk and wifimanager and configuring blynk through the webportal here https://github.com/tzapu/SonoffBoilerplate and explanatory post here https://tzapu.com/sonoff-esp8266-control-blynk-ios-android/

i hope this helps
alex

Hi Alex,
This is just the type of “kick start” I was looking for. I’ll give your SonoffBoilerplate a try tonight. Thank you!
-Garrett

Hi Tzapulica, do you have any simple guide for beginners? Here is an example:

  1. Copy/Paste this Sketch
  2. Go to Wifi and find ESP8266
  3. Enter ID / Pass
  4. Connect
1 Like

@flhtraveler see above sonoff boiler plate, also pretty much all WiFiManger examples do at least that…

good luck

Thank you. I’ve tried all the examples as well as the sonoff boiler plate. I’m using (Wemos D1 Mini & have also tried the Node MCU). The WIFI network does not appear in my choices. I’m using an Iphone 6, Arduino 1.8.0 and have loaded the latest ESP8266 libraries inside the Arduino IDE. Please advise

Size of 32 is not big enough, needs to be at least 33 to cover the null terminator.

I noticed that if you have had the nodemcu connected to the wifi when upload the sketch, the wifimanager knows that and direct connect to your wifi… that hapenned to me…
Try to switch off your router, start the nodemcu and let your iPhone to search wifi nodes, the one you have set in wifimanager autoconnect should appear, try to connect to it and after few seconds the screen to config the access point should appear.

Thanks I’ll give it a try