ESP32 -WPA Enterprise WIFI connection to Blynk

Hi @PeteKnight, I having some issue on connecting to the Blynk IoT. I manage to connect my esp32 module to WPA2 enterprise WIFI. Attached is the code that I manage to connect to NETWORK, I got comment out the part that failed to link with Blynk.

#include <WiFi.h> //Wifi library
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include "esp_wpa2.h" //wpa2 library for connections to Enterprise networks

#define EAP_IDENTITY "xxx"
#define EAP_PASSWORD "xxx"          

#define BLYNK_TEMPLATE_ID "xxx"
#define BLYNK_DEVICE_NAME "xxx"
#define BLYNK_AUTH_TOKEN "xxx"

#define BLYNK_PRINT Serial

//SSID NAME
const char* ssid = "xxxx"; 
char auth[] = BLYNK_AUTH_TOKEN;
char pass[] = EAP_PASSWORD;

void setup() {
  Serial.begin(115200);
  delay(10);
  Serial.println();
  Serial.print(F("Connecting to network: "));
  Serial.println(ssid);
  WiFi.disconnect(true);  //disconnect form wifi to set new wifi connection
  WiFi.mode(WIFI_STA); //init wifi mode
  WiFi.begin(ssid, WPA2_AUTH_PEAP, EAP_IDENTITY, EAP_IDENTITY, EAP_PASSWORD); //without CERTIFICATE, NO ANONYMOUS IDENTITY
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(F("."));
  }
  Serial.println("");
  Serial.println(F("WiFi is connected!"));
  Serial.println(F("IP address set: "));
  Serial.println(WiFi.localIP()); //print LAN IP
  //Blynk.begin(auth, ssid, pass);
}
void loop() {
  //Blynk.run();
  yield();
}

When you copied this from the device screen you overlooked this important message…

which results in a “Connecting to blynk-cloud.com” message and an “Invalid Auth Token” message in your serial monitor (which you haven’t shared).

Pete.

I still not manage connect to Blynk application. I have enter all the important information which incluse auth token , device name , template id and so on. I have shift the circled code to the top. I got try to serial print “HI” after the blynk.begin but nothing appears.

#include <WiFi.h> //Wifi library
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include "esp_wpa2.h" //wpa2 library for connections to Enterprise networks

#define BLYNK_TEMPLATE_ID "xxx"
#define BLYNK_DEVICE_NAME "xxx"
#define BLYNK_AUTH_TOKEN "k7kzZF8NpkVTLjWtO2bog9iRyWQt--z6"

#define EAP_IDENTITY "xxx" 
#define EAP_PASSWORD "xxx"          

#define BLYNK_PRINT Serial

//SSID NAME
char auth[] = BLYNK_AUTH_TOKEN;
const char* ssid = "xxx"; 
char username[] = EAP_IDENTITY;
char pass[] = EAP_PASSWORD;

void setup() {
  Serial.begin(115200);
  delay(10);
  Serial.println();
  Serial.print(F("Connecting to network: "));
  Serial.println(ssid);
  WiFi.disconnect(true);  //disconnect form wifi to set new wifi connection
  WiFi.mode(WIFI_STA); //init wifi mode
  WiFi.begin(ssid, WPA2_AUTH_PEAP, EAP_IDENTITY, EAP_IDENTITY, EAP_PASSWORD); //without CERTIFICATE, NO ANONYMOUS IDENTITY
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(F("."));
  }
  Serial.println("");
  Serial.println(F("WiFi is connected!"));
  Serial.println(F("IP address set: "));
  Serial.println(WiFi.localIP()); //print LAN IP
  Blynk.begin(auth, ssid, username, pass);
}
void loop() {
  Blynk.run();
  yield();
}

Kyle.

Not in the code you’ve just posted!

How about you take a few steps back and do what I asked when you posted in the other topic…

Pete.

Hi @PeteKnight , I still get the same output which the WIFI is connected but didn’t manage to link to Blynk. Below is the code is this what u mean? got try to serial print “HI” after the blynk.begin but nothing appears, i only print until showing the ip address

#define BLYNK_TEMPLATE_ID "xxx"
#define BLYNK_DEVICE_NAME "xxx"
#define BLYNK_AUTH_TOKEN "xxx"

#include <WiFi.h> //Wifi library
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include "esp_wpa2.h" //wpa2 library for connections to Enterprise networks

#define EAP_IDENTITY "xxx" 
#define EAP_PASSWORD "xxx"           

#define BLYNK_PRINT Serial

