BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk with Eduroam / MSCHAPv2

Hello,

I wanted to connect my Blynk project with the Eduroam WiFi at my University.
WiFi connection works well, but connecting with the Blynk server always results in a timeout.
Do you know why that is?
Thanks in advance!


#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include "esp_wpa2.h"

char auth[] = "XXXXX";

#define EAP_ANONYMOUS_IDENTITY "XXXXX"
#define EAP_IDENTITY "XXXXX"
#define EAP_PASSWORD "XXXXX"
const char* ssid = "eduroam"; // Eduroam SSID
int counter = 0;

void setup()
{
  Serial.begin(9600);
  WiFi.disconnect(true);  //disconnect form wifi to set new wifi connection
  WiFi.mode(WIFI_STA); //init wifi mode
  esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_ANONYMOUS_IDENTITY, strlen(EAP_ANONYMOUS_IDENTITY)); 
  esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY));
  esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD));
  esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT(); //set config settings to default
  esp_wifi_sta_wpa2_ent_enable(&config); //set config settings to enable function
  WiFi.begin(ssid); //connect to wifi
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    counter++;
    if(counter>=60){ //after 30 seconds timeout - reset board
      ESP.restart();
    }
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address set: "); 
  Serial.println(WiFi.localIP()); //print LAN IP
  Blynk.config(auth);
}

void loop()
{
  Blynk.run();
}

The IT department of University also gave me an URL that seems to be neccessary in some way, but I am unsure what do with it.

If you’re getting to the point where you see the “WiFi connected” and "IP address set: " messages then my guess is that your IT department is blocking the data packets that are going to/from the Blynk server on port 8080. There are apparently PSH flagged TCP/IP packets and probably need the firewall to be reconfigured to allow them through.

Pete.

Port 8080?
The Serial monitor shows Connecting to Blynk-cloud.com:80

I will go and ask them about that, thanks!

The other thing you could try is forcing the use of port 8080 by changing this:

Blynk.config(auth);

to this…

char server[] = "xxx.xxx.xxx.xxx";  // IP for your Local Server
int port = 8080;
Blynk.config(auth, server, port);

Pete.

If I open

http://blynk-cloud.com/myAuthCode/get/V0

while beeing connected to the same network with my laptop, everthing works an I can see the value.
I treid port 80, 443 and 8080, all result in a timeout.

an HTTP/S API call is different to an open TCP connection.

What did they say?

Pete.

I gave them the MAC of my ESP32. They said that they will allow that Mac access to blynk-cloud.com or (139.59.206.133) tommorow.

Update:

It still does not work. I tried ports 80, 443, 8080 and 139.59.206.133 and blynk-cloud.com.
It always says:

WiFi connected
IP address set:
10.8.XXX.XX
[2221] Connecting to 139.59.206.133:80 
[5274] Login timeout

However: HTTP get works with the ESP, so WiFi is not the problem:

#include <WiFi.h> //Wifi library
#include <HTTPClient.h>
#include "esp_wpa2.h" //wpa2 library for connections to Enterprise networks
#define EAP_ANONYMOUS_IDENTITY "XXXX.de"
#define EAP_IDENTITY "XXXX.de"
#define EAP_PASSWORD "XXXX"
const char* ssid = "eduroam"; // Eduroam SSID
int counter = 0;
void setup() {
  Serial.begin(115200);
  delay(10);
  Serial.println();
  Serial.print("Connecting to network: ");
  Serial.println(ssid);
  WiFi.disconnect(true);  //disconnect form wifi to set new wifi connection
  WiFi.mode(WIFI_STA); //init wifi mode 
  esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)EAP_ANONYMOUS_IDENTITY, strlen(EAP_ANONYMOUS_IDENTITY)); 
  esp_wifi_sta_wpa2_ent_set_username((uint8_t *)EAP_IDENTITY, strlen(EAP_IDENTITY));
  esp_wifi_sta_wpa2_ent_set_password((uint8_t *)EAP_PASSWORD, strlen(EAP_PASSWORD));
  esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT(); //set config settings to default
  esp_wifi_sta_wpa2_ent_enable(&config); //set config settings to enable function
  WiFi.begin(ssid); //connect to wifi
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    counter++;
    if(counter>=60){ //after 30 seconds timeout - reset board
      ESP.restart();
    }
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address set: "); 
  Serial.println(WiFi.localIP()); //print LAN IP
}
void loop() {
  if (WiFi.status() == WL_CONNECTED) { //if we are connected to Eduroam network
    counter = 0; //reset counter
    Serial.println("Wifi is still connected with IP: "); 
    Serial.println(WiFi.localIP());   //inform user about his IP address
  }else if (WiFi.status() != WL_CONNECTED) { //if we lost connection, retry
    WiFi.begin(ssid);      
  }
  while (WiFi.status() != WL_CONNECTED) { //during lost connection, print dots
    delay(500);
    Serial.print(".");
    counter++;
    if(counter>=60){ //30 seconds timeout - reset board
    ESP.restart();
    }
  }
  Serial.print("Connecting to website: ");
   HTTPClient http;
   http.begin("139.59.206.133/myAuthCode/get/V0"); //HTTP
   int httpCode = http.GET();
        if(httpCode > 0) {
            // HTTP header has been send and Server response header has been handled
            Serial.printf("[HTTP] GET... code: %d\n", httpCode);
            if(httpCode == HTTP_CODE_OK) {
                String payload = http.getString();
                Serial.println(payload);
            }
        } else {
            Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
        }

        http.end();
delay(5000);
}

Talk to your IT department again, it looks like the Blynk traffic is being blocked.

The alternative is to set-up a local Blynk server so that your data packets do t need to go through the firewall.

Pete.