Blink an LED with ESP32 blueprint won't compile

I’m trying to use the “simple beginner” example blueprint to blink the LED on a ESP32. The ESP32 works as I’ve run a timed blink sketch on it. When I open the .ino file normally in the Arduino IDE (v2.3.4) NINE tabs open and compiling takes forever but I eventually get a string of errors about WIFI.

If I open by “add file” as the tutorial says, (or paste code in new sketch) compiler can’t find BlynkEdgent.h.

I’ve installed 2 blynk libraries, deleted and reinstalled, and the files are in the same folder as .ino.

After several hours running in circles I gave up around mid-night. But I couldn’t sleep thinking about the problem!

You need to share those error messages if you want assistance with the issue.

Don’t forget to use triple backticks when posting the compiler error messages to the forum. Don’t share the error message as a screenshot.

Pete.

took 1m45s, but here it is.

In file included from C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\BlynkEdgent.h:8,
                 from C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\Edgent_Blynk_ESP32_LED.ino:18:
c:\BA\Arduino\libraries\Blynk\src/BlynkSimpleEsp32_SSL.h: In member function 'void BlynkWifi<Transport>::connectWiFi(const char*, const char*)':
c:\BA\Arduino\libraries\Blynk\src/BlynkSimpleEsp32_SSL.h:67:9: error: 'WiFi' was not declared in this scope
   67 |         WiFi.mode(WIFI_STA);
      |         ^~~~
c:\BA\Arduino\libraries\Blynk\src/BlynkSimpleEsp32_SSL.h:67:19: error: 'WIFI_STA' was not declared in this scope
   67 |         WiFi.mode(WIFI_STA);
      |                   ^~~~~~~~
c:\BA\Arduino\libraries\Blynk\src/BlynkSimpleEsp32_SSL.h:67:19: note: the macro 'WIFI_STA' had not yet been defined
In file included from C:\Users\DELL\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.1\libraries\WiFi\src/WiFi.h:33,
                 from C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\OTA.h:2,
                 from C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\BlynkEdgent.h:45:
C:\Users\DELL\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.1\libraries\WiFi\src/WiFiType.h:35: note: it was later defined here
   35 | #define WIFI_STA    WIFI_MODE_STA
      | 