//SSID NAME
char auth[] = BLYNK_AUTH_TOKEN;
const char* ssid = "xxx"; 
char pass[] = EAP_PASSWORD;

void setup() {
  Serial.begin(115200);
  delay(10);
  Serial.println();
  Serial.print(F("Connecting to network: "));
  Serial.println(ssid);
  WiFi.disconnect(true);  //disconnect form wifi to set new wifi connection
  WiFi.mode(WIFI_STA); //init wifi mode
  WiFi.begin(ssid, WPA2_AUTH_PEAP, EAP_IDENTITY, EAP_IDENTITY, EAP_PASSWORD); //without CERTIFICATE, NO ANONYMOUS IDENTITY
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(F("."));
  }
  Serial.println("");
  Serial.println(F("WiFi is connected!"));
  Serial.println(F("IP address set: "));
  Serial.println(WiFi.localIP()); //print LAN IP
  Blynk.begin(auth, ssid, pass);
}
void loop() {
  Blynk.run();
  yield();
}

Try hitting the + New Topic button, select the category of “Need help with my project” then start reading. Copy the text if necessary, then abandon the process of creating the new topic.

Provide ALL of the requested information, plus the other things I’ve asked for (serial monitor output that isn’t a screenshot etc).

Once you’ve done that we’ll carry-on the discussion.

Pete.

Hi, this is the information needed.
Hardware model :NodeMCU - 32S
Smartphone OS : android vsersion 12
Blynk server is used.
Blynk library version is 1.1.0

HI @PeteKnight, I having some issue on connecting to the Blynk IoT. I manage to connect my esp32 module to WPA2 enterprise WIFI. Attached is the code that I manage to connect to NETWORK but failed to link with Blynk.server.

The serial monitor shows that the wifi is connected and the ip address is printed on the serial monitor. But the message after the Blynk.begin() is not printed , thanks

16:50:02.003 → Connecting to network: LabWLAN
16:50:02.614 → …
16:50:07.971 → WiFi is connected!
16:50:07.971 → IP address set:
16:50:07.971 → 10.158.102.11

#define BLYNK_TEMPLATE_ID "xxx"
#define BLYNK_DEVICE_NAME "xxx"
#define BLYNK_AUTH_TOKEN "xxx"

#include <WiFi.h> //Wifi library
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include "esp_wpa2.h" //wpa2 library for connections to Enterprise networks

#define EAP_IDENTITY "xxx" 
#define EAP_PASSWORD "xxx"         
#define BLYNK_PRINT Serial

//SSID NAME
char auth[] = BLYNK_AUTH_TOKEN;
const char* ssid = "xxx"; 
//char username[] = EAP_IDENTITY;
//char pass[] = EAP_PASSWORD;

//BlynkTimer timer;

void setup() {
  Serial.begin(115200);
  delay(10);
  Serial.println();
  Serial.print(F("Connecting to network: "));
  Serial.println(ssid);
  WiFi.disconnect(true);  //disconnect form wifi to set new wifi connection
  WiFi.mode(WIFI_STA); //init wifi mode
  WiFi.begin(ssid, WPA2_AUTH_PEAP, EAP_IDENTITY, EAP_IDENTITY, EAP_PASSWORD); //without CERTIFICATE, NO ANONYMOUS IDENTITY
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(F("."));
  }
  Serial.println("");
  Serial.println(F("WiFi is connected!"));
  Serial.println(F("IP address set: "));
  Serial.println(WiFi.localIP()); //print LAN IP
  //Blynk.begin(auth, ssid, pass);
  Blynk.begin(auth, ssid, EAP_PASSWORD);
  Serial.println("connected to the Blynk server");
}
void loop() {
  Blynk.run();
  yield();
}

Kyle.

Pete.

I have edited from the chat , @PeteKnight , I think that is all u need. If i did wrong just give one example , thanks

You need to put triple backticks before and after your serial monitor output, the same as wnhe you post code.

Please move this line…

so that it is between these two lines of code…

then re-test your code and post the resulting serial output.

Pete.

Hi @PeteKnight, attached is the code and serial monitor output.