c:\BA\Arduino\libraries\Blynk\src/BlynkSimpleEsp32_SSL.h:73:33: error: 'WL_CONNECTED' was not declared in this scope; did you mean 'BLYNK_CONNECTED'?
   73 |         while (WiFi.status() != WL_CONNECTED) {
      |                                 ^~~~~~~~~~~~
      |                                 BLYNK_CONNECTED
In file included from C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\BlynkEdgent.h:43:
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h: In function 'String getWiFiMacAddress()':
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:147:10: error: 'WiFi' was not declared in this scope
  147 |   return WiFi.macAddress();
      |          ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h: In function 'String getWiFiApBSSID()':
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:152:10: error: 'WiFi' was not declared in this scope
  152 |   return WiFi.softAPmacAddress();
      |          ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h: In function 'String getWiFiNetworkSSID()':
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:157:10: error: 'WiFi' was not declared in this scope
  157 |   return WiFi.SSID();
      |          ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h: In function 'String getWiFiNetworkBSSID()':
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:162:10: error: 'WiFi' was not declared in this scope
  162 |   return WiFi.BSSIDstr();
      |          ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h: In function 'void enterConfigMode()':
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:167:3: error: 'WiFi' was not declared in this scope
  167 |   WiFi.mode(WIFI_OFF);
      |   ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:167:13: error: 'WIFI_OFF' was not declared in this scope
  167 |   WiFi.mode(WIFI_OFF);
      |             ^~~~~~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:167:13: note: the macro 'WIFI_OFF' had not yet been defined
C:\Users\DELL\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.1\libraries\WiFi\src/WiFiType.h:34: note: it was later defined here
   34 | #define WIFI_OFF    WIFI_MODE_NULL
      | 
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:169:13: error: 'WIFI_AP' was not declared in this scope
  169 |   WiFi.mode(WIFI_AP);
      |             ^~~~~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:169:13: note: the macro 'WIFI_AP' had not yet been defined
C:\Users\DELL\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.1\libraries\WiFi\src/WiFiType.h:36: note: it was later defined here
   36 | #define WIFI_AP     WIFI_MODE_AP
      | 
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h: In lambda function:
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:332:21: error: 'WiFi' is not captured
  332 |     int wifi_nets = WiFi.scanNetworks(true, true);
      |                     ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:330:33: note: the lambda has no capture-default
  330 |   server.on("/wifi_scan.json", []() {
      |                                 ^
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:167:3: note: '<typeprefixerror>WiFi' declared here
  167 |   WiFi.mode(WIFI_OFF);
      |   ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:338:19: error: 'WiFi' is not captured
  338 |       wifi_nets = WiFi.scanComplete();
      |                   ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:330:33: note: the lambda has no capture-default
  330 |   server.on("/wifi_scan.json", []() {
      |                                 ^
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:167:3: note: '<typeprefixerror>WiFi' declared here
  167 |   WiFi.mode(WIFI_OFF);
      |   ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:350:15: error: 'WiFi' is not captured
  350 |           if (WiFi.RSSI(indices[j]) > WiFi.RSSI(indices[i])) {
      |               ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:330:33: note: the lambda has no capture-default
  330 |   server.on("/wifi_scan.json", []() {
      |                                 ^
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:167:3: note: '<typeprefixerror>WiFi' declared here
  167 |   WiFi.mode(WIFI_OFF);
      |   ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:350:39: error: 'WiFi' is not captured
  350 |           if (WiFi.RSSI(indices[j]) > WiFi.RSSI(indices[i])) {
      |                                       ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:330:33: note: the lambda has no capture-default
  330 |   server.on("/wifi_scan.json", []() {
      |                                 ^
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:167:3: note: '<typeprefixerror>WiFi' declared here
  167 |   WiFi.mode(WIFI_OFF);
      |   ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:367:11: error: 'WiFi' is not captured
  367 |           WiFi.SSID(id).c_str(),
      |           ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:330:33: note: the lambda has no capture-default
  330 |   server.on("/wifi_scan.json", []() {
      |                                 ^
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:167:3: note: '<typeprefixerror>WiFi' declared here
  167 |   WiFi.mode(WIFI_OFF);
      |   ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:368:11: error: 'WiFi' is not captured
  368 |           WiFi.BSSIDstr(id).c_str(),
      |           ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:330:33: note: the lambda has no capture-default
  330 |   server.on("/wifi_scan.json", []() {
      |                                 ^
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:167:3: note: '<typeprefixerror>WiFi' declared here
  167 |   WiFi.mode(WIFI_OFF);
      |   ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:369:11: error: 'WiFi' is not captured
  369 |           WiFi.RSSI(id),
      |           ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:330:33: note: the lambda has no capture-default
  330 |   server.on("/wifi_scan.json", []() {
      |                                 ^
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:167:3: note: '<typeprefixerror>WiFi' declared here
  167 |   WiFi.mode(WIFI_OFF);
      |   ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:370:24: error: 'WiFi' is not captured
  370 |           wifiSecToStr(WiFi.encryptionType(id)),
      |                        ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:330:33: note: the lambda has no capture-default
  330 |   server.on("/wifi_scan.json", []() {
      |                                 ^
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:167:3: note: '<typeprefixerror>WiFi' declared here
  167 |   WiFi.mode(WIFI_OFF);
      |   ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:371:11: error: 'WiFi' is not captured
  371 |           WiFi.channel(id)
      |           ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:330:33: note: the lambda has no capture-default
  330 |   server.on("/wifi_scan.json", []() {
      |                                 ^
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:167:3: note: '<typeprefixerror>WiFi' declared here
  167 |   WiFi.mode(WIFI_OFF);
      |   ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:377:7: error: 'WiFi' is not captured
  377 |       WiFi.scanDelete();
      |       ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:330:33: note: the lambda has no capture-default
  330 |   server.on("/wifi_scan.json", []() {
      |                                 ^
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:167:3: note: '<typeprefixerror>WiFi' declared here
  167 |   WiFi.mode(WIFI_OFF);
      |   ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h: In function 'void enterConnectNet()':
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:417:3: error: 'WiFi' was not declared in this scope
  417 |   WiFi.enableSTA(false);
      |   ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:440:54: error: 'WL_CONNECTED' was not declared in this scope; did you mean 'BLYNK_CONNECTED'?
  440 |   while ((timeoutMs > millis()) && (WiFi.status() != WL_CONNECTED))
      |                                                      ^~~~~~~~~~~~
      |                                                      BLYNK_CONNECTED
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:451:24: error: 'WL_CONNECTED' was not declared in this scope; did you mean 'BLYNK_CONNECTED'?
  451 |   if (WiFi.status() == WL_CONNECTED) {
      |                        ^~~~~~~~~~~~
      |                        BLYNK_CONNECTED
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h: In function 'void enterConnectCloud()':
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:475:10: error: 'WiFi' was not declared in this scope
  475 |         (WiFi.status() == WL_CONNECTED) &&
      |          ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:475:27: error: 'WL_CONNECTED' was not declared in this scope; did you mean 'BLYNK_CONNECTED'?
  475 |         (WiFi.status() == WL_CONNECTED) &&
      |                           ^~~~~~~~~~~~
      |                           BLYNK_CONNECTED
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:495:14: error: 'WiFi' was not declared in this scope
  495 |   } else if (WiFi.status() != WL_CONNECTED) {
      |              ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:495:31: error: 'WL_CONNECTED' was not declared in this scope; did you mean 'BLYNK_CONNECTED'?
  495 |   } else if (WiFi.status() != WL_CONNECTED) {
      |                               ^~~~~~~~~~~~
      |                               BLYNK_CONNECTED
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h: In function 'void enterSwitchToSTA()':
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:520:3: error: 'WiFi' was not declared in this scope
  520 |   WiFi.mode(WIFI_OFF);
      |   ^~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:520:13: error: 'WIFI_OFF' was not declared in this scope
  520 |   WiFi.mode(WIFI_OFF);
      |             ^~~~~~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:520:13: note: the macro 'WIFI_OFF' had not yet been defined
C:\Users\DELL\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.1\libraries\WiFi\src/WiFiType.h:34: note: it was later defined here
   34 | #define WIFI_OFF    WIFI_MODE_NULL
      | 
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:522:13: error: 'WIFI_STA' was not declared in this scope
  522 |   WiFi.mode(WIFI_STA);
      |             ^~~~~~~~
C:\BA\Arduino\Sketches\Edgent_Blynk_ESP32_LED\ConfigMode.h:522:13: note: the macro 'WIFI_STA' had not yet been defined
C:\Users\DELL\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.1\libraries\WiFi\src/WiFiType.h:35: note: it was later defined here
   35 | #define WIFI_STA    WIFI_MODE_STA
      | 

exit status 1

Compilation error: 'WiFi' was not declared in this scope

I can also repeat the code but it is direct from the zip file (w or w/o authentication info). Bah, why not. Here it is.


// *** MAIN SETTINGS ***
// Replace this block with correct template settings.
// You can find it for every template here:
//
//   https://blynk.cloud/dashboard/templates

#define BLYNK_TEMPLATE_ID "TMPL2AmdMBOLi"
#define BLYNK_TEMPLATE_NAME "LED ESP32"

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

#include "BlynkEdgent.h"

#define LED_PIN 2  // Use pin 2 for LED (change it, if your board uses another pin)


// V0 is a datastream used to transfer and store LED switch state.
// Evey time you use the LED switch in the app, this function
// will listen and update the state on device
BLYNK_WRITE(V0)
{
  // Local variable `value` stores the incoming LED switch state (1 or 0)
  // Based on this value, the physical LED on the board will be on or off:
  int value = param.asInt();

  if (value == 1) {
    digitalWrite(LED_PIN, HIGH);
    Serial.print("value =");
    Serial.println(value);
  } else {
    digitalWrite(LED_PIN, LOW);
    Serial.print("value = ");
    Serial.println(value);
  }
}
void setup()
{
  pinMode(LED_PIN, OUTPUT);

  // Debug console. Make sure you have the same baud rate selected in your serial monitor
  Serial.begin(115200);
  delay(100);

  BlynkEdgent.begin();
}

void loop() {
  BlynkEdgent.run();
  delay(10);
}

If you’d have taken a few minutes to search this forum for the compilation error message “‘WiFi’ was not declared in this scope” you would have found this…

Pete.

I think you for your help. I did spend, not only minutes, but hours researching in numerous locations (including here) for the answers to various aspects of the problems. 50 plus error messages about 9 tabs *.h tabs that opened by themselves were somewhat overwhelming. In fact, I searched here immediately before posting. Perhaps I got hung up on the “File not found” error message on the Edgent.h.

Mr. Knight, you seem knowledgeable and I appreciate your willingness to share that knowledge. I understand it must be frustrating when us new idiots can’t even figure out the easy stuff or want you to do our work for us. But even in the little time I’ve spent here (less than a few minutes, I guess) I saw your name repeatedly and almost every time you come across as . . . gruff. Sometimes even rude and it doesn’t help. There seems to be a link in inverse proportion between the intelligence gene and the courtesy gene on forums. Buck evolution!.

No problem, I’m happy to refrain from gruffly pointing you in the direction of solutions in future. Just add a little note to future posts that my input is not required.

Pete.

1 Like

I don’t know how to laugh on a bulletin board, or what ever they are called now, but I’m doing it. You made me chuckle. In a good way.

Have a good one. (unless you’d rather not :slight_smile: )