17:29:03.251 -> Connecting to network: LabWLAN
17:29:03.862 -> ..........................................................................
17:29:41.020 -> WiFi is connected!
17:29:41.020 -> IP address set: 
17:29:41.020 -> 10.158.102.11
17:29:41.020 -> [37806] Connecting to LabWLAN
17:29:46.263 -> [43051] Connected to WiFi
17:29:46.263 -> [43052] IP: 10.158.102.11
17:29:46.263 -> [43052] 
17:29:46.263 ->     ___  __          __
17:29:46.263 ->    / _ )/ /_ _____  / /__
17:29:46.309 ->   / _  / / // / _ \/  '_/
17:29:46.309 ->  /____/_/\_, /_//_/_/\_\
17:29:46.309 ->         /___/ v1.1.0 on ESP32
17:29:46.309 -> 
17:29:46.309 ->  #StandWithUkraine    https://bit.ly/swua
17:29:46.309 -> 
17:29:46.309 -> 
17:29:46.309 -> [43062] Connecting to blynk.cloud:80
17:30:04.618 -> [61369] Connecting to blynk.cloud:80
17:30:23.098 -> [79881] Connecting to blynk.cloud:80
17:30:41.627 -> [98394] Connecting to blynk.cloud:80
17:31:00.127 -> [116907] Connecting to blynk.cloud:80
17:31:18.650 -> [135420] Connecting to blynk.cloud:80
17:31:37.167 -> [153932] Connecting to blynk.cloud:80
17:31:55.686 -> [172445] Connecting to blynk.cloud:80
17:32:14.187 -> [190958] Connecting to blynk.cloud:80
17:45:12.351 -> [968600] Connecting to blynk.cloud:80

above is the monitor serial output but the status of device remain offline.

#define BLYNK_TEMPLATE_ID "TMPLpODhcl2v"
#define BLYNK_DEVICE_NAME "Smart Locker"
#define BLYNK_AUTH_TOKEN "k7kzZF8NpkVTLjWtO2bog9iRyWQt--z6"

#define BLYNK_PRINT Serial

#include <WiFi.h> //Wifi library
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include "esp_wpa2.h" //wpa2 library for connections to Enterprise networks

#define EAP_IDENTITY "sys_cbrd" 
#define EAP_PASSWORD "KyleGeeChunYeow@990916"           

//SSID NAME
char auth[] = BLYNK_AUTH_TOKEN;
const char* ssid = "LabWLAN"; // eduroam SSID
//char username[] = EAP_IDENTITY;
//char pass[] = EAP_PASSWORD;

//BlynkTimer timer;

void setup() {
  Serial.begin(115200);
  delay(10);
  Serial.println();
  Serial.print(F("Connecting to network: "));
  Serial.println(ssid);
  WiFi.disconnect(true);  //disconnect form wifi to set new wifi connection
  WiFi.mode(WIFI_STA); //init wifi mode
  WiFi.begin(ssid, WPA2_AUTH_PEAP, EAP_IDENTITY, EAP_IDENTITY, EAP_PASSWORD); //without CERTIFICATE, NO ANONYMOUS IDENTITY
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(F("."));
  }
  Serial.println("");
  Serial.println(F("WiFi is connected!"));
  Serial.println(F("IP address set: "));
  Serial.println(WiFi.localIP()); //print LAN IP
  //Blynk.begin(auth, ssid, pass);
  Blynk.begin(auth, ssid, EAP_PASSWORD);
  Serial.println("connected to the Blynk server");
}
void loop() {
  Blynk.run();
  yield();
}

Olay. There is a good possibility that the network you are connecting to is blocking the Blynk data packets, either outbound or inbound.

This may be because you’re using port 80, which you could test by changing this line:

to this:

#include <BlynkSimpleEsp32_SSL.h>

There is however a basic flaw in what you’re doing in your sketch, which is that you are manually creating a WiFi connection with this code:

then throwing that connection away and asking Blynk to create another one here:

You’d be better removing the Blynk.begin line and replacing it with:

Blynk.config(BLYNK_AUTH_TOKEN);
Blynk.connect();

Which will re-use your existing WiFi connection rather than attempting to create a new one.

If that still doesn’t work then try adding:

#define BLYNK_DEBUG immediately after #define BLYNK_PRINT Serial

Pete.

Hi @PeteKnight , this is the output of serial monitor. I not sure why it still unable to connect with Blynk server.

15:42:35.344 -> WiFi is connected!
15:42:35.344 -> IP address set: 
15:42:35.344 -> 10.158.102.11
15:42:35.344 -> [4150] 
15:42:35.344 ->     ___  __          __
15:42:35.344 ->    / _ )/ /_ _____  / /__
15:42:35.344 ->   / _  / / // / _ \/  '_/
15:42:35.344 ->  /____/_/\_, /_//_/_/\_\
15:42:35.344 ->         /___/ v1.1.0 on ESP32
15:42:35.382 -> 
15:42:35.382 ->  #StandWithUkraine    https://bit.ly/swua
15:42:35.382 -> 
15:42:35.382 -> 
15:42:35.382 -> [4160] Connecting to blynk.cloud:443
15:42:53.652 -> [22455] Secure connection failed
15:42:53.652 -> connected to the Blynk server
15:42:53.652 -> [22455] Connecting to blynk.cloud:443
15:43:12.151 -> [40962] Secure connection failed
15:43:12.151 -> [40962] Connecting to blynk.cloud:443

Kyle

I gave you a variety of possible things to try, and steps to follow in my last post, and you’ve responded with a serial monitor output which seems to show that you’ve tried using SSL, but you’ve not provided any more information about other things that you’ve tried, and what the results were.

What more do you want from me?

Pete.

Hi @PeteKnight , I have change to SSL library and the blynk begin is replaced with blynk config and blynk connect.

15:42:53.652 -> [22455] Connecting to blynk.cloud:443
15:43:12.151 -> [40962] Secure connection failed

this is what is shows from the serial monitor.

Next, I add on #define BLYNK_DEBUG below the #define BLYNK_PRINT Serial , the output from serial monitor is still the same.

Kyle.

Hi @PeteKnight , any additional information provided?

This seems strange. Your serial output should be significantly different, like this…

Pete.

Hi @PeteKnight , attached is the code.

#define BLYNK_TEMPLATE_ID "xxx"
#define BLYNK_DEVICE_NAME "xxx"
#define BLYNK_AUTH_TOKEN "xxx"

#define BLYNK_PRINT Serial
#define BLYNK_DEBUG 

#include <WiFi.h> //Wifi library
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include "esp_wpa2.h" //wpa2 library for connections to Enterprise networks

#define EAP_IDENTITY "xxx" 
#define EAP_PASSWORD "xxx"           

//SSID NAME
char auth[] = BLYNK_AUTH_TOKEN;
const char* ssid = "xxx";
//char username[] = EAP_IDENTITY;
//char pass[] = EAP_PASSWORD;

//BlynkTimer timer;

void setup() {
  Serial.begin(115200);
  delay(10);
  Serial.println();
  Serial.print(F("Connecting to network: "));
  Serial.println(ssid);
  WiFi.disconnect(true);  //disconnect form wifi to set new wifi connection
  WiFi.mode(WIFI_STA); //init wifi mode
  WiFi.begin(ssid, WPA2_AUTH_PEAP, EAP_IDENTITY, EAP_IDENTITY, EAP_PASSWORD); //without CERTIFICATE, NO ANONYMOUS IDENTITY
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(F("."));
  }
  Serial.println("");
  Serial.println(F("WiFi is connected!"));
  Serial.println(F("IP address set: "));
  Serial.println(WiFi.localIP()); //print LAN IP
  //Blynk.begin(auth, ssid, pass);
  //Blynk.begin(auth, ssid, EAP_PASSWORD);
  Blynk.config(auth);
  Blynk.connect();
  //Serial.println("connected to the Blynk server");
}
void loop() {
  Blynk.run();
  yield();
}

After that , I upload the code and open serial monitor. This is what i saw from the output of my serial monitor.

16:19:12.773 -> Connecting to network: LabWLAN
16:19:13.389 -> ........
16:19:17.486 -> WiFi is connected!
16:19:17.486 -> IP address set: 
16:19:17.486 -> 10.158.102.11
16:19:17.486 -> [4742] 
16:19:17.486 ->     ___  __          __
16:19:17.486 ->    / _ )/ /_ _____  / /__
16:19:17.486 ->   / _  / / // / _ \/  '_/
16:19:17.486 ->  /____/_/\_, /_//_/_/\_\
16:19:17.486 ->         /___/ v1.1.0 on ESP32
16:19:17.522 -> 
16:19:17.522 ->  #StandWithUkraine    https://bit.ly/swua
16:19:17.522 -> 
16:19:17.522 -> 
16:19:17.522 -> [4752] Connecting to blynk.cloud:80
16:19:35.805 -> [23038] Connecting to blynk.cloud:80
16:19:54.282 -> [41549] Connecting to blynk.cloud:80
16:20:12.802 -> [60062] Connecting to blynk.cloud:80
16:20:31.349 -> [78575] Connecting to blynk.cloud:80

Maybe can check with IT side on the port whether is open when firewall is running?

Kyle.

Hi @PeteKnight ,

Do you have any idea regarding this issue? Is it because of the blynk doesn’t configured with proxy?

Kyle.

I don’t think any of your data is getting out to the Blynk server.

Pete